[project @ 2002-10-11 16:45:16 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / DriverFlags.hs
index 8a6f1a5..cf039d9 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.93 2002/05/11 10:02:22 panne Exp $
+-- $Id: DriverFlags.hs,v 1.103 2002/10/11 16:45:17 simonpj Exp $
 --
 -- Driver flags
 --
@@ -27,10 +27,10 @@ import Config
 import Util
 import Panic
 
-import Exception
-import IOExts
-import System          ( exitWith, ExitCode(..) )
+import EXCEPTION
+import DATA_IOREF      ( readIORef, writeIORef )
 
+import System          ( exitWith, ExitCode(..) )
 import IO
 import Maybe
 import Monad
@@ -263,6 +263,12 @@ static_flags =
   ,  ( "L"             , Prefix (addToDirList v_Library_paths) )
   ,  ( "l"             , Prefix (add v_Cmdline_libraries) )
 
+#ifdef darwin_TARGET_OS
+       ------- Frameworks --------------------------------------------------
+        -- -framework-path should really be -F ...
+  ,  ( "framework-path" , HasArg (addToDirList v_Framework_paths) )
+  ,  ( "framework"     , HasArg (add v_Cmdline_frameworks) )
+#endif
         ------- Packages ----------------------------------------------------
   ,  ( "package-name"   , HasArg (\s -> add v_Opt_C ("-inpackage="++s)) )
 
@@ -356,7 +362,7 @@ dynamic_flags = [
        -- on all other systems, quoting is necessary, to avoid interpretation
        -- of shell metacharacters in the arguments (e.g. green-card's
        -- -DBEGIN_GHC_ONLY='}-' trick).
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
   ,  ( "D",            Prefix (\s -> addOpt_P ("-D'"++s++"'") ) )
   ,  ( "U",            Prefix (\s -> addOpt_P ("-U'"++s++"'") ) )
 #else
@@ -394,6 +400,7 @@ dynamic_flags = [
   ,  ( "dshow-passes",           NoArg (setVerbosity "2") )
   ,  ( "ddump-rn-trace",         NoArg (setDynFlag Opt_D_dump_rn_trace) )
   ,  ( "ddump-tc-trace",         NoArg (setDynFlag Opt_D_dump_tc_trace) )
+  ,  ( "ddump-splices",          NoArg (setDynFlag Opt_D_dump_splices) )
   ,  ( "ddump-rn-stats",         NoArg (setDynFlag Opt_D_dump_rn_stats) )
   ,  ( "ddump-stix",             NoArg (setDynFlag Opt_D_dump_stix) )
   ,  ( "ddump-simpl-stats",      NoArg (setDynFlag Opt_D_dump_simpl_stats) )
@@ -427,7 +434,6 @@ dynamic_flags = [
   ,  ( "fvia-c",       NoArg (setLang HscC) )
   ,  ( "fvia-C",       NoArg (setLang HscC) )
   ,  ( "filx",         NoArg (setLang HscILX) )
-  ,  ( "fcore",                NoArg (setLang HscCore) )
 
        -- "active negatives"
   ,  ( "fno-implicit-prelude",  NoArg (setDynFlag Opt_NoImplicitPrelude) )
@@ -457,6 +463,9 @@ fFlags = [
   ( "warn-unused-matches",             Opt_WarnUnusedMatches ),
   ( "warn-deprecations",               Opt_WarnDeprecations ),
   ( "glasgow-exts",                    Opt_GlasgowExts ),
+  ( "fi",                              Opt_FFI ),  -- support `-ffi'...
+  ( "ffi",                             Opt_FFI ),  -- ...and also `-fffi'
+  ( "with",                            Opt_With ), -- with keyword
   ( "parr",                            Opt_PArr ),
   ( "allow-overlapping-instances",     Opt_AllowOverlappingInstances ),
   ( "allow-undecidable-instances",     Opt_AllowUndecidableInstances ),
@@ -485,8 +494,13 @@ decodeSize str
 -----------------------------------------------------------------------------
 -- RTS Hooks
 
+#if __GLASGOW_HASKELL__ >= 504
+foreign import ccall unsafe "setHeapSize"       setHeapSize       :: Int -> IO ()
+foreign import ccall unsafe "enableTimingStats" enableTimingStats :: IO ()
+#else
 foreign import "setHeapSize"       unsafe setHeapSize       :: Int -> IO ()
 foreign import "enableTimingStats" unsafe enableTimingStats :: IO ()
+#endif
 
 -----------------------------------------------------------------------------
 -- Build the Hsc static command line opts
@@ -527,7 +541,11 @@ buildStaticHscOpts = do
 
 machdepCCOpts 
    | prefixMatch "alpha"   cTARGETPLATFORM  
-       = return ( ["-static", "-w", "-mieee"], [] )
+       = return ( ["-static", "-w", "-mieee"
+#ifdef HAVE_THREADED_RTS_SUPPORT
+                   , "-D_REENTRANT"
+#endif
+                  ], [] )
        -- For now, to suppress the gcc warning "call-clobbered
        -- register used for global register variable", we simply
        -- disable all warnings altogether using the -w flag. Oh well.
@@ -556,12 +574,20 @@ machdepCCOpts
       --   the fp (%ebp) for our register maps.
        = do n_regs <- dynFlag stolen_x86_regs
             sta    <- readIORef v_Static
-            return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "",
-                        if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" ],
+            return ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else ""
+--                    , if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" 
+                     ],
                      [ "-fno-defer-pop", "-fomit-frame-pointer",
+                       -- we want -fno-builtin, because when gcc inlines
+                       -- built-in functions like memcpy() it tends to
+                       -- run out of registers, requiring -monly-n-regs
+                       "-fno-builtin",
                        "-DSTOLEN_X86_REGS="++show n_regs ]
                    )
 
+   | prefixMatch "ia64"    cTARGETPLATFORM  
+       = return ( [], ["-fomit-frame-pointer", "-G0"] )
+
    | prefixMatch "mips"    cTARGETPLATFORM
        = return ( ["-static"], [] )