[MLton-commit] r4610

Wesley Terpstra MLton@mlton.org
Fri, 26 May 2006 10:29:16 -0700


Support using MLton in a path with spaces. Changed -cc-opt to not separate on spaces, -cc-opts will do this still. Ditto for the rest of these options.
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/bin/mlton-script
U   mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
U   mlton/branches/on-20050822-x86_64-branch/package/mingw/mlton.bat

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

Modified: mlton/branches/on-20050822-x86_64-branch/bin/mlton-script
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bin/mlton-script	2006-05-26 03:54:30 UTC (rev 4609)
+++ mlton/branches/on-20050822-x86_64-branch/bin/mlton-script	2006-05-26 17:29:11 UTC (rev 4610)
@@ -72,43 +72,39 @@
 fi
 
 doit "$lib" \
-        -cc "$gcc"                                              \
-        -cc-opt "-I$lib/include"                                \
-        -cc-opt '-O1'                                           \
-        -cc-opt '-fno-strict-aliasing -fomit-frame-pointer -w'  \
-	-mlb-path-map "$lib/mlb-path-map"			\
-        -target-as-opt amd64                                    \
-                '-m32
-                -mtune=opteron'                                 \
-        -target-cc-opt amd64                                    \
-                '-m32
-                -mtune=opteron'                                 \
-        -target-cc-opt darwin '-I/sw/include'                   \
-	-target-cc-opt freebsd '-I/usr/local/include'		\
-        -target-cc-opt solaris                                  \
+        -cc "$gcc"                                               \
+        -cc-opt "-I$lib/include"                                 \
+        -cc-opt '-O1'                                            \
+        -cc-opts '-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 '-I/sw/include'                   \
+        -target-cc-opts freebsd '-I/usr/local/include'           \
+        -target-cc-opts solaris                                  \
                 '-Wa,-xarch=v8plusa
-                -mcpu=ultrasparc'                               \
-        -target-cc-opt sparc '-mcpu=v8 -m32'                    \
-        -target-cc-opt x86                                      \
+                -mcpu=ultrasparc'                                \
+        -target-cc-opts sparc '-mcpu=v8 -m32'                    \
+        -target-cc-opts x86                                      \
                 '-fno-strength-reduce
                 -fschedule-insns
                 -fschedule-insns2
                 -malign-functions=5
                 -malign-jumps=2
-                -malign-loops=2'                                \
-        -target-link-opt aix '-lgmp'                            \
-        -target-link-opt amd64 '-m32'                           \
-        -target-link-opt cygwin '-lgmp'                         \
-        -target-link-opt darwin "$darwinLinkOpts -lgmp"         \
-        -target-link-opt freebsd '-L/usr/local/lib/ -lgmp'      \
-        -target-link-opt hpux '-lgmp'                           \
-        -target-link-opt linux '-lgmp'                          \
-        -target-link-opt mingw                                  \
-                '-lgmp -lws2_32 -lkernel32 -lpsapi -lnetapi32'  \
-        -target-link-opt netbsd                                 \
-                '-Wl,-R/usr/pkg/lib -L/usr/local/lib/ -lgmp'    \
-        -target-link-opt openbsd '-L/usr/local/lib/ -lgmp'      \
-        -target-link-opt solaris '-lgmp -lnsl -lsocket -lrt'    \
-        -link-opt '-lgdtoa -lm'                                 \
-        -profile-exclude '<basis>'                              \
+                -malign-loops=2'                                 \
+        -target-link-opts aix '-lgmp'                            \
+        -target-link-opts amd64 '-m32'                           \
+        -target-link-opts cygwin '-lgmp'                         \
+        -target-link-opts darwin "$darwinLinkOpts -lgmp"         \
+        -target-link-opts freebsd '-L/usr/local/lib/ -lgmp'      \
+        -target-link-opts hpux '-lgmp'                           \
+        -target-link-opts linux '-lgmp'                          \
+        -target-link-opts mingw                                  \
+                '-lgmp -lws2_32 -lkernel32 -lpsapi -lnetapi32'   \
+        -target-link-opts netbsd                                 \
+                '-Wl,-R/usr/pkg/lib -L/usr/local/lib/ -lgmp'     \
+        -target-link-opts openbsd '-L/usr/local/lib/ -lgmp'      \
+        -target-link-opts solaris '-lgmp -lnsl -lsocket -lrt'    \
+        -link-opts '-lgdtoa -lm'                                 \
+        -profile-exclude '<basis>'                               \
         "$@"

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun	2006-05-26 03:54:30 UTC (rev 4609)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun	2006-05-26 17:29:11 UTC (rev 4610)
@@ -129,8 +129,12 @@
           | Control.Elaborate.Other =>
                usage (concat ["invalid -", flag, " flag: ", s])
       open Control Popt
