[MLton-commit] r4911: Restored -{, target}-{as, cc, link}-opt behavior

Matthew Fluet fluet at mlton.org
Fri Dec 8 10:00:44 PST 2006


MAIL Restored -{,target}-{as,cc,link}-opt behavior

Reversed the behavior introduced by r4610.

The command switches -{,target}-{as,cc,link}-opt always tokenize their
argument on Char.isSpace, yeilding multiple gcc arguments.

The (new) command switches -{,target}-{as,cc,link}-opt-quote never
tokenize their argument, yeilding a single gcc argument.

Use the later if you need to pass include or library paths that have
spaces.


----------------------------------------------------------------------

U   mlton/trunk/bin/mlton-script
U   mlton/trunk/doc/changelog
U   mlton/trunk/mlton/main/main.fun
U   mlton/trunk/package/mingw/mlton.bat

----------------------------------------------------------------------

Modified: mlton/trunk/bin/mlton-script
===================================================================
--- mlton/trunk/bin/mlton-script	2006-12-07 23:11:38 UTC (rev 4910)
+++ mlton/trunk/bin/mlton-script	2006-12-08 18:00:36 UTC (rev 4911)
@@ -70,46 +70,45 @@
 # The darwin linker complains (loudly) about non-existent library
 # search paths.
 darwinLinkOpts=''
-if [ -d '/opt/local/lib' ]; then
-        darwinLinkOpts="$darwinLinkOpts -L/opt/local/lib"
-fi
 if [ -d '/sw/lib' ]; then
         darwinLinkOpts="$darwinLinkOpts -L/sw/lib"
 fi
+if [ -d '/opt/local/lib' ]; then
+        darwinLinkOpts="$darwinLinkOpts -L/opt/local/lib"
+fi
 
 doit "$lib" \
         -cc "$gcc"                                               \
-        -cc-opt "-I$lib/include"                                 \
+        -cc-opt-quote "-I$lib/include"                           \
         -cc-opt '-O1'                                            \
-        -cc-opts '-fno-strict-aliasing -fomit-frame-pointer -w'  \
+        -cc-opt '-fno-strict-aliasing -fomit-frame-pointer -w'   \
         -mlb-path-map "$lib/mlb-path-map"                        \
-        -target-as-opts amd64 '-m32 -mtune=opteron'              \
-        -target-cc-opts amd64 '-m32 -mtune=opteron'              \
-        -target-cc-opts darwin                                   \
+        -target-as-opt amd64 '-m32 -mtune=opteron'               \
+        -target-cc-opt amd64 '-m32 -mtune=opteron'               \
+        -target-cc-opt darwin                                    \
                 '-I/opt/local/include -I/sw/include'             \
-        -target-cc-opts freebsd '-I/usr/local/include'           \
-        -target-cc-opts netbsd '-I/usr/pkg/include'              \
-        -target-cc-opts openbsd '-I/usr/local/include'           \
-        -target-cc-opts solaris                                  \
-                '-Wa,-xarch=v8plusa
-                -mcpu=ultrasparc'                                \
-        -target-cc-opts sparc '-mcpu=v8 -m32'                    \
-        -target-cc-opts x86                                      \
+        -target-cc-opt freebsd '-I/usr/local/include'            \
+        -target-cc-opt netbsd '-I/usr/pkg/include'               \
+        -target-cc-opt openbsd '-I/usr/local/include'            \
+        -target-cc-opt solaris                                   \
+                '-Wa,-xarch=v8plusa -mcpu=ultrasparc'            \
+        -target-cc-opt sparc '-mcpu=v8 -m32'                     \
+        -target-cc-opt x86                                       \
                 '-fno-strength-reduce
                 -fschedule-insns
                 -fschedule-insns2
                 -malign-functions=5
                 -malign-jumps=2
                 -malign-loops=2'                                 \
-        -target-link-opts amd64 '-m32'                           \
-        -target-link-opts darwin "$darwinLinkOpts"               \
-        -target-link-opts freebsd '-L/usr/local/lib/'            \
-        -target-link-opts mingw                                  \
+        -target-link-opt amd64 '-m32'                            \
+        -target-link-opt darwin "$darwinLinkOpts"                \
+        -target-link-opt freebsd '-L/usr/local/lib/'             \
+        -target-link-opt mingw                                   \
                 '-lws2_32 -lkernel32 -lpsapi -lnetapi32'         \
-        -target-link-opts netbsd                                 \
+        -target-link-opt netbsd                                  \
                 '-Wl,-R/usr/pkg/lib -L/usr/pkg/lib/'             \
-        -target-link-opts openbsd '-L/usr/local/lib/'            \
-        -target-link-opts solaris '-lnsl -lsocket -lrt'          \
-        -link-opts '-lgdtoa -lm -lgmp'                           \
+        -target-link-opt openbsd '-L/usr/local/lib/'             \
+        -target-link-opt solaris '-lnsl -lsocket -lrt'           \
+        -link-opt '-lgdtoa -lm -lgmp'                            \
         -profile-exclude '<basis>'                               \
         "$@"

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2006-12-07 23:11:38 UTC (rev 4910)
+++ mlton/trunk/doc/changelog	2006-12-08 18:00:36 UTC (rev 4911)
@@ -1,5 +1,12 @@
 Here are the changes since version 20051202.
 
