shithub: MicroHs

Download patch

ref: ddaf33c956850dd20b1002652ea7fcef6c817391
parent: fc9b604a099d9b054f3f885ec2d0b90b1a8dd624
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Nov 13 09:00:37 EST 2023

More Makefile changes

--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@
 GHCINCS= -ighc -isrc
 GHCWARNS= -Wall -Wno-unrecognised-warning-flags -Wno-x-partial
 GHCOPTS= -O
-GHCEXTS= -XScopedTypeVariables -XTupleSections
-GHCPKGS= -package mtl -package pretty
+GHCEXTS= -XScopedTypeVariables -XPatternGuards -XTupleSections -XTypeSynonymInstances -XFlexibleInstances
+GHCPKGS= #-package mtl -package pretty -package temporary -package process
 GHCTOOL= -F -pgmF Tools/convertX.sh
 GHCOUTDIR= ghc-out
 GHCOUT= -outputdir $(GHCOUTDIR)
@@ -16,8 +16,6 @@
 GHCPROF= # -prof -fprof-late #-prof -fprof-auto
 GHCFLAGS= $(GHCEXTS) $(GHCINCS) $(GHCWARNS) $(GHCOPTS) $(GHCTOOL) $(GHCPKGS) $(GHCOUT) $(GHCPROF)
 #
-MHSCOMP= bin/mhs -ilib -isrc MicroHs.Main
-#
 .PHONY:	clean bootstrap
 
 # Compile mhs from distribution, with C compiler
@@ -38,7 +36,7 @@
 # Generate distribution C file
 generated/mhs.c:	bin/mhs src/*/*.hs
 	@mkdir -p generated
-	$(MHSCOMP) -ogenerated/mhs.c
+	bin/mhs -ilib -isrc MicroHs.Main -ogenerated/mhs.c
 
 # Make sure boottrapping works
 bootstrap:	bin/mhs-stage2
@@ -49,7 +47,7 @@
 bin/mhs-stage1:	bin/mhs src/*/*.hs
 	@mkdir -p generated
 	@echo Build stage1 compiler
-	$(MHSCOMP) -ogenerated/mhs-stage1.c
+	bin/mhs -ilib -isrc MicroHs.Main -ogenerated/mhs-stage1.c
 	$(CCEVAL) generated/mhs-stage1.c -o bin/mhs-stage1
 
 # Build stage2 compiler with stage1 compiler, and compare
@@ -59,6 +57,11 @@
 	bin/mhs-stage1 -ilib -isrc MicroHs.Main -ogenerated/mhs-stage2.c
 	cmp generated/mhs-stage1.c generated/mhs-stage2.c
 	$(CCEVAL) generated/mhs-stage2.c -o bin/mhs-stage2
+
+# Run test examples with ghc-compiled compiler
+runtest:	bin/mhseval bin/gmhs tests/*.hs
+	cd tests; make alltest
+
 #
 clean:
 	rm -rf src/*/*.hi src/*/*.o *.comb *.tmp *~ bin/* a.out $(GHCOUTDIR) tmp/* Tools/*.o Tools/*.hi dist-newstyle generated/*-stage*
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -1909,7 +1909,12 @@
       } else {
         /* No handler, so just die. */
         CHKARGEV1(msg = evalstring(x));
+#if WANT_STDIO
+        fprintf(stderr, "mhs: %s\n", msg);
+        exit(1);
+#else  /* WANT_STDIO */
         ERR1("error: %s", msg);
+#endif  /* WANT_STDIO */
       }
     case T_SEQ:  CHECK(2); eval(ARG(TOP(0))); POP(2); n = TOP(-1); y = ARG(n); GOIND(y); /* seq x y = eval(x); y */
 
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,4 +1,4 @@
-MHS=../bin/mhs -i../lib
+MHS=../bin/gmhs -i../lib
 EVAL=../bin/mhseval
 .PHONY: test time clean errtest alltest
 
--