diff options
Diffstat (limited to 'compiler/main/StaticFlags.hs')
-rw-r--r-- | compiler/main/StaticFlags.hs | 97 |
1 files changed, 35 insertions, 62 deletions
diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs index c982d14b33..09d5772637 100644 --- a/compiler/main/StaticFlags.hs +++ b/compiler/main/StaticFlags.hs @@ -1,10 +1,3 @@ -{-# OPTIONS -fno-warn-tabs #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and --- detab the module (please do the detabbing in a separate patch). See --- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces --- for details - {-# OPTIONS -fno-cse #-} -- -fno-cse is needed for GLOBAL_VAR's to behave properly @@ -23,27 +16,29 @@ module StaticFlags ( -- entry point parseStaticFlags, - staticFlags, + staticFlags, initStaticOpts, - -- Output style options - opt_PprStyle_Debug, + -- Output style options + opt_PprStyle_Debug, opt_NoDebugOutput, - -- language opts - opt_DictsStrict, + -- language opts + opt_DictsStrict, - -- optimisation opts - opt_NoStateHack, - opt_CprOff, - opt_NoOptCoercion, - opt_NoFlatCache, + -- optimisation opts + opt_NoStateHack, + opt_CprOff, + opt_NoOptCoercion, -- For the parser addOpt, removeOpt, v_opt_C_ready, -- Saving/restoring globals - saveStaticFlagGlobals, restoreStaticFlagGlobals + saveStaticFlagGlobals, restoreStaticFlagGlobals, + + -- For options autocompletion + flagsStatic, flagsStaticNames ) where #include "HsVersions.h" @@ -52,13 +47,13 @@ import CmdLineParser import FastString import SrcLoc import Util --- import Maybes ( firstJusts ) +-- import Maybes ( firstJusts ) import Panic import Control.Monad import Data.Char import Data.IORef -import System.IO.Unsafe ( unsafePerformIO ) +import System.IO.Unsafe ( unsafePerformIO ) ----------------------------------------------------------------------------- @@ -114,7 +109,7 @@ staticFlags = unsafePerformIO $ do -- All the static flags should appear in this list. It describes how each -- static flag should be processed. Two main purposes: -- (a) if a command-line flag doesn't appear in the list, GHC can complain --- (b) a command-line flag may remove, or add, other flags; e.g. the "-fno-X" +-- (b) a command-line flag may remove, or add, other flags; e.g. the "-fno-X" -- things -- -- The common (PassFlag addOpt) action puts the static flag into the bunch of @@ -147,18 +142,16 @@ flagsStatic = [ ] + isStaticFlag :: String -> Bool -isStaticFlag f = - f `elem` [ +isStaticFlag f = f `elem` flagsStaticNames + + +flagsStaticNames :: [String] +flagsStaticNames = [ "fdicts-strict", - "fspec-inline-join-points", - "fno-hi-version-check", - "dno-black-holing", "fno-state-hack", - "fruntime-types", "fno-opt-coercion", - "fno-flat-cache", - "fhardwire-lib-paths", "fcpr-off" ] @@ -198,10 +191,10 @@ opt_NoDebugOutput = lookUp (fsLit "-dno-debug-output") -- language opts opt_DictsStrict :: Bool -opt_DictsStrict = lookUp (fsLit "-fdicts-strict") +opt_DictsStrict = lookUp (fsLit "-fdicts-strict") opt_NoStateHack :: Bool -opt_NoStateHack = lookUp (fsLit "-fno-state-hack") +opt_NoStateHack = lookUp (fsLit "-fno-state-hack") -- Switch off CPR analysis in the new demand analyser opt_CprOff :: Bool @@ -210,9 +203,6 @@ opt_CprOff = lookUp (fsLit "-fcpr-off") opt_NoOptCoercion :: Bool opt_NoOptCoercion = lookUp (fsLit "-fno-opt-coercion") -opt_NoFlatCache :: Bool -opt_NoFlatCache = lookUp (fsLit "-fno-flat-cache") - ----------------------------------------------------------------------------- -- Convert sizes like "3.5M" into integers @@ -254,45 +244,28 @@ foreign import ccall unsafe "enableTimingStats" enableTimingStats :: IO () lookup_str :: String -> Maybe String lookup_str sw = case firstJusts (map (stripPrefix sw) staticFlags) of - Just ('=' : str) -> Just str - Just str -> Just str - Nothing -> Nothing + Just ('=' : str) -> Just str + Just str -> Just str + Nothing -> Nothing lookup_def_int :: String -> Int -> Int lookup_def_int sw def = case (lookup_str sw) of - Nothing -> def -- Use default - Just xx -> try_read sw xx + Nothing -> def -- Use default + Just xx -> try_read sw xx lookup_def_float :: String -> Float -> Float lookup_def_float sw def = case (lookup_str sw) of - Nothing -> def -- Use default - Just xx -> try_read sw xx + Nothing -> def -- Use default + 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 - [] -> throwGhcException (UsageError ("Malformed argument " ++ str ++ " for flag " ++ sw)) - -- ToDo: hack alert. We should really parse the arguments - -- and announce errors in a more civilised way. --} - - -{- - Putting the compiler options into temporary at-files - may turn out to be necessary later on if we turn hsc into - a pure Win32 application where I think there's a command-line - length limit of 255. unpacked_opts understands the @ option. - -unpacked_opts :: [String] -unpacked_opts = - concat $ - map (expandAts) $ - map unpackFS argv -- NOT ARGV any more: v_Static_hsc_opts - where - expandAts ('@':fname) = words (unsafePerformIO (readFile fname)) - expandAts l = [l] + ((x,_):_) -> x -- Be forgiving: ignore trailing goop, and alternative parses + [] -> throwGhcException (UsageError ("Malformed argument " ++ str ++ " for flag " ++ sw)) + -- ToDo: hack alert. We should really parse the arguments + -- and announce errors in a more civilised way. -} |