+* 2006-12-8
+   - Added command line switches -{,target}-{as,cc,link}-opt-quote, which
+     pass their argument as a single argument to gcc (i.e., without
+     tokenization at spaces).  These options support using headers and
+     libraries (including the MLton runtime headers and libraries) from a
+     path with spaces.  
+
 * 2006-12-02
    - Extensive reorganization of garbage collector, runtime system, and
      Basis Library implementation. (This is in preparation for future

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2006-12-07 23:11:38 UTC (rev 4910)
+++ mlton/trunk/mlton/main/main.fun	2006-12-08 18:00:36 UTC (rev 4911)
@@ -47,19 +47,20 @@
        | Yes 
    end
 
+val gcc: string ref = ref "<unset>"
 val asOpts: {opt: string, pred: OptPred.t} list ref = ref []
-val buildConstants: bool ref = ref false
 val ccOpts: {opt: string, pred: OptPred.t} list ref = ref []
+val linkOpts: {opt: string, pred: OptPred.t} list ref = ref []
+
+val buildConstants: bool ref = ref false
 val coalesce: int option ref = ref NONE
 val debugRuntime: bool ref = ref false
 val expert: bool ref = ref false
 val explicitAlign: Control.align option ref = ref NONE
 val explicitCodegen: Control.codegen option ref = ref NONE
-val gcc: string ref = ref "<unset>"
 val keepGenerated = ref false
 val keepO = ref false
 val keepSML = ref false
-val linkOpts: {opt: string, pred: OptPred.t} list ref = ref []
 val output: string option ref = ref NONE
 val profileSet: bool ref = ref false
 val profileTimeSet: bool ref = ref false
@@ -140,11 +141,12 @@
                usage (concat ["invalid -", flag, " flag: ", s])
       open Control Popt
       datatype z = datatype MLton.Platform.Arch.t
-      fun splitString f opts =
-        List.foreach (String.tokens (opts, Char.isSpace), f)
-      fun splitString2 f (target, opts) =
-        List.foreach (String.tokens (opts, Char.isSpace), 
-                      fn opt => f (target, opt))
+      fun tokenizeOpt f opts =
+         List.foreach (String.tokens (opts, Char.isSpace), 
+                       fn opt => f opt)
+      fun tokenizeTargetOpt f (target, opts) =
+         List.foreach (String.tokens (opts, Char.isSpace), 
+                       fn opt => f (target, opt))
    in
       List.map
       (
@@ -159,24 +161,22 @@
                                 | _ => usage (concat ["invalid -align flag: ",
                                                       s]))))),
        (Normal, "as-opt", " <opt>", "pass option to assembler",
-        SpaceString (fn s =>
-                     List.push (asOpts, {opt = s, pred = OptPred.Yes}))),
-       (Expert, "as-opts", " <opts>", "pass options to assembler",
+        (SpaceString o tokenizeOpt)
+        (fn s => List.push (asOpts, {opt = s, pred = OptPred.Yes}))),
+       (Expert, "as-opt-quote", " <opt>", "pass (quoted) option to assembler",
         SpaceString 
-         (splitString (fn s =>
-                       List.push (asOpts, {opt = s, pred = OptPred.Yes})))),
+        (fn s => List.push (asOpts, {opt = s, pred = OptPred.Yes}))),
        (Expert, "build-constants", " {false|true}",
         "output C file that prints basis constants",
         boolRef buildConstants),
        (Expert, "cc", " <gcc>", "path to gcc executable",
         SpaceString (fn s => gcc := s)),
        (Normal, "cc-opt", " <opt>", "pass option to C compiler",
-        SpaceString (fn s =>
-                     List.push (ccOpts, {opt = s, pred = OptPred.Yes}))),
-       (Expert, "cc-opts", " <opts>", "pass options to C compiler",
+        (SpaceString o tokenizeOpt)
+        (fn s => List.push (ccOpts, {opt = s, pred = OptPred.Yes}))),
+       (Expert, "cc-opt-quote", " <opt>", "pass (quoted) option to C compiler",
         SpaceString 
-         (splitString (fn s =>
-                       List.push (ccOpts, {opt = s, pred = OptPred.Yes})))),
+        (fn s => List.push (ccOpts, {opt = s, pred = OptPred.Yes}))),
        (Expert, "coalesce", " <n>", "coalesce chunk size for C codegen",
         Int (fn n => coalesce := SOME n)),
        (Normal, "codegen",
@@ -306,12 +306,11 @@
                                     end
                    | NONE => usage (concat ["invalid -keep-pass flag: ", s])))),
        (Normal, "link-opt", " <opt>", "pass option to linker",
-        SpaceString (fn s =>
-                     List.push (linkOpts, {opt = s, pred = OptPred.Yes}))),
-       (Expert, "link-opts", " <opts>", "pass options to linker",
+        (SpaceString o tokenizeOpt)
+        (fn s => List.push (linkOpts, {opt = s, pred = OptPred.Yes}))),
+       (Expert, "link-opt-quote", " <opt>", "pass (quoted) option to linker",
         SpaceString 
-         (splitString (fn s =>
-                       List.push (linkOpts, {opt = s, pred = OptPred.Yes})))),
+        (fn s => List.push (linkOpts, {opt = s, pred = OptPred.Yes}))),
        (Expert, "loop-passes", " <n>", "loop optimization passes (1)",
         Int 
         (fn i => 
@@ -501,32 +500,29 @@
          (target := (if t = "self" then Self else Cross t);
           setTargetType (t, usage)))),
        (Normal, "target-as-opt", " <target> <opt>", "target-dependent assembler option",
+        (SpaceString2 o tokenizeTargetOpt)
+        (fn (target, opt) =>
+         List.push (asOpts, {opt = opt, pred = OptPred.Target target}))),
+       (Expert, "target-as-opt-quote", " <target> <opt>", "target-dependent assembler option (quoted)",
         (SpaceString2
          (fn (target, opt) =>
           List.push (asOpts, {opt = opt, pred = OptPred.Target target})))),
