diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-12-27 13:18:32 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-12-27 13:18:32 -0500 |
commit | 834b3a5799b14cc722dfca9205c4b37e2faedce4 (patch) | |
tree | 4a63c8e1de989b220775c95117ae849c20f76f1c /src | |
parent | d14fddf5c814d77030a2bf1885ac2e955c8c961e (diff) |
Dynamic linking of the runtime system
Diffstat (limited to 'src')
-rw-r--r-- | src/cgi.sml | 3 | ||||
-rw-r--r-- | src/compiler.sml | 12 | ||||
-rw-r--r-- | src/fastcgi.sml | 3 | ||||
-rw-r--r-- | src/http.sml | 3 | ||||
-rw-r--r-- | src/main.mlton.sml | 3 | ||||
-rw-r--r-- | src/settings.sig | 10 | ||||
-rw-r--r-- | src/settings.sml | 10 |
7 files changed, 32 insertions, 12 deletions
diff --git a/src/cgi.sml b/src/cgi.sml index f57cd845..f853a12c 100644 --- a/src/cgi.sml +++ b/src/cgi.sml @@ -30,7 +30,8 @@ structure Cgi :> CGI = struct open Settings val () = addProtocol {name = "cgi", - link = clibFile "request.o" ^ " " ^ clibFile "cgi.o", + linkStatic = clibFile "cgi.o", + linkDynamic = "-lurweb_cgi", persistent = false} end diff --git a/src/compiler.sml b/src/compiler.sml index a596a21d..1ef8c5b1 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1025,13 +1025,17 @@ val toSqlify = transform sqlify "sqlify" o toMono_opt2 fun compileC {cname, oname, ename, libs, profile, debug, link = link'} = let val proto = Settings.currentProtocol () - val urweb_o = clibFile "urweb.o" - val memmem_o = clibFile "memmem.o" + + val lib = if Settings.getStaticLinking () then + clibFile "request.o" ^ " " ^ clibFile "queue.o" ^ " " ^ clibFile "urweb.o" + ^ " " ^ clibFile "memmem.o" ^ " " ^ #linkStatic proto + else + "-L" ^ Config.libC ^ " -lurweb " ^ #linkDynamic proto val compile = "gcc " ^ Config.gccArgs ^ " -Wimplicit -Werror -O3 -fno-inline -I " ^ Config.includ ^ " -c " ^ cname ^ " -o " ^ oname - val link = "gcc -Werror -O3 -lm -lmhash -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ urweb_o ^ " " ^ oname - ^ " " ^ memmem_o ^ " " ^ #link proto ^ " -o " ^ ename + val link = "gcc -Werror -O3 -lm -lmhash -pthread " ^ Config.gccArgs ^ " " ^ libs ^ " " ^ lib ^ " " ^ oname + ^ " -o " ^ ename val (compile, link) = if profile then diff --git a/src/fastcgi.sml b/src/fastcgi.sml index fbd24b5d..16836f30 100644 --- a/src/fastcgi.sml +++ b/src/fastcgi.sml @@ -30,7 +30,8 @@ structure Fastcgi :> FASTCGI = struct open Settings val () = addProtocol {name = "fastcgi", - link = clibFile "request.o" ^ " " ^ clibFile "queue.o" ^ " " ^ clibFile "fastcgi.o", + linkStatic = clibFile "fastcgi.o", + linkDynamic = "-lurweb_fastcgi", persistent = true} end diff --git a/src/http.sml b/src/http.sml index b835a4ac..3f6fc2df 100644 --- a/src/http.sml +++ b/src/http.sml @@ -30,7 +30,8 @@ structure Http :> HTTP = struct open Settings val () = addProtocol {name = "http", - link = clibFile "request.o" ^ " " ^ clibFile "queue.o" ^ " " ^ clibFile "http.o", + linkStatic = clibFile "http.o", + linkDynamic = "-lurweb_http", persistent = true} val () = setProtocol "http" diff --git a/src/main.mlton.sml b/src/main.mlton.sml index 36d0ce98..42f05259 100644 --- a/src/main.mlton.sml +++ b/src/main.mlton.sml @@ -63,6 +63,9 @@ fun doArgs args = | "-sql" :: s :: rest => (Settings.setSql (SOME s); doArgs rest) + | "-static" :: rest => + (Settings.setStaticLinking true; + doArgs rest) | arg :: rest => (if size arg > 0 andalso String.sub (arg, 0) = #"-" then raise Fail ("Unknown flag " ^ arg) diff --git a/src/settings.sig b/src/settings.sig index 574832a2..8eb4bc13 100644 --- a/src/settings.sig +++ b/src/settings.sig @@ -92,9 +92,10 @@ signature SETTINGS = sig (* Web protocols that generated programs may speak *) type protocol = { - name : string, (* Call it this on the command line *) - link : string, (* Pass these linker arguments *) - persistent : bool (* Multiple requests per process? *) + name : string, (* Call it this on the command line *) + linkStatic : string, (* Pass these static linker arguments *) + linkDynamic : string,(* Pass these dynamic linker arguments *) + persistent : bool (* Multiple requests per process? *) } val addProtocol : protocol -> unit val setProtocol : string -> unit @@ -182,4 +183,7 @@ signature SETTINGS = sig val setMonoInline : int -> unit val getMonoInline : unit -> int + val setStaticLinking : bool -> unit + val getStaticLinking : unit -> bool + end diff --git a/src/settings.sml b/src/settings.sml index a7f2cc9f..39398490 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -270,7 +270,8 @@ val checkMime = check type protocol = { name : string, - link : string, + linkStatic : string, + linkDynamic : string, persistent : bool } val protocols = ref ([] : protocol list) @@ -281,7 +282,8 @@ fun clibFile s = OS.Path.joinDirFile {dir = Config.libC, file = s} val curProto = ref {name = "", - link = "", + linkStatic = "", + linkDynamic = "", persistent = false} fun setProtocol name = case getProtocol name of @@ -427,4 +429,8 @@ val monoInline = ref 20 fun setMonoInline n = monoInline := n fun getMonoInline () = !monoInline +val staticLinking = ref false +fun setStaticLinking b = staticLinking := b +fun getStaticLinking () = !staticLinking + end |