summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler.mlb1
-rw-r--r--src/compiler.sig5
-rw-r--r--src/compiler.sml3
-rw-r--r--src/main.mlton.sml2
4 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler.mlb b/src/compiler.mlb
index 83212484..f0007284 100644
--- a/src/compiler.mlb
+++ b/src/compiler.mlb
@@ -1,4 +1,5 @@
$(SML_LIB)/basis/basis.mlb
+$(SML_LIB)/basis/mlton.mlb
urweb.mlb
diff --git a/src/compiler.sig b/src/compiler.sig
index 587b3a94..62b57856 100644
--- a/src/compiler.sig
+++ b/src/compiler.sig
@@ -65,6 +65,11 @@ signature COMPILER = sig
val compileC : {cname : string, oname : string, ename : string, libs : string,
profile : bool, debug : bool, link : string list} -> bool
+ val beforeC : (unit -> unit) ref
+ (* This function is called before beginning C compilation.
+ * The current use is for MLton to compact its heap here, to avoid hogging
+ * space after all the interesting ML code is done. *)
+
type ('src, 'dst) phase
type ('src, 'dst) transform
diff --git a/src/compiler.sml b/src/compiler.sml
index 21ffae27..de6b14b4 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -1311,6 +1311,8 @@ val toSqlify = transform sqlify "sqlify" o toMono_opt2
val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" => "\\'" | ch => str ch)
+val beforeC = ref (fn () => ())
+
fun compileC {cname, oname, ename, libs, profile, debug, link = link'} =
let
val proto = Settings.currentProtocol ()
@@ -1348,6 +1350,7 @@ fun compileC {cname, oname, ename, libs, profile, debug, link = link'} =
();
OS.Process.isSuccess (OS.Process.system s))
in
+ !beforeC ();
system compile andalso system link
end
diff --git a/src/main.mlton.sml b/src/main.mlton.sml
index debbce15..6f38efa8 100644
--- a/src/main.mlton.sml
+++ b/src/main.mlton.sml
@@ -32,6 +32,8 @@ val demo = ref (NONE : (string * bool) option)
val tutorial = ref false
val css = ref false
+val () = Compiler.beforeC := MLton.GC.pack
+
fun printVersion () = (print (Config.versionString ^ "\n");
OS.Process.exit OS.Process.success)
fun printNumericVersion () = (print (Config.versionNumber ^ "\n");