-      fun push r = SpaceString (fn s => List.push (r, s))
       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))
    in
       List.map
       (
@@ -150,6 +154,10 @@
        (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 
+         (splitString (fn s =>
+                       List.push (asOpts, {opt = s, pred = OptPred.Yes})))),
        (Expert, "build-constants", " {false|true}",
         "output C file that prints basis constants",
         boolRef buildConstants),
@@ -158,6 +166,10 @@
        (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 
+         (splitString (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",
@@ -289,6 +301,10 @@
        (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 
+         (splitString (fn s =>
+                       List.push (linkOpts, {opt = s, pred = OptPred.Yes})))),
        (Expert, "loop-passes", " <n>", "loop optimization passes (1)",
         Int 
         (fn i => 
@@ -428,7 +444,7 @@
        (Normal, "profile-stack", " {false|true}", "profile the stack",
         boolRef profileStack),
        (Normal, "runtime", " <arg>", "pass arg to runtime via @MLton",
-        push runtimeArgs),
+        SpaceString (fn s => List.push (runtimeArgs, s))),
        (Expert, "show-anns", " {false|true}", "show annotations",
         boolRef showAnns),
        (Normal, "show-basis", " <file>", "write out the final basis environment",
@@ -481,14 +497,29 @@
         (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
          (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
          (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),
@@ -592,19 +623,18 @@
       fun tokenize l =
          String.tokens (concat (List.separate (l, " ")), Char.isSpace)
       fun addTargetOpts opts =
-         tokenize
-         (List.fold
-          (!opts, [], fn ({opt, pred}, ac) =>
-           if (case pred of
-                  OptPred.Target s =>
-                     let
-                        val s = String.toLower s
-                     in
-                        s = archStr orelse s = OSStr
-                     end
-                | OptPred.Yes => true)
-              then opt :: ac
-           else ac))
+         List.fold
+         (!opts, [], fn ({opt, pred}, ac) =>
+          if (case pred of
+                 OptPred.Target s =>
+                    let
+                       val s = String.toLower s
+                    in
+                       s = archStr orelse s = OSStr
+                    end
+               | OptPred.Yes => true)
+             then opt :: ac
+          else ac)
       val asOpts = addTargetOpts asOpts
       val ccOpts = addTargetOpts ccOpts
       val linkOpts =
@@ -788,13 +818,13 @@
                               trace (Top, "Link")
                               (fn () =>
                                System.system
-                               (gcc,
-                                List.concat
-                                [targetOpts, 
-                                 ["-o", output],
-                                 if !debug then gccDebug else [],
-                                 inputs,
-                                 linkOpts]))
+                                (gcc,
+                                 List.concat
+                                  [targetOpts,
+                                   ["-o", output],
+                                   if !debug then gccDebug else [],
+                                   inputs,
+                                   linkOpts]))
                               ()
                            (* gcc on Cygwin appends .exe, which I don't want, so
                             * move the output file to it's rightful place.
@@ -833,39 +863,34 @@
                         else temp ".o"
                   fun compileC (c: Counter.t, input: File.t): File.t =
                      let
-                        val (debugSwitches, switches) =
-                           (gccDebug @ ["-DASSERT=1"], ccOpts)
-                        val switches =
-                           if !debug
-                              then debugSwitches @ switches
-                              else switches
-                        val switches =
-                           targetOpts @ ("-std=gnu99" :: "-c" :: switches)
+                        val debugSwitches = gccDebug @ ["-DASSERT=1"]
                         val output = mkOutputO (c, input)
                         val _ =
                            System.system
-                           (gcc,
-                            List.concat [switches,
-                                         ["-o", output, input]])
+                            (gcc, 
+                             List.concat
+                             [targetOpts,
+                              [ "-std=gnu99", "-c" ],
+                              if !debug then debugSwitches else [],
+                              ccOpts,
+                              ["-o", output], 
+                              [input]])
                      in
                         output
                      end
                   fun compileS (c: Counter.t, input: File.t): File.t =
                      let
-                        val (debugSwitches, switches) =
-                           ([asDebug], asOpts)
-                        val switches =
-                           if !debug
-                              then debugSwitches @ switches
-                              else switches
-                        val switches =
-                           targetOpts @ ("-c" :: switches)
                         val output = mkOutputO (c, input)
                         val _ =
                            System.system
                            (gcc,
-                            List.concat [switches,
-                                         ["-o", output, input]])
+                            List.concat 
+                            [targetOpts,
+                             ["-c"],
+                             if !debug then [asDebug] else [],
+                             asOpts,
+                             ["-o", output], 
+                             [input]])
                      in
                         output
                      end

Modified: mlton/branches/on-20050822-x86_64-branch/package/mingw/mlton.bat
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/package/mingw/mlton.bat	2006-05-26 03:54:30 UTC (rev 4609)
+++ mlton/branches/on-20050822-x86_64-branch/package/mingw/mlton.bat	2006-05-26 17:29:11 UTC (rev 4610)
@@ -26,13 +26,13 @@
 set world=%lib%\world.mlton
 set mlton=%lib%\mlton-compile.exe
 
-set ccopts=-I%lib%\include -O1 -fno-strict-aliasing -fomit-frame-pointer -w
+set ccopts=-O1 -fno-strict-aliasing -fomit-frame-pointer -w
 set ccopts=%ccopts% -fno-strength-reduce -fschedule-insns -fschedule-insns2
 set ccopts=%ccopts% -malign-functions=5 -malign-jumps=2 -malign-loops=2
 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 "%ccopts%" -mlb-path-map %lib%\mlb-path-map -link-opt "%linkopts%" %*
+%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%" %*
 goto :eof
 
 :setdir