[project @ 2004-10-07 15:54:03 by wolfgang]
[ghc-hetmet.git] / ghc / compiler / main / CmdLineOpts.lhs
index 6d8a2bf..6042f15 100644 (file)
@@ -93,7 +93,8 @@ module CmdLineOpts (
        opt_OmitBlackHoling,
        opt_Static,
        opt_Unregisterised,
-       opt_EmitExternalCore
+       opt_EmitExternalCore,
+       opt_PIC
     ) where
 
 #include "HsVersions.h"
@@ -104,6 +105,7 @@ import FastString   ( FastString, mkFastString )
 import Config
 import Maybes          ( firstJust )
 
+import Panic           ( ghcError, GhcException(UsageError) )
 import GLAEXTS
 import DATA_IOREF      ( IORef, readIORef, writeIORef )
 import UNSAFE_IO       ( unsafePerformIO )
@@ -209,7 +211,7 @@ data FloatOutSwitches
 data DynFlag
 
    -- debugging flags
-   = Opt_D_dump_absC
+   = Opt_D_dump_cmm
    | Opt_D_dump_asm
    | Opt_D_dump_cpranal
    | Opt_D_dump_deriv
@@ -219,7 +221,6 @@ data DynFlag
    | Opt_D_dump_inlinings
    | Opt_D_dump_occur_anal
    | Opt_D_dump_parsed
-   | Opt_D_dump_realC
    | Opt_D_dump_rn
    | Opt_D_dump_simpl
    | Opt_D_dump_simpl_iterations
@@ -234,7 +235,7 @@ data DynFlag
    | Opt_D_dump_worker_wrapper
    | Opt_D_dump_rn_trace
    | Opt_D_dump_rn_stats
-   | Opt_D_dump_stix
+   | Opt_D_dump_opt_cmm
    | Opt_D_dump_simpl_stats
    | Opt_D_dump_tc_trace
    | Opt_D_dump_if_trace
@@ -249,6 +250,7 @@ data DynFlag
    | Opt_D_dump_minimal_imports
    | Opt_DoCoreLinting
    | Opt_DoStgLinting
+   | Opt_DoCmmLinting
 
    | Opt_WarnIsError           -- -Werror; makes warnings fatal
    | Opt_WarnDuplicateExports
@@ -265,7 +267,7 @@ data DynFlag
    | Opt_WarnUnusedImports
    | Opt_WarnUnusedMatches
    | Opt_WarnDeprecations
-   | Opt_WarnMisc
+   | Opt_WarnDodgyImports
 
    -- language opts
    | Opt_AllowOverlappingInstances
@@ -674,7 +676,7 @@ minusWOpts
        Opt_WarnUnusedMatches,
        Opt_WarnUnusedImports,
        Opt_WarnIncompletePatterns,
-       Opt_WarnMisc
+       Opt_WarnDodgyImports
       ]
 
 minusWallOpts
@@ -708,19 +710,36 @@ packed_static_opts   = map mkFastString unpacked_static_opts
 
 lookUp     sw = sw `elem` packed_static_opts
        
-lookup_str sw = firstJust (map (startsWith sw) unpacked_static_opts)
+-- (lookup_str "foo") looks for the flag -foo=X or -fooX, 
+-- and returns the string X
+lookup_str sw 
+   = case firstJust (map (startsWith sw) unpacked_static_opts) of
+       Just ('=' : str) -> Just str
+       Just str         -> Just str
+       Nothing          -> Nothing     
 
 lookup_int sw = case (lookup_str sw) of
                  Nothing -> Nothing
-                 Just xx -> Just (read xx)
+                 Just xx -> Just (try_read sw xx)
 
 lookup_def_int sw def = case (lookup_str sw) of
                            Nothing -> def              -- Use default
-                           Just xx -> read xx
+                           Just xx -> try_read sw xx
 
 lookup_def_float sw def = case (lookup_str sw) of
                            Nothing -> def              -- Use default
-                           Just xx -> read xx
+                           Just xx -> try_read sw xx
+
+
+try_read :: Read a => String -> String -> a
+-- (try_read sw str) tries to read s; if it fails, it
+-- bleats about flag sw
+try_read sw str
+  = case reads str of
+       ((x,_):_) -> x  -- Be forgiving: ignore trailing goop, and alternative parses
+       []        -> ghcError (UsageError ("Malformed argument " ++ str ++ " for flag " ++ sw))
+                       -- ToDo: hack alert. We should really parse the arugments
+                       --       and announce errors in a more civilised way.
 
 
 {-
@@ -814,6 +833,8 @@ opt_EmitExternalCore                = lookUp  FSLIT("-fext-core")
 
 -- Include full span info in error messages, instead of just the start position.
 opt_ErrorSpans                 = lookUp FSLIT("-ferror-spans")
+
+opt_PIC                         = lookUp FSLIT("-fPIC")
 \end{code}
 
 %************************************************************************
@@ -845,18 +866,19 @@ isStaticHscFlag f =
        "fno-hi-version-check",
        "dno-black-holing",
        "fno-method-sharing",
+       "fno-state-hack",
        "fruntime-types",
        "fno-pre-inlining",
        "fexcess-precision",
        "funfolding-update-in-place",
-       "fno-prune-decls",
        "static",
        "funregisterised",
        "fext-core",
        "frule-check",
        "frules-off",
        "fcpr-off",
-       "ferror-spans"
+       "ferror-spans",
+       "fPIC"
        ]
   || any (flip prefixMatch f) [
        "fcontext-stack",