X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FDynFlags.hs;h=1b39d5ded408fb50463759bd05cd1dae1cbe67ec;hb=9bbcd77cf9b66940058dbea1827db594e8ff6d7f;hp=da226884cbe7dc70db0732cf9035972bee60b7ce;hpb=a896a832ab7306da8c638df7f44619b3548bd518;p=ghc-hetmet.git diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index da22688..1b39d5d 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1,3 +1,4 @@ + {-# OPTIONS -fno-warn-missing-fields #-} ----------------------------------------------------------------------------- -- @@ -16,7 +17,7 @@ module DynFlags ( -- Dynamic flags DynFlag(..), DynFlags(..), - HscTarget(..), + HscTarget(..), isObjectTarget, defaultObjectTarget, GhcMode(..), isOneShot, GhcLink(..), isNoLink, PackageFlag(..), @@ -84,10 +85,6 @@ import Util ( split ) import Data.Char ( isUpper ) import System.IO ( hPutStrLn, stderr ) -#ifdef GHCI -import Breakpoints ( BkptHandler ) -import Module ( ModuleName ) -#endif -- ----------------------------------------------------------------------------- -- DynFlags @@ -142,6 +139,7 @@ data DynFlag | Opt_WarnIsError -- -Werror; makes warnings fatal | Opt_WarnDuplicateExports | Opt_WarnHiShadows + | Opt_WarnImplicitPrelude | Opt_WarnIncompletePatterns | Opt_WarnIncompletePatternsRecUpd | Opt_WarnMissingFields @@ -151,6 +149,7 @@ data DynFlag | Opt_WarnOverlappingPatterns | Opt_WarnSimplePatterns | Opt_WarnTypeDefaults + | Opt_WarnMonomorphism | Opt_WarnUnusedBinds | Opt_WarnUnusedImports | Opt_WarnUnusedMatches @@ -176,7 +175,7 @@ data DynFlag | Opt_ImplicitPrelude | Opt_ScopedTypeVariables | Opt_BangPatterns - | Opt_IndexedTypes + | Opt_TypeFamilies | Opt_OverloadedStrings -- optimisation opts @@ -194,6 +193,7 @@ data DynFlag | Opt_CaseMerge | Opt_UnboxStrictFields | Opt_DictsCheap + | Opt_RewriteRules -- misc opts | Opt_Cpp @@ -207,12 +207,10 @@ data DynFlag | Opt_SplitObjs | Opt_StgStats | Opt_HideAllPackages -#if defined(GHCI) && defined(DEBUGGER) - | Opt_Debugging -#endif | Opt_PrintBindResult | Opt_Haddock | Opt_Hpc_No_Auto + | Opt_BreakOnException -- keeping stuff | Opt_KeepHiDiffs @@ -320,11 +318,6 @@ data DynFlags = DynFlags { -- message output log_action :: Severity -> SrcSpan -> PprStyle -> Message -> IO () - -#ifdef GHCI - -- breakpoint handling - ,bkptHandler :: Maybe (BkptHandler Module) -#endif } data HscTarget @@ -335,24 +328,35 @@ data HscTarget | HscNothing deriving (Eq, Show) +-- | will this target result in an object file on the disk? +isObjectTarget :: HscTarget -> Bool +isObjectTarget HscC = True +isObjectTarget HscAsm = True +isObjectTarget _ = False + +-- | The 'GhcMode' tells us whether we're doing multi-module +-- compilation (controlled via the "GHC" API) or one-shot +-- (single-module) compilation. This makes a difference primarily to +-- the "Finder": in one-shot mode we look for interface files for +-- imported modules, but in multi-module mode we look for source files +-- in order to check whether they need to be recompiled. data GhcMode - = BatchCompile -- | @ghc --make Main@ - | Interactive -- | @ghc --interactive@ - | OneShot -- | @ghc -c Foo.hs@ - | JustTypecheck -- | Development environemnts, refactorer, etc. - | MkDepend + = CompManager -- ^ --make, GHCi, etc. + | OneShot -- ^ ghc -c Foo.hs + | MkDepend -- ^ ghc -M, see Finder for why we need this deriving Eq isOneShot :: GhcMode -> Bool isOneShot OneShot = True isOneShot _other = False +-- | What kind of linking to do. data GhcLink -- What to do in the link step, if there is one - = -- Only relevant for modes - -- DoMake and StopBefore StopLn - NoLink -- Don't link at all - | StaticLink -- Ordinary linker [the default] + = NoLink -- Don't link at all + | LinkBinary -- Link object code into a binary + | LinkInMemory -- Use the in-memory dynamic linker | MkDLL -- Make a DLL + deriving Eq isNoLink :: GhcLink -> Bool isNoLink NoLink = True @@ -364,7 +368,11 @@ data PackageFlag | IgnorePackage String deriving Eq -defaultHscTarget +defaultHscTarget = defaultObjectTarget + +-- | the 'HscTarget' value corresponding to the default way to create +-- object files on the current platform. +defaultObjectTarget | cGhcWithNativeCodeGen == "YES" = HscAsm | otherwise = HscC @@ -381,8 +389,8 @@ initDynFlags dflags = do defaultDynFlags = DynFlags { - ghcMode = OneShot, - ghcLink = StaticLink, + ghcMode = CompManager, + ghcLink = LinkBinary, coreToDo = Nothing, stgToDo = Nothing, hscTarget = defaultHscTarget, @@ -434,9 +442,6 @@ defaultDynFlags = packageFlags = [], pkgDatabase = Nothing, pkgState = panic "no package state yet: call GHC.setSessionDynFlags", -#ifdef GHCI - bkptHandler = Nothing, -#endif flags = [ Opt_ReadUserPackageConf, @@ -562,12 +567,16 @@ optLevelFlags :: [([Int], DynFlag)] optLevelFlags = [ ([0], Opt_IgnoreInterfacePragmas) , ([0], Opt_OmitInterfacePragmas) + , ([1,2], Opt_IgnoreAsserts) + , ([1,2], Opt_RewriteRules) -- Off for -O0; see Note [Scoping for Builtin rules] + -- in PrelRules , ([1,2], Opt_DoEtaReduction) , ([1,2], Opt_CaseMerge) , ([1,2], Opt_Strictness) , ([1,2], Opt_CSE) , ([1,2], Opt_FullLaziness) + , ([2], Opt_LiberateCase) , ([2], Opt_SpecConstr) @@ -995,10 +1004,13 @@ dynamic_flags = [ ------ Compiler flags ----------------------------------------------- + , ( "fasm", AnySuffix (\_ -> setObjTarget HscAsm) ) + , ( "fvia-c", NoArg (setObjTarget HscC) ) + , ( "fvia-C", NoArg (setObjTarget HscC) ) + , ( "fno-code", NoArg (setTarget HscNothing)) - , ( "fasm", AnySuffix (\_ -> setTarget HscAsm) ) - , ( "fvia-c", NoArg (setTarget HscC) ) - , ( "fvia-C", NoArg (setTarget HscC) ) + , ( "fbyte-code", NoArg (setTarget HscInterpreted) ) + , ( "fobject-code", NoArg (setTarget defaultHscTarget) ) , ( "fglasgow-exts", NoArg (mapM_ setDynFlag glasgowExtsFlags) ) , ( "fno-glasgow-exts", NoArg (mapM_ unSetDynFlag glasgowExtsFlags) ) @@ -1014,6 +1026,7 @@ dynamic_flags = [ fFlags = [ ( "warn-duplicate-exports", Opt_WarnDuplicateExports ), ( "warn-hi-shadowing", Opt_WarnHiShadows ), + ( "warn-implicit-prelude", Opt_WarnImplicitPrelude ), ( "warn-incomplete-patterns", Opt_WarnIncompletePatterns ), ( "warn-incomplete-record-updates", Opt_WarnIncompletePatternsRecUpd ), ( "warn-missing-fields", Opt_WarnMissingFields ), @@ -1023,6 +1036,7 @@ fFlags = [ ( "warn-overlapping-patterns", Opt_WarnOverlappingPatterns ), ( "warn-simple-patterns", Opt_WarnSimplePatterns ), ( "warn-type-defaults", Opt_WarnTypeDefaults ), + ( "warn-monomorphism-restriction", Opt_WarnMonomorphism ), ( "warn-unused-binds", Opt_WarnUnusedBinds ), ( "warn-unused-imports", Opt_WarnUnusedImports ), ( "warn-unused-matches", Opt_WarnUnusedMatches ), @@ -1038,7 +1052,7 @@ fFlags = [ ( "scoped-type-variables", Opt_ScopedTypeVariables ), ( "bang-patterns", Opt_BangPatterns ), ( "overloaded-strings", Opt_OverloadedStrings ), - ( "indexed-types", Opt_IndexedTypes ), + ( "type-families", Opt_TypeFamilies ), ( "monomorphism-restriction", Opt_MonomorphismRestriction ), ( "mono-pat-binds", Opt_MonoPatBinds ), ( "extended-default-rules", Opt_ExtendedDefaultRules ), @@ -1064,11 +1078,10 @@ fFlags = [ ( "excess-precision", Opt_ExcessPrecision ), ( "asm-mangling", Opt_DoAsmMangling ), ( "print-bind-result", Opt_PrintBindResult ), -#if defined(GHCI) && defined(DEBUGGER) - ( "debugging", Opt_Debugging), -#endif ( "force-recomp", Opt_ForceRecomp ), - ( "hpc-no-auto", Opt_Hpc_No_Auto ) + ( "hpc-no-auto", Opt_Hpc_No_Auto ), + ( "rewrite-rules", Opt_RewriteRules ), + ( "break-on-exception", Opt_BreakOnException ) ] @@ -1077,7 +1090,7 @@ glasgowExtsFlags = [ Opt_FFI, Opt_ImplicitParams, Opt_ScopedTypeVariables, - Opt_IndexedTypes ] + Opt_TypeFamilies ] isFFlag f = f `elem` (map fst fFlags) getFFlag f = fromJust (lookup f fFlags) @@ -1133,12 +1146,23 @@ setPackageName p where pid = stringToPackageId p --- we can only switch between HscC, and HscAsmm with dynamic flags --- (-fvia-C, -fasm, -filx respectively). -setTarget l = upd (\dfs -> case hscTarget dfs of - HscC -> dfs{ hscTarget = l } - HscAsm -> dfs{ hscTarget = l } - _ -> dfs) +-- If we're linking a binary, then only targets that produce object +-- code are allowed (requests for other target types are ignored). +setTarget l = upd set + where + set dfs + | ghcLink dfs /= LinkBinary || isObjectTarget l = dfs{ hscTarget = l } + | otherwise = dfs + +-- Changes the target only if we're compiling object code. This is +-- used by -fasm and -fvia-C, which switch from one to the other, but +-- not from bytecode to object-code. The idea is that -fasm/-fvia-C +-- can be safely used in an OPTIONS_GHC pragma. +setObjTarget l = upd set + where + set dfs + | isObjectTarget (hscTarget dfs) = dfs { hscTarget = l } + | otherwise = dfs setOptLevel :: Int -> DynFlags -> DynFlags setOptLevel n dflags