summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.tex1
-rw-r--r--src/compiler.sig3
-rw-r--r--src/compiler.sml14
-rw-r--r--src/demo.sml1
-rw-r--r--tests/linker.ur1
-rw-r--r--tests/linker.urp4
6 files changed, 20 insertions, 4 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index ee4fdd0c..8b44e078 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -164,6 +164,7 @@ Here is the complete list of directive forms. ``FFI'' stands for ``foreign func
\item \texttt{transactionals}: maximum number of custom transactional actions (e.g., sending an e-mail) that may be run in a single page generation
\end{itemize}
\item \texttt{link FILENAME} adds \texttt{FILENAME} to the list of files to be passed to the linker at the end of compilation. This is most useful for importing extra libraries needed by new FFI modules.
+\item \texttt{linker CMD} sets \texttt{CMD} as the command line prefix to use for linking C object files. The command line will be completed with a space-separated list of \texttt{.o} and \texttt{.a} files, \texttt{-L} and \texttt{-l} flags, and finally with a \texttt{-o} flag to set the location where the executable should be written.
\item \texttt{minHeap NUMBYTES} sets the initial size for thread-local heaps used in handling requests. These heaps grow automatically as needed (up to any maximum set with \texttt{limit}), but each regrow requires restarting the request handling process.
\item \texttt{noXsrfProtection URIPREFIX} turns off automatic cross-site request forgery protection for the page handler identified by the given URI prefix. This will avoid checking cryptographic signatures on cookies, which is generally a reasonable idea for some pages, such as login pages that are going to discard all old cookie values, anyway.
\item \texttt{onError Module.var} changes the handling of fatal application errors. Instead of displaying a default, ugly error 500 page, the error page will be generated by calling function \texttt{Module.var} on a piece of XML representing the error message. The error handler should have type $\mt{xbody} \to \mt{transaction} \; \mt{page}$. Note that the error handler \emph{cannot} be in the application's main module, since that would register it as explicitly callable via URLs.
diff --git a/src/compiler.sig b/src/compiler.sig
index 53887ecb..7c39f28d 100644
--- a/src/compiler.sig
+++ b/src/compiler.sig
@@ -40,6 +40,7 @@ signature COMPILER = sig
timeout : int,
ffi : string list,
link : string list,
+ linker : string option,
headers : string list,
scripts : string list,
clientToServer : Settings.ffi list,
@@ -63,7 +64,7 @@ signature COMPILER = sig
val compile : string -> bool
val compiler : string -> unit
val compileC : {cname : string, oname : string, ename : string, libs : string,
- profile : bool, debug : bool, link : string list} -> bool
+ profile : bool, debug : bool, linker : string option, link : string list} -> bool
val beforeC : (unit -> unit) ref
(* This function is called before beginning C compilation.
diff --git a/src/compiler.sml b/src/compiler.sml
index 2ebf0d28..ce6f95af 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -44,6 +44,7 @@ type job = {
timeout : int,
ffi : string list,
link : string list,
+ linker : string option,
headers : string list,
scripts : string list,
clientToServer : Settings.ffi list,
@@ -399,6 +400,7 @@ fun parseUrp' accLibs fname =
timeout = 60,
ffi = [],
link = [],
+ linker = NONE,
headers = [],
scripts = [],
clientToServer = [],
@@ -518,6 +520,7 @@ fun parseUrp' accLibs fname =
val timeout = ref NONE
val ffi = ref []
val link = ref []
+ val linker = ref NONE
val headers = ref []
val scripts = ref []
val clientToServer = ref []
@@ -552,6 +555,7 @@ fun parseUrp' accLibs fname =
timeout = Option.getOpt (!timeout, 60),
ffi = rev (!ffi),
link = rev (!link),
+ linker = !linker,
headers = rev (!headers),
scripts = rev (!scripts),
clientToServer = rev (!clientToServer),
@@ -607,6 +611,7 @@ fun parseUrp' accLibs fname =
timeout = #timeout old,
ffi = #ffi old @ #ffi new,
link = #link old @ #link new,
+ linker = mergeO (fn (_, new) => new) (#linker old, #linker new),
headers = #headers old @ #headers new,
scripts = #scripts old @ #scripts new,
clientToServer = #clientToServer old @ #clientToServer new,
@@ -742,6 +747,7 @@ fun parseUrp' accLibs fname =
in
link := arg :: !link
end
+ | "linker" => linker := SOME arg
| "include" => headers := relifyA arg :: !headers
| "script" => scripts := arg :: !scripts
| "clientToServer" => clientToServer := ffiS () :: !clientToServer
@@ -1356,7 +1362,7 @@ val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'"
val beforeC = ref (fn () => ())
-fun compileC {cname, oname, ename, libs, profile, debug, link = link'} =
+fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} =
let
val proto = Settings.currentProtocol ()
@@ -1375,7 +1381,9 @@ fun compileC {cname, oname, ename, libs, profile, debug, link = link'} =
^ " " ^ #compile proto
^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname
- val link = Config.ccompiler ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " " ^ Config.pthreadLibs
+ val linker = Option.getOpt (linker, Config.ccompiler ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " " ^ Config.pthreadLibs)
+
+ val link = linker
^ " " ^ lib ^ " " ^ escapeFilename oname ^ " " ^ libs ^ " -lm " ^ Config.openssl ^ " -o " ^ escapeFilename ename
val (compile, link) =
@@ -1462,7 +1470,7 @@ fun compile job =
end;
compileC {cname = cname, oname = oname, ename = ename, libs = libs,
- profile = #profile job, debug = #debug job, link = #link job}
+ profile = #profile job, debug = #debug job, linker = #linker job, link = #link job}
before cleanup ())
end
diff --git a/src/demo.sml b/src/demo.sml
index 729dd218..35332637 100644
--- a/src/demo.sml
+++ b/src/demo.sml
@@ -103,6 +103,7 @@ fun make' {prefix, dirname, guided} =
profile = false,
ffi = [],
link = [],
+ linker = NONE,
headers = [],
scripts = [],
clientToServer = [],
diff --git a/tests/linker.ur b/tests/linker.ur
new file mode 100644
index 00000000..22c5e3ae
--- /dev/null
+++ b/tests/linker.ur
@@ -0,0 +1 @@
+fun main () : transaction page = return <xml/>
diff --git a/tests/linker.urp b/tests/linker.urp
new file mode 100644
index 00000000..9a0f8f43
--- /dev/null
+++ b/tests/linker.urp
@@ -0,0 +1,4 @@
+debug
+linker ld -g
+
+linker