From 8f8bca7350c25d21e079e3513d9b8fad93c42812 Mon Sep 17 00:00:00 2001 From: Eran Meir Date: Sat, 2 Jan 2016 03:49:39 +0200 Subject: Prevent pthread cflags options from being passed to linker (in order to fix build issue on mac) --- src/compiler.sml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/compiler.sml') diff --git a/src/compiler.sml b/src/compiler.sml index bf7491e5..5ac024d4 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -878,7 +878,7 @@ fun parseUrp' accLibs fname = | "jsFile" => (Settings.setFilePath thisPath; Settings.addJsFile arg) - + | _ => ErrorMsg.error ("Unrecognized command '" ^ cmd ^ "'"); read () end @@ -1518,7 +1518,7 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} = ^ " " ^ #compile proto ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname - val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " " ^ Config.pthreadLibs) + val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadLibs) val ssl = if Settings.getStaticLinking () then Config.openssl ^ " -ldl -lz" -- cgit v1.2.3 From 6747f5ff7d80001f112fd23af51a1275471f5bf0 Mon Sep 17 00:00:00 2001 From: Eran Meir Date: Sat, 2 Jan 2016 13:56:35 +0200 Subject: Untagle boot and static flags Boot flag should build a dynamic executable but link urweb libraries statically (from build tree). This should fix the problem of not being able to build static executables on OSX. --- src/compiler.sml | 4 +++- src/main.mlton.sml | 8 ++++---- src/settings.sig | 3 +++ src/settings.sml | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/compiler.sml') diff --git a/src/compiler.sml b/src/compiler.sml index 5ac024d4..e2dc168e 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1503,7 +1503,9 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} = let val proto = Settings.currentProtocol () - val lib = if Settings.getStaticLinking () then + val lib = if Settings.getBootLinking () then + !Settings.configLib ^ "/" ^ #linkStatic proto ^ " " ^ !Settings.configLib ^ "/liburweb.a" + else if Settings.getStaticLinking () then " -static " ^ !Settings.configLib ^ "/" ^ #linkStatic proto ^ " " ^ !Settings.configLib ^ "/liburweb.a" else "-L" ^ !Settings.configLib ^ " " ^ #linkDynamic proto ^ " -lurweb" diff --git a/src/main.mlton.sml b/src/main.mlton.sml index 67732b58..f595134f 100644 --- a/src/main.mlton.sml +++ b/src/main.mlton.sml @@ -16,7 +16,7 @@ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN @@ -64,7 +64,7 @@ fun oneRun args = fun doArgs args = case args of [] => () - | "-version" :: rest => + | "-version" :: rest => printVersion () | "-numeric-version" :: rest => printNumericVersion () @@ -151,7 +151,7 @@ fun oneRun args = doArgs rest) | "-boot" :: rest => (Compiler.enableBoot (); - Settings.setStaticLinking true; + Settings.setBootLinking true; doArgs rest) | "-sigfile" :: name :: rest => (Settings.setSigFile (SOME name); @@ -318,7 +318,7 @@ val () = case CommandLine.arguments () of (* Redirect the daemon's output to the socket. *) redirect Posix.FileSys.stdout; redirect Posix.FileSys.stderr; - + loop' ("", []); Socket.close sock; diff --git a/src/settings.sig b/src/settings.sig index 732a31fa..c75f12a3 100644 --- a/src/settings.sig +++ b/src/settings.sig @@ -238,6 +238,9 @@ signature SETTINGS = sig val setStaticLinking : bool -> unit val getStaticLinking : unit -> bool + val setBootLinking : bool -> unit + val getBootLinking : unit -> bool + val setDeadlines : bool -> unit val getDeadlines : unit -> bool diff --git a/src/settings.sml b/src/settings.sml index 94692a2e..38ea30fc 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -686,6 +686,10 @@ val staticLinking = ref false fun setStaticLinking b = staticLinking := b fun getStaticLinking () = !staticLinking +val bootLinking = ref false +fun setBootLinking b = bootLinking := b +fun getBootLinking () = !bootLinking + val deadlines = ref false fun setDeadlines b = deadlines := b fun getDeadlines () = !deadlines -- cgit v1.2.3 From 610dc28a6c858748c6a22ce4478eeaef66477514 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 16 Jan 2016 09:33:39 -0500 Subject: Tweaking discovery of Pthreads C flags --- m4/m4_ax_pthread.m4 | 12 ++++++++++++ src/compiler.sml | 11 ++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/compiler.sml') diff --git a/m4/m4_ax_pthread.m4 b/m4/m4_ax_pthread.m4 index d383ad5c..f0717ada 100644 --- a/m4/m4_ax_pthread.m4 +++ b/m4/m4_ax_pthread.m4 @@ -204,11 +204,22 @@ for flag in $ax_pthread_flags; do ;; esac + save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" + # This check added by Adam Chlipala on January 16, 2016. + # The documentation at the top of this file said that PTHREAD_CFLAGS needs to + # be used at link-time, too, but this test didn't seem to do so. + # For now, I'm patching just for the common case of '-pthread'. + case $flag in + -pthread) + LDFLAGS="$LDFLAGS -pthread" + ;; + esac + # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) @@ -230,6 +241,7 @@ for flag in $ax_pthread_flags; do [ax_pthread_ok=yes], []) + LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" diff --git a/src/compiler.sml b/src/compiler.sml index e2dc168e..e269c8b9 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1520,7 +1520,16 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} = ^ " " ^ #compile proto ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname - val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadLibs) + fun concatArgs (a1, a2) = + if CharVector.all Char.isSpace a1 then + a2 + else + a1 ^ " " ^ a2 + + val args = concatArgs (Config.ccArgs, Config.pthreadCflags) + val args = concatArgs (args, Config.pthreadLibs) + + val linker = Option.getOpt (linker, (Settings.getCCompiler ()) ^ " -Werror" ^ opt ^ " " ^ args) val ssl = if Settings.getStaticLinking () then Config.openssl ^ " -ldl -lz" -- cgit v1.2.3 From 7b379c724999c4b415b1c3826db748450c7a6571 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 7 Feb 2016 20:41:34 -0500 Subject: Finish removing PWild; only load a library once, even if referenced multiple times in a .urp tree --- lib/js/urweb.js | 2 +- src/cjr.sml | 3 +-- src/cjr_print.sml | 11 +++-------- src/compiler.sml | 36 +++++++++++++++++++++++------------- src/elaborate.sml | 2 +- src/jscomp.sml | 2 +- src/reduce.sml | 1 - tests/library.urp | 1 + tests/library2.urp | 1 + tests/multilib.ur | 3 +++ tests/multilib.urp | 5 +++++ 11 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 tests/library.urp create mode 100644 tests/library2.urp create mode 100644 tests/multilib.ur create mode 100644 tests/multilib.urp (limited to 'src/compiler.sml') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index ac469f20..410a0e23 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1848,7 +1848,7 @@ function execP(env, p, v) { } return env; default: - whine("Unknown Ur pattern kind" + p.c); + whine("Unknown Ur pattern kind " + p.c); } } diff --git a/src/cjr.sml b/src/cjr.sml index 3742a06f..e582e6ae 100644 --- a/src/cjr.sml +++ b/src/cjr.sml @@ -46,8 +46,7 @@ datatype patCon = | PConFfi of {mod : string, datatyp : string, con : string, arg : typ option} datatype pat' = - PWild - | PVar of string * typ + PVar of string * typ | PPrim of Prim.t | PCon of datatype_kind * patCon * pat option | PRecord of (string * pat * typ) list diff --git a/src/cjr_print.sml b/src/cjr_print.sml index bbbe5c8b..2471ce59 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -163,9 +163,7 @@ fun p_con_named env n = fun p_pat_preamble env (p, _) = case p of - PWild => (box [], - env) - | PVar (x, t) => (box [p_typ env t, + PVar (x, t) => (box [p_typ env t, space, string "__uwr_", p_ident x, @@ -194,8 +192,7 @@ fun p_patCon env pc = fun p_patMatch (env, disc) (p, loc) = case p of - PWild => string "1" - | PVar _ => string "1" + PVar _ => string "1" | PPrim (Prim.Int n) => box [string ("(" ^ disc), space, string "==", @@ -318,9 +315,7 @@ fun p_patMatch (env, disc) (p, loc) = fun p_patBind (env, disc) (p, loc) = case p of - PWild => - (box [], env) - | PVar (x, t) => + PVar (x, t) => (box [p_typ env t, space, string "__uwr_", diff --git a/src/compiler.sml b/src/compiler.sml index e269c8b9..7580c5e4 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1,4 +1,4 @@ -(* Copyright (c) 2008-2012, 2014, Adam Chlipala +(* Copyright (c) 2008-2012, 2014, 2016, Adam Chlipala * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -412,6 +412,14 @@ fun inputCommentableLine inf = val lastUrp = ref "" +structure SK = struct +type ord_key = string +val compare = String.compare +end + +structure SS = BinarySetFn(SK) +structure SM = BinaryMapFn(SK) + fun parseUrp' accLibs fname = (lastUrp := fname; if not (Posix.FileSys.access (fname ^ ".urp", []) orelse Posix.FileSys.access (fname ^ "/lib.urp", [])) @@ -459,6 +467,7 @@ fun parseUrp' accLibs fname = let val pathmap = ref (!pathmap) val bigLibs = ref [] + val libSet = ref SS.empty fun pu filename = let @@ -822,10 +831,19 @@ fun parseUrp' accLibs fname = fkind := {action = Settings.Deny, kind = kind, pattern = pattern} :: !fkind end | _ => ErrorMsg.error "Bad 'deny' syntax") - | "library" => if accLibs then - libs := pu (libify (relify arg)) :: !libs - else - bigLibs := libify' arg :: !bigLibs + | "library" => + if accLibs then + let + val arg = libify (relify arg) + in + if SS.member (!libSet, arg) then + () + else + (libs := pu arg :: !libs; + libSet := SS.add (!libSet, arg)) + end + else + bigLibs := libify' arg :: !bigLibs | "path" => (case String.fields (fn ch => ch = #"=") arg of [n, v] => ((pathmap := M.insert (!pathmap, n, OS.Path.mkAbsolute {path = v, relativeTo = dir})) @@ -936,14 +954,6 @@ fun addModuleRoot (k, v) = moduleRoots := relativeTo = OS.FileSys.getDir ()}, v) :: !moduleRoots -structure SK = struct -type ord_key = string -val compare = String.compare -end - -structure SS = BinarySetFn(SK) -structure SM = BinaryMapFn(SK) - exception MissingFile of string val parse = { diff --git a/src/elaborate.sml b/src/elaborate.sml index 9765b090..6965adfd 100644 --- a/src/elaborate.sml +++ b/src/elaborate.sml @@ -1565,7 +1565,7 @@ fun elabPat (pAll as (p, loc), (env, bound)) = case p of L.PVar x => let - val t = if SS.member (bound, x) then + val t = if x <> "_" andalso SS.member (bound, x) then (expError env (DuplicatePatternVariable (loc, x)); terror) else diff --git a/src/jscomp.sml b/src/jscomp.sml index d8c83b94..65a0fa3a 100644 --- a/src/jscomp.sml +++ b/src/jscomp.sml @@ -458,7 +458,7 @@ fun process (file : file) = fun jsPat (p, _) = case p of - PVar _ => str "{c:\"v\"}" + PVar _ => str "{/*hoho*/c:\"v\"}" | PPrim p => strcat [str "{c:\"c\",v:", jsPrim p, str "}"] diff --git a/src/reduce.sml b/src/reduce.sml index 08040ad3..04cec168 100644 --- a/src/reduce.sml +++ b/src/reduce.sml @@ -755,7 +755,6 @@ fun kindConAndExp (namedC, namedE) = end | ECase (_, [((PRecord [], _), e)], _) => exp env e - | ECase (_, [((PWild, _), e)], _) => exp env e | ECase (e, pes, {disc, result}) => let diff --git a/tests/library.urp b/tests/library.urp new file mode 100644 index 00000000..1c4d6fb2 --- /dev/null +++ b/tests/library.urp @@ -0,0 +1 @@ +script /bogus.js diff --git a/tests/library2.urp b/tests/library2.urp new file mode 100644 index 00000000..17b1ad55 --- /dev/null +++ b/tests/library2.urp @@ -0,0 +1 @@ +library library diff --git a/tests/multilib.ur b/tests/multilib.ur new file mode 100644 index 00000000..52c8cb30 --- /dev/null +++ b/tests/multilib.ur @@ -0,0 +1,3 @@ +fun main () : transaction page = return + + diff --git a/tests/multilib.urp b/tests/multilib.urp new file mode 100644 index 00000000..b33d66e4 --- /dev/null +++ b/tests/multilib.urp @@ -0,0 +1,5 @@ +library library +library library2 +rewrite all Multilib/* + +multilib -- cgit v1.2.3