-       (Expert, "target-as-opts", " <target> <opts>", "target-dependent assembler options",
-        (SpaceString2
-         (splitString2 
-          (fn (target, opt) =>
-           List.push (asOpts, {opt = opt, pred = OptPred.Target target}))))),
        (Normal, "target-cc-opt", " <target> <opt>", "target-dependent C compiler option",
+        (SpaceString2 o tokenizeTargetOpt)
+        (fn (target, opt) =>
+         List.push (ccOpts, {opt = opt, pred = OptPred.Target target}))),
+       (Expert, "target-cc-opt-quote", " <target> <opt>", "target-dependent C compiler option (quoted)",
         (SpaceString2
          (fn (target, opt) =>
           List.push (ccOpts, {opt = opt, pred = OptPred.Target target})))),
-       (Expert, "target-cc-opts", " <target> <opts>", "target-dependent C compiler options",
-        (SpaceString2
-         (splitString2
-          (fn (target, opt) =>
-           List.push (ccOpts, {opt = opt, pred = OptPred.Target target}))))),
        (Normal, "target-link-opt", " <target> <opt>", "target-dependent linker option",
+        (SpaceString2 o tokenizeTargetOpt)
+        (fn (target, opt) =>
+         List.push (linkOpts, {opt = opt, pred = OptPred.Target target}))),
+       (Expert, "target-link-opt-quote", " <target> <opt>", "target-dependent linker option (quoted)",
         (SpaceString2
          (fn (target, opt) =>
           List.push (linkOpts, {opt = opt, pred = OptPred.Target target})))),
-       (Expert, "target-link-opts", " <target> <opts>", "target-dependent linker options",
-        (SpaceString2
-         (splitString2
-          (fn (target, opt) =>
-           List.push (linkOpts, {opt = opt, pred = OptPred.Target target}))))),
        (Expert, #1 trace, " name1,...", "trace compiler internals", #2 trace),
        (Expert, "type-check", " {false|true}", "type check ILs",
         boolRef typeCheck),

Modified: mlton/trunk/package/mingw/mlton.bat
===================================================================
--- mlton/trunk/package/mingw/mlton.bat	2006-12-07 23:11:38 UTC (rev 4910)
+++ mlton/trunk/package/mingw/mlton.bat	2006-12-08 18:00:36 UTC (rev 4911)
@@ -32,7 +32,7 @@
 set linkopts=-lgdtoa -lm
 set linkopts=%linkopts% -lgmp -lws2_32 -lkernel32 -lpsapi -lnetapi32
 
-%mlton% @MLton load-world %world% ram-slop 0.5 -- %lib% -cc %cc% -cc-opt "-I%lib%\include" -cc-opts "%ccopts%" -mlb-path-map "%lib%\mlb-path-map" -link-opts "%linkopts%" %*
+%mlton% @MLton load-world %world% ram-slop 0.5 -- %lib% -cc %cc% -cc-opt-quote "-I%lib%\include" -cc-opt "%ccopts%" -mlb-path-map "%lib%\mlb-path-map" -link-opt "%linkopts%" %*
 goto :eof
 
 :setdir




More information about the MLton-commit mailing list