[MLton-devel] cvs commit: Added -cc and -ccopt

Stephen Weeks sweeks@users.sourceforge.net
Tue, 05 Nov 2002 12:27:11 -0800


sweeks      02/11/05 12:27:10

  Modified:    bin      mlton
               mlton/control control.sml
               mlton/main main.sml
  Log:
  Added the -cc and -ccopt switches, with the semantics pretty much as
  was requested.  -cc sets the C compiler and -ccopt adds a switch to
  the list of switches passed to gcc (-ccopt is only relevant when
  compiling -native false).  The only minor weirdness that I put in is
  that -cc doesn't reset the switch list if you just pass in the C
  compiler without any switches.  So, "-cc gcc" will cause gcc to be
  invoked with all the usual switches from bin/mlton.  But "-cc 'gcc
  -DFOO'" will cause only the switch -DFOO to be passed, unless you also
  use -ccopt.

Revision  Changes    Path
1.16      +11 -4     mlton/bin/mlton

Index: mlton
===================================================================
RCS file: /cvsroot/mlton/mlton/bin/mlton,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- mlton	5 Nov 2002 01:38:04 -0000	1.15
+++ mlton	5 Nov 2002 20:27:06 -0000	1.16
@@ -39,7 +39,14 @@
 # can find the gmp.
 
 doit "$lib" \
-	"$gcc" -w -fomit-frame-pointer -fno-strength-reduce \
-	-mcpu=pentiumpro -malign-loops=2 -falign-jumps=2 -falign-functions=5 \
-	-fschedule-insns -fschedule-insns2 END \
-	-lm "$@"
+	-cc "$gcc -w 
+		-falign-functions=5
+		-falign-jumps=2 
+		-fno-strength-reduce
+		-fomit-frame-pointer
+		-fschedule-insns 
+		-fschedule-insns2
+		-malign-loops=2
+		-mcpu=pentiumpro" \
+	-lm \
+	"$@"



1.69      +1 -1      mlton/mlton/control/control.sml

Index: control.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sml,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- control.sml	2 Nov 2002 03:37:40 -0000	1.68
+++ control.sml	5 Nov 2002 20:27:07 -0000	1.69
@@ -193,7 +193,7 @@
 				      Regexp.Compiled.layout)}
 
 val libDir = control {name = "lib dir",
-		      default = "<none>",
+		      default = "<libDir unset>",
 		      toString = fn s => s}
    
 structure LimitCheck =



1.90      +21 -28    mlton/mlton/main/main.sml

Index: main.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/main.sml,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- main.sml	3 Nov 2002 00:28:13 -0000	1.89
+++ main.sml	5 Nov 2002 20:27:08 -0000	1.90
@@ -37,6 +37,8 @@
 
 val buildConstants: bool ref = ref false
 val coalesce: int option ref = ref NONE
+val gcc: string ref = ref "gcc"
+val gccSwitches : string list ref = ref []
 val includeDirs: string list ref = ref []
 val keepGenerated = ref false
 val keepO = ref false
@@ -48,17 +50,11 @@
 val showBasis: bool ref = ref false
 val stop = ref Place.OUT
 
-val libRef: Dir.t option ref = ref NONE
-fun getLib (): Dir.t =
-   case !libRef of
-      NONE => Error.bug "lib not set"
-    | SOME l => l
-
 val hostMap: unit -> {host: string, hostType: Control.hostType} list =
    Promise.lazy
    (fn () =>
     List.map
-    (File.lines (concat [getLib (), "/hostmap"]), fn line =>
+    (File.lines (concat [!Control.libDir, "/hostmap"]), fn line =>
      case String.tokens (line, Char.isSpace) of
 	[host, hostType] =>
 	   {host = host,
@@ -84,8 +80,18 @@
        (Expert, "card-size-log2", " n",
 	"log (base 2) of card size used by GC",
 	intRef cardSizeLog2),
+       (Expert, "cc", " gcc", "gcc command line",
+	SpaceString (fn s =>
+		     case String.tokens (s, Char.isSpace) of
+			x :: xs => (gcc := x
+				    ; (case xs of
+					  [] => ()
+					| _ => gccSwitches := xs))
+		      | _ => usage "-cc must specify gcc")),
        (Expert, "coalesce", " n", "coalesce chunk size for C codegen",
 	Int (fn n => coalesce := SOME n)),
+       (Expert, "ccopt", " opt", "pass option to C compiler",
+	SpaceString (fn s => List.push (gccSwitches, s))),
        (Expert, "debug", " {false|true}", "produce executable with debug info",
 	boolRef debug),
        (Normal, "detect-overflow", " {true|false}",
@@ -157,6 +163,8 @@
 				    end
 		   | NONE => usage (concat ["invalid -keep-pass flag: ", s])))),
        (Normal, "l", "library", "link with library", push libs),
+       (Expert, "lib", " lib", "set MLton lib directory",
+	SpaceString (fn s => libDir := s)),
        (Expert, "limit-check", " {lhle|pb|ebb|lh|lhf|lhfle}",
 	"limit check insertion algorithm",
 	SpaceString (fn s =>
@@ -217,8 +225,6 @@
 	Bool (fn b => if b then () else polyvariance := NONE)),
        (Normal, "o", " file", "name of output file",
 	SpaceString (fn s => output := SOME s)),
-       (Expert, "O", "digit", "gcc optimization level",
-	Digit (fn d => optimization := d)),
        (Normal, "profile", " {no|alloc|time}",
 	"produce executable suitable for profiling",
 	SpaceString
@@ -294,31 +300,18 @@
 fun commandLine (args: string list): unit =
    let
       open Control
-      fun error () = Error.bug "incorrect args from shell script"
-      val (lib, gcc, gccSwitches, args) =
+      val args =
 	 case args of
-	    lib :: gcc :: args =>
-	       let
-		  fun loop (args, ac) =
-		     case args of
-			[] => error ()
-		      | arg :: args =>
-			   if arg = "END"
-			      then (rev ac, args)
-			   else loop (args, arg :: ac)
-		  val (gccSwitches, args) = loop (args, [])
-	       in
-		  (lib, gcc, gccSwitches, args)
-	       end
-	  | _ => error ()
-      val _ = libRef := SOME lib
+	    lib :: args => (libDir := lib; args)
+	  | _ => Error.bug "incorrect args from shell script"
       val result = parse args
+      val gcc = !gcc
       val host = !host
       val hostString =
 	 case host of
 	    Cross s => s
 	  | Self => "self"
-      val lib = concat [lib, "/", hostString]
+      val lib = concat [!libDir, "/", hostString]
       val _ = Control.libDir := lib
       val libDirs = lib :: !libDirs
       val includeDirs = concat [lib, "/include"] :: !includeDirs
@@ -570,7 +563,7 @@
 			    [concat ["-O", Int.toString (!optimization)]],
 			    if !Native.native
 			       then []
-			    else gccSwitches]
+			    else !gccSwitches]
 			val switches =
 			   case host of
 			      Cross s => "-b" :: s :: switches





-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel