2 {-# OPTIONS -fno-warn-missing-fields #-}
3 -----------------------------------------------------------------------------
7 -- Most flags are dynamic flags, which means they can change from
8 -- compilation to compilation using OPTIONS_GHC pragmas, and in a
9 -- multi-session GHC each session can be using different dynamic
10 -- flags. Dynamic flags can also be set at the prompt in GHCi.
12 -- (c) The University of Glasgow 2005
14 -----------------------------------------------------------------------------
20 HscTarget(..), isObjectTarget,
21 GhcMode(..), isOneShot,
22 GhcLink(..), isNoLink,
26 -- Configuration of the core-to-core and stg-to-stg phases
30 SimplifierMode(..), FloatOutSwitches(..),
31 getCoreToDo, getStgToDo,
33 -- Manipulating DynFlags
34 defaultDynFlags, -- DynFlags
35 initDynFlags, -- DynFlags -> IO DynFlags
37 dopt, -- DynFlag -> DynFlags -> Bool
38 dopt_set, dopt_unset, -- DynFlags -> DynFlag -> DynFlags
39 getOpts, -- (DynFlags -> [a]) -> IO [a]
50 machdepCCOpts, picCCOpts
53 #include "HsVersions.h"
55 import Module ( Module, mkModuleName, mkModule )
57 import PrelNames ( mAIN )
58 #ifdef i386_TARGET_ARCH
59 import StaticFlags ( opt_Static )
61 import StaticFlags ( opt_PIC, WayName(..), v_Ways, v_Build_tag,
63 import {-# SOURCE #-} Packages (PackageState)
64 import DriverPhases ( Phase(..), phaseInputExt )
67 import Constants ( mAX_CONTEXT_REDUCTION_DEPTH )
68 import Panic ( panic, GhcException(..) )
69 import UniqFM ( UniqFM )
70 import Util ( notNull, splitLongestPrefix, normalisePath )
71 import Maybes ( fromJust, orElse )
72 import SrcLoc ( SrcSpan )
74 import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
76 import Data.IORef ( readIORef )
77 import Control.Exception ( throwDyn )
78 import Control.Monad ( when )
79 #ifdef mingw32_TARGET_OS
80 import Data.List ( isPrefixOf )
85 import Data.Char ( isUpper )
86 import System.IO ( hPutStrLn, stderr )
88 -- -----------------------------------------------------------------------------
101 | Opt_D_dump_inlinings
102 | Opt_D_dump_rule_firings
103 | Opt_D_dump_occur_anal
107 | Opt_D_dump_simpl_iterations
116 | Opt_D_dump_worker_wrapper
117 | Opt_D_dump_rn_trace
118 | Opt_D_dump_rn_stats
120 | Opt_D_dump_simpl_stats
121 | Opt_D_dump_tc_trace
122 | Opt_D_dump_if_trace
128 | Opt_D_verbose_core2core
129 | Opt_D_verbose_stg2stg
131 | Opt_D_dump_hi_diffs
132 | Opt_D_dump_minimal_imports
133 | Opt_D_dump_mod_cycles
134 | Opt_D_faststring_stats
139 | Opt_WarnIsError -- -Werror; makes warnings fatal
140 | Opt_WarnDuplicateExports
142 | Opt_WarnIncompletePatterns
143 | Opt_WarnIncompletePatternsRecUpd
144 | Opt_WarnMissingFields
145 | Opt_WarnMissingMethods
146 | Opt_WarnMissingSigs
147 | Opt_WarnNameShadowing
148 | Opt_WarnOverlappingPatterns
149 | Opt_WarnSimplePatterns
150 | Opt_WarnTypeDefaults
151 | Opt_WarnMonomorphism
152 | Opt_WarnUnusedBinds
153 | Opt_WarnUnusedImports
154 | Opt_WarnUnusedMatches
155 | Opt_WarnDeprecations
156 | Opt_WarnDodgyImports
161 | Opt_AllowOverlappingInstances
162 | Opt_AllowUndecidableInstances
163 | Opt_AllowIncoherentInstances
164 | Opt_MonomorphismRestriction
166 | Opt_ExtendedDefaultRules -- Use GHC's extended rules for defaulting
169 | Opt_PArr -- Syntactic support for parallel arrays
170 | Opt_Arrows -- Arrow-notation syntax
174 | Opt_ImplicitPrelude
175 | Opt_ScopedTypeVariables
178 | Opt_OverloadedStrings
186 | Opt_IgnoreInterfacePragmas
187 | Opt_OmitInterfacePragmas
188 | Opt_DoLambdaEtaExpansion
190 | Opt_IgnoreBreakpoints
193 | Opt_UnboxStrictFields
202 | Opt_ExcessPrecision
203 | Opt_ReadUserPackageConf
207 | Opt_HideAllPackages
208 | Opt_PrintBindResult
221 data DynFlags = DynFlags {
224 coreToDo :: Maybe [CoreToDo], -- reserved for -Ofile
225 stgToDo :: Maybe [StgToDo], -- similarly
226 hscTarget :: HscTarget,
227 hscOutName :: String, -- name of the output file
228 extCoreName :: String, -- name of the .core output file
229 verbosity :: Int, -- verbosity level
230 optLevel :: Int, -- optimisation level
231 maxSimplIterations :: Int, -- max simplifier iterations
232 ruleCheck :: Maybe String,
234 specThreshold :: Int, -- Threshold for function specialisation
236 stolen_x86_regs :: Int,
237 cmdlineHcIncludes :: [String], -- -#includes
238 importPaths :: [FilePath],
240 mainFunIs :: Maybe String,
241 ctxtStkDepth :: Int, -- Typechecker context stack depth
243 thisPackage :: PackageId,
246 wayNames :: [WayName], -- way flags from the cmd line
247 buildTag :: String, -- the global "way" (eg. "p" for prof)
248 rtsBuildTag :: String, -- the RTS "way"
251 objectDir :: Maybe String,
252 hiDir :: Maybe String,
253 stubDir :: Maybe String,
259 outputFile :: Maybe String,
260 outputHi :: Maybe String,
262 includePaths :: [String],
263 libraryPaths :: [String],
264 frameworkPaths :: [String], -- used on darwin only
265 cmdlineFrameworks :: [String], -- ditto
266 tmpDir :: String, -- no trailing '/'
268 ghcUsagePath :: FilePath, -- Filled in by SysTools
269 ghciUsagePath :: FilePath, -- ditto
271 hpcDir :: String, -- ^ path to store the .mix files
273 -- options for particular phases
284 -- commands for particular phases
286 pgm_P :: (String,[Option]),
288 pgm_c :: (String,[Option]),
289 pgm_m :: (String,[Option]),
290 pgm_s :: (String,[Option]),
291 pgm_a :: (String,[Option]),
292 pgm_l :: (String,[Option]),
293 pgm_dll :: (String,[Option]),
295 pgm_sysman :: String,
298 extraPkgConfs :: [FilePath],
299 topDir :: FilePath, -- filled in by SysTools
300 systemPackageConfig :: FilePath, -- ditto
301 -- The -package-conf flags given on the command line, in the order
304 packageFlags :: [PackageFlag],
305 -- The -package and -hide-package flags from the command-line
308 -- NB. do not modify this field, it is calculated by
309 -- Packages.initPackages and Packages.updatePackages.
310 pkgDatabase :: Maybe (UniqFM InstalledPackageInfo),
311 pkgState :: PackageState,
317 log_action :: Severity -> SrcSpan -> PprStyle -> Message -> IO ()
328 -- | will this target result in an object file on the disk?
329 isObjectTarget :: HscTarget -> Bool
330 isObjectTarget HscC = True
331 isObjectTarget HscAsm = True
332 isObjectTarget _ = False
334 -- | The 'GhcMode' tells us whether we're doing multi-module
335 -- compilation (controlled via the "GHC" API) or one-shot
336 -- (single-module) compilation. This makes a difference primarily to
337 -- the "Finder": in one-shot mode we look for interface files for
338 -- imported modules, but in multi-module mode we look for source files
339 -- in order to check whether they need to be recompiled.
341 = CompManager -- ^ --make, GHCi, etc.
342 | OneShot -- ^ ghc -c Foo.hs
343 | MkDepend -- ^ ghc -M, see Finder for why we need this
346 isOneShot :: GhcMode -> Bool
347 isOneShot OneShot = True
348 isOneShot _other = False
350 -- | What kind of linking to do.
351 data GhcLink -- What to do in the link step, if there is one
352 = NoLink -- Don't link at all
353 | LinkBinary -- Link object code into a binary
354 | LinkInMemory -- Use the in-memory dynamic linker
355 | MkDLL -- Make a DLL
358 isNoLink :: GhcLink -> Bool
359 isNoLink NoLink = True
360 isNoLink other = False
363 = ExposePackage String
365 | IgnorePackage String
369 | cGhcWithNativeCodeGen == "YES" = HscAsm
372 initDynFlags dflags = do
373 -- someday these will be dynamic flags
374 ways <- readIORef v_Ways
375 build_tag <- readIORef v_Build_tag
376 rts_build_tag <- readIORef v_RTS_Build_tag
379 buildTag = build_tag,
380 rtsBuildTag = rts_build_tag
385 ghcMode = CompManager,
386 ghcLink = LinkBinary,
389 hscTarget = defaultHscTarget,
394 maxSimplIterations = 4,
398 cmdlineHcIncludes = [],
402 ctxtStkDepth = mAX_CONTEXT_REDUCTION_DEPTH,
404 thisPackage = mainPackageId,
410 objectSuf = phaseInputExt StopLn,
411 hcSuf = phaseInputExt HCc,
414 outputFile = Nothing,
419 cmdlineFrameworks = [],
420 tmpDir = cDEFAULT_TMPDIR,
436 pkgDatabase = Nothing,
437 pkgState = panic "no package state yet: call GHC.setSessionDynFlags",
439 Opt_ReadUserPackageConf,
441 Opt_MonoPatBinds, -- Experimentally, I'm making this non-standard
442 -- behaviour the default, to see if anyone notices
446 Opt_MonomorphismRestriction,
451 Opt_PrintBindResult ]
452 ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
453 -- The default -O0 options
456 log_action = \severity srcSpan style msg ->
458 SevInfo -> hPutStrLn stderr (show (msg style))
459 SevFatal -> hPutStrLn stderr (show (msg style))
460 _ -> hPutStrLn stderr ('\n':show ((mkLocMessage srcSpan msg) style))
466 0 | print errors & warnings only
467 1 | minimal verbosity: print "compiling M ... done." for each module.
468 2 | equivalent to -dshow-passes
469 3 | equivalent to existing "ghc -v"
470 4 | "ghc -v -ddump-most"
471 5 | "ghc -v -ddump-all"
474 dopt :: DynFlag -> DynFlags -> Bool
475 dopt f dflags = f `elem` (flags dflags)
477 dopt_set :: DynFlags -> DynFlag -> DynFlags
478 dopt_set dfs f = dfs{ flags = f : flags dfs }
480 dopt_unset :: DynFlags -> DynFlag -> DynFlags
481 dopt_unset dfs f = dfs{ flags = filter (/= f) (flags dfs) }
483 getOpts :: DynFlags -> (DynFlags -> [a]) -> [a]
484 getOpts dflags opts = reverse (opts dflags)
485 -- We add to the options from the front, so we need to reverse the list
487 getVerbFlag :: DynFlags -> String
489 | verbosity dflags >= 3 = "-v"
492 setObjectDir f d = d{ objectDir = f}
493 setHiDir f d = d{ hiDir = f}
494 setStubDir f d = d{ stubDir = f}
496 setObjectSuf f d = d{ objectSuf = f}
497 setHiSuf f d = d{ hiSuf = f}
498 setHcSuf f d = d{ hcSuf = f}
500 setOutputFile f d = d{ outputFile = f}
501 setOutputHi f d = d{ outputHi = f}
503 -- XXX HACK: Prelude> words "'does not' work" ===> ["'does","not'","work"]
504 -- Config.hs should really use Option.
505 setPgmP f d = let (pgm:args) = words f in d{ pgm_P = (pgm, map Option args)}
507 setPgmL f d = d{ pgm_L = f}
508 setPgmF f d = d{ pgm_F = f}
509 setPgmc f d = d{ pgm_c = (f,[])}
510 setPgmm f d = d{ pgm_m = (f,[])}
511 setPgms f d = d{ pgm_s = (f,[])}
512 setPgma f d = d{ pgm_a = (f,[])}
513 setPgml f d = d{ pgm_l = (f,[])}
514 setPgmdll f d = d{ pgm_dll = (f,[])}
516 addOptL f d = d{ opt_L = f : opt_L d}
517 addOptP f d = d{ opt_P = f : opt_P d}
518 addOptF f d = d{ opt_F = f : opt_F d}
519 addOptc f d = d{ opt_c = f : opt_c d}
520 addOptm f d = d{ opt_m = f : opt_m d}
521 addOpta f d = d{ opt_a = f : opt_a d}
522 addOptl f d = d{ opt_l = f : opt_l d}
523 addOptdll f d = d{ opt_dll = f : opt_dll d}
524 addOptdep f d = d{ opt_dep = f : opt_dep d}
526 addCmdlineFramework f d = d{ cmdlineFrameworks = f : cmdlineFrameworks d}
528 -- -----------------------------------------------------------------------------
529 -- Command-line options
531 -- When invoking external tools as part of the compilation pipeline, we
532 -- pass these a sequence of options on the command-line. Rather than
533 -- just using a list of Strings, we use a type that allows us to distinguish
534 -- between filepaths and 'other stuff'. [The reason being, of course, that
535 -- this type gives us a handle on transforming filenames, and filenames only,
536 -- to whatever format they're expected to be on a particular platform.]
539 = FileOption -- an entry that _contains_ filename(s) / filepaths.
540 String -- a non-filepath prefix that shouldn't be
541 -- transformed (e.g., "/out=")
542 String -- the filepath/filename portion
545 -----------------------------------------------------------------------------
546 -- Setting the optimisation level
548 updOptLevel :: Int -> DynFlags -> DynFlags
549 -- Set dynflags appropriate to the optimisation level
551 = dfs2{ optLevel = n }
553 dfs1 = foldr (flip dopt_unset) dfs remove_dopts
554 dfs2 = foldr (flip dopt_set) dfs1 extra_dopts
556 extra_dopts = [ f | (ns,f) <- optLevelFlags, n `elem` ns ]
557 remove_dopts = [ f | (ns,f) <- optLevelFlags, n `notElem` ns ]
559 optLevelFlags :: [([Int], DynFlag)]
561 = [ ([0], Opt_IgnoreInterfacePragmas)
562 , ([0], Opt_OmitInterfacePragmas)
563 , ([1,2], Opt_IgnoreAsserts)
564 , ([1,2], Opt_DoEtaReduction)
565 , ([1,2], Opt_CaseMerge)
566 , ([1,2], Opt_Strictness)
568 , ([1,2], Opt_FullLaziness)
569 , ([2], Opt_LiberateCase)
570 , ([2], Opt_SpecConstr)
572 , ([0,1,2], Opt_DoLambdaEtaExpansion)
573 -- This one is important for a tiresome reason:
574 -- we want to make sure that the bindings for data
575 -- constructors are eta-expanded. This is probably
576 -- a good thing anyway, but it seems fragile.
579 -- -----------------------------------------------------------------------------
580 -- Standard sets of warning options
583 = [ Opt_WarnDeprecations,
584 Opt_WarnOverlappingPatterns,
585 Opt_WarnMissingFields,
586 Opt_WarnMissingMethods,
587 Opt_WarnMonomorphism,
588 Opt_WarnDuplicateExports
592 = standardWarnings ++
593 [ Opt_WarnUnusedBinds,
594 Opt_WarnUnusedMatches,
595 Opt_WarnUnusedImports,
596 Opt_WarnIncompletePatterns,
602 [ Opt_WarnTypeDefaults,
603 Opt_WarnNameShadowing,
609 -- -----------------------------------------------------------------------------
610 -- CoreToDo: abstraction of core-to-core passes to run.
612 data CoreToDo -- These are diff core-to-core passes,
613 -- which may be invoked in any order,
614 -- as many times as you like.
616 = CoreDoSimplify -- The core-to-core simplifier.
619 -- Each run of the simplifier can take a different
620 -- set of simplifier-specific flags.
622 | CoreDoFloatOutwards FloatOutSwitches
627 | CoreDoWorkerWrapper
630 | CoreDoOldStrictness
633 | CoreDoRuleCheck Int{-CompilerPhase-} String -- Check for non-application of rules
634 -- matching this string
635 | CoreDoNothing -- Useful when building up
636 | CoreDoPasses [CoreToDo] -- lists of these things
638 data SimplifierMode -- See comments in SimplMonad
642 data SimplifierSwitch
643 = MaxSimplifierIterations Int
646 data FloatOutSwitches
647 = FloatOutSw Bool -- True <=> float lambdas to top level
648 Bool -- True <=> float constants to top level,
649 -- even if they do not escape a lambda
652 -- The core-to-core pass ordering is derived from the DynFlags:
653 runWhen :: Bool -> CoreToDo -> CoreToDo
654 runWhen True do_this = do_this
655 runWhen False do_this = CoreDoNothing
657 getCoreToDo :: DynFlags -> [CoreToDo]
659 | Just todo <- coreToDo dflags = todo -- set explicitly by user
660 | otherwise = core_todo
662 opt_level = optLevel dflags
663 max_iter = maxSimplIterations dflags
664 strictness = dopt Opt_Strictness dflags
665 full_laziness = dopt Opt_FullLaziness dflags
666 cse = dopt Opt_CSE dflags
667 spec_constr = dopt Opt_SpecConstr dflags
668 liberate_case = dopt Opt_LiberateCase dflags
669 rule_check = ruleCheck dflags
672 if opt_level == 0 then
674 CoreDoSimplify (SimplPhase 0) [
675 MaxSimplifierIterations max_iter
678 else {- opt_level >= 1 -} [
680 -- initial simplify: mk specialiser happy: minimum effort please
681 CoreDoSimplify SimplGently [
683 -- Don't inline anything till full laziness has bitten
684 -- In particular, inlining wrappers inhibits floating
685 -- e.g. ...(case f x of ...)...
686 -- ==> ...(case (case x of I# x# -> fw x#) of ...)...
687 -- ==> ...(case x of I# x# -> case fw x# of ...)...
688 -- and now the redex (f x) isn't floatable any more
689 -- Similarly, don't apply any rules until after full
690 -- laziness. Notably, list fusion can prevent floating.
692 NoCaseOfCase, -- Don't do case-of-case transformations.
693 -- This makes full laziness work better
694 MaxSimplifierIterations max_iter
697 -- Specialisation is best done before full laziness
698 -- so that overloaded functions have all their dictionary lambdas manifest
701 runWhen full_laziness (CoreDoFloatOutwards (FloatOutSw False False)),
705 CoreDoSimplify (SimplPhase 2) [
706 -- Want to run with inline phase 2 after the specialiser to give
707 -- maximum chance for fusion to work before we inline build/augment
708 -- in phase 1. This made a difference in 'ansi' where an
709 -- overloaded function wasn't inlined till too late.
710 MaxSimplifierIterations max_iter
712 case rule_check of { Just pat -> CoreDoRuleCheck 2 pat; Nothing -> CoreDoNothing },
714 CoreDoSimplify (SimplPhase 1) [
715 -- Need inline-phase2 here so that build/augment get
716 -- inlined. I found that spectral/hartel/genfft lost some useful
717 -- strictness in the function sumcode' if augment is not inlined
718 -- before strictness analysis runs
719 MaxSimplifierIterations max_iter
721 case rule_check of { Just pat -> CoreDoRuleCheck 1 pat; Nothing -> CoreDoNothing },
723 CoreDoSimplify (SimplPhase 0) [
724 -- Phase 0: allow all Ids to be inlined now
725 -- This gets foldr inlined before strictness analysis
727 MaxSimplifierIterations 3
728 -- At least 3 iterations because otherwise we land up with
729 -- huge dead expressions because of an infelicity in the
731 -- let k = BIG in foldr k z xs
732 -- ==> let k = BIG in letrec go = \xs -> ...(k x).... in go xs
733 -- ==> let k = BIG in letrec go = \xs -> ...(BIG x).... in go xs
737 case rule_check of { Just pat -> CoreDoRuleCheck 0 pat; Nothing -> CoreDoNothing },
739 #ifdef OLD_STRICTNESS
742 runWhen strictness (CoreDoPasses [
746 CoreDoSimplify (SimplPhase 0) [
747 MaxSimplifierIterations max_iter
750 runWhen full_laziness
751 (CoreDoFloatOutwards (FloatOutSw False -- Not lambdas
752 True)), -- Float constants
753 -- nofib/spectral/hartel/wang doubles in speed if you
754 -- do full laziness late in the day. It only happens
755 -- after fusion and other stuff, so the early pass doesn't
756 -- catch it. For the record, the redex is
757 -- f_el22 (f_el21 r_midblock)
761 -- We want CSE to follow the final full-laziness pass, because it may
762 -- succeed in commoning up things floated out by full laziness.
763 -- CSE used to rely on the no-shadowing invariant, but it doesn't any more
767 case rule_check of { Just pat -> CoreDoRuleCheck 0 pat; Nothing -> CoreDoNothing },
769 -- Case-liberation for -O2. This should be after
770 -- strictness analysis and the simplification which follows it.
771 runWhen liberate_case (CoreDoPasses [
773 CoreDoSimplify (SimplPhase 0) [
774 MaxSimplifierIterations max_iter
775 ] ]), -- Run the simplifier after LiberateCase to vastly
776 -- reduce the possiblility of shadowing
777 -- Reason: see Note [Shadowing] in SpecConstr.lhs
779 runWhen spec_constr CoreDoSpecConstr,
781 -- Final clean-up simplification:
782 CoreDoSimplify (SimplPhase 0) [
783 MaxSimplifierIterations max_iter
787 -- -----------------------------------------------------------------------------
788 -- StgToDo: abstraction of stg-to-stg passes to run.
791 = StgDoMassageForProfiling -- should be (next to) last
792 -- There's also setStgVarInfo, but its absolute "lastness"
793 -- is so critical that it is hardwired in (no flag).
796 getStgToDo :: DynFlags -> [StgToDo]
798 | Just todo <- stgToDo dflags = todo -- set explicitly by user
801 stg_stats = dopt Opt_StgStats dflags
803 todo1 = if stg_stats then [D_stg_stats] else []
805 todo2 | WayProf `elem` wayNames dflags
806 = StgDoMassageForProfiling : todo1
810 -- -----------------------------------------------------------------------------
814 allFlags = map ('-':) $
815 [ name | (name, optkind) <- dynamic_flags, ok optkind ] ++
816 map ("fno-"++) flags ++
818 where ok (PrefixPred _ _) = False
820 flags = map fst fFlags
822 dynamic_flags :: [(String, OptKind DynP)]
824 ( "n" , NoArg (setDynFlag Opt_DryRun) )
825 , ( "cpp" , NoArg (setDynFlag Opt_Cpp))
826 , ( "F" , NoArg (setDynFlag Opt_Pp))
827 , ( "#include" , HasArg (addCmdlineHCInclude) )
828 , ( "v" , OptIntSuffix setVerbosity )
830 ------- Specific phases --------------------------------------------
831 , ( "pgmL" , HasArg (upd . setPgmL) )
832 , ( "pgmP" , HasArg (upd . setPgmP) )
833 , ( "pgmF" , HasArg (upd . setPgmF) )
834 , ( "pgmc" , HasArg (upd . setPgmc) )
835 , ( "pgmm" , HasArg (upd . setPgmm) )
836 , ( "pgms" , HasArg (upd . setPgms) )
837 , ( "pgma" , HasArg (upd . setPgma) )
838 , ( "pgml" , HasArg (upd . setPgml) )
839 , ( "pgmdll" , HasArg (upd . setPgmdll) )
841 , ( "optL" , HasArg (upd . addOptL) )
842 , ( "optP" , HasArg (upd . addOptP) )
843 , ( "optF" , HasArg (upd . addOptF) )
844 , ( "optc" , HasArg (upd . addOptc) )
845 , ( "optm" , HasArg (upd . addOptm) )
846 , ( "opta" , HasArg (upd . addOpta) )
847 , ( "optl" , HasArg (upd . addOptl) )
848 , ( "optdll" , HasArg (upd . addOptdll) )
849 , ( "optdep" , HasArg (upd . addOptdep) )
851 , ( "split-objs" , NoArg (if can_split
852 then setDynFlag Opt_SplitObjs
855 -------- Linking ----------------------------------------------------
856 , ( "c" , NoArg (upd $ \d -> d{ ghcLink=NoLink } ))
857 , ( "no-link" , NoArg (upd $ \d -> d{ ghcLink=NoLink } )) -- Dep.
858 , ( "-mk-dll" , NoArg (upd $ \d -> d{ ghcLink=MkDLL } ))
860 ------- Libraries ---------------------------------------------------
861 , ( "L" , Prefix addLibraryPath )
862 , ( "l" , AnySuffix (\s -> do upd (addOptl s)
865 ------- Frameworks --------------------------------------------------
866 -- -framework-path should really be -F ...
867 , ( "framework-path" , HasArg addFrameworkPath )
868 , ( "framework" , HasArg (upd . addCmdlineFramework) )
870 ------- Output Redirection ------------------------------------------
871 , ( "odir" , HasArg (upd . setObjectDir . Just))
872 , ( "o" , SepArg (upd . setOutputFile . Just))
873 , ( "ohi" , HasArg (upd . setOutputHi . Just ))
874 , ( "osuf" , HasArg (upd . setObjectSuf))
875 , ( "hcsuf" , HasArg (upd . setHcSuf))
876 , ( "hisuf" , HasArg (upd . setHiSuf))
877 , ( "hidir" , HasArg (upd . setHiDir . Just))
878 , ( "tmpdir" , HasArg (upd . setTmpDir))
879 , ( "stubdir" , HasArg (upd . setStubDir . Just))
881 ------- Keeping temporary files -------------------------------------
882 , ( "keep-hc-file" , AnySuffix (\_ -> setDynFlag Opt_KeepHcFiles))
883 , ( "keep-s-file" , AnySuffix (\_ -> setDynFlag Opt_KeepSFiles))
884 , ( "keep-raw-s-file", AnySuffix (\_ -> setDynFlag Opt_KeepRawSFiles))
885 , ( "keep-tmp-files" , AnySuffix (\_ -> setDynFlag Opt_KeepTmpFiles))
887 ------- Miscellaneous ----------------------------------------------
888 , ( "no-hs-main" , NoArg (setDynFlag Opt_NoHsMain))
889 , ( "main-is" , SepArg setMainIs )
890 , ( "haddock" , NoArg (setDynFlag Opt_Haddock) )
891 , ( "hpcdir" , SepArg setOptHpcDir )
893 ------- recompilation checker (DEPRECATED, use -fforce-recomp) -----
894 , ( "recomp" , NoArg (unSetDynFlag Opt_ForceRecomp) )
895 , ( "no-recomp" , NoArg (setDynFlag Opt_ForceRecomp) )
897 ------- Packages ----------------------------------------------------
898 , ( "package-conf" , HasArg extraPkgConf_ )
899 , ( "no-user-package-conf", NoArg (unSetDynFlag Opt_ReadUserPackageConf) )
900 , ( "package-name" , HasArg (upd . setPackageName) )
901 , ( "package" , HasArg exposePackage )
902 , ( "hide-package" , HasArg hidePackage )
903 , ( "hide-all-packages", NoArg (setDynFlag Opt_HideAllPackages) )
904 , ( "ignore-package" , HasArg ignorePackage )
905 , ( "syslib" , HasArg exposePackage ) -- for compatibility
907 ------ HsCpp opts ---------------------------------------------------
908 , ( "D", AnySuffix (upd . addOptP) )
909 , ( "U", AnySuffix (upd . addOptP) )
911 ------- Include/Import Paths ----------------------------------------
912 , ( "I" , Prefix addIncludePath)
913 , ( "i" , OptPrefix addImportPath )
915 ------ Debugging ----------------------------------------------------
916 , ( "dstg-stats", NoArg (setDynFlag Opt_StgStats))
918 , ( "ddump-cmm", setDumpFlag Opt_D_dump_cmm)
919 , ( "ddump-asm", setDumpFlag Opt_D_dump_asm)
920 , ( "ddump-cpranal", setDumpFlag Opt_D_dump_cpranal)
921 , ( "ddump-deriv", setDumpFlag Opt_D_dump_deriv)
922 , ( "ddump-ds", setDumpFlag Opt_D_dump_ds)
923 , ( "ddump-flatC", setDumpFlag Opt_D_dump_flatC)
924 , ( "ddump-foreign", setDumpFlag Opt_D_dump_foreign)
925 , ( "ddump-inlinings", setDumpFlag Opt_D_dump_inlinings)
926 , ( "ddump-rule-firings", setDumpFlag Opt_D_dump_rule_firings)
927 , ( "ddump-occur-anal", setDumpFlag Opt_D_dump_occur_anal)
928 , ( "ddump-parsed", setDumpFlag Opt_D_dump_parsed)
929 , ( "ddump-rn", setDumpFlag Opt_D_dump_rn)
930 , ( "ddump-simpl", setDumpFlag Opt_D_dump_simpl)
931 , ( "ddump-simpl-iterations", setDumpFlag Opt_D_dump_simpl_iterations)
932 , ( "ddump-spec", setDumpFlag Opt_D_dump_spec)
933 , ( "ddump-prep", setDumpFlag Opt_D_dump_prep)
934 , ( "ddump-stg", setDumpFlag Opt_D_dump_stg)
935 , ( "ddump-stranal", setDumpFlag Opt_D_dump_stranal)
936 , ( "ddump-tc", setDumpFlag Opt_D_dump_tc)
937 , ( "ddump-types", setDumpFlag Opt_D_dump_types)
938 , ( "ddump-rules", setDumpFlag Opt_D_dump_rules)
939 , ( "ddump-cse", setDumpFlag Opt_D_dump_cse)
940 , ( "ddump-worker-wrapper", setDumpFlag Opt_D_dump_worker_wrapper)
941 , ( "ddump-rn-trace", setDumpFlag Opt_D_dump_rn_trace)
942 , ( "ddump-if-trace", setDumpFlag Opt_D_dump_if_trace)
943 , ( "ddump-tc-trace", setDumpFlag Opt_D_dump_tc_trace)
944 , ( "ddump-splices", setDumpFlag Opt_D_dump_splices)
945 , ( "ddump-rn-stats", setDumpFlag Opt_D_dump_rn_stats)
946 , ( "ddump-opt-cmm", setDumpFlag Opt_D_dump_opt_cmm)
947 , ( "ddump-simpl-stats", setDumpFlag Opt_D_dump_simpl_stats)
948 , ( "ddump-bcos", setDumpFlag Opt_D_dump_BCOs)
949 , ( "dsource-stats", setDumpFlag Opt_D_source_stats)
950 , ( "dverbose-core2core", setDumpFlag Opt_D_verbose_core2core)
951 , ( "dverbose-stg2stg", setDumpFlag Opt_D_verbose_stg2stg)
952 , ( "ddump-hi-diffs", setDumpFlag Opt_D_dump_hi_diffs)
953 , ( "ddump-hi", setDumpFlag Opt_D_dump_hi)
954 , ( "ddump-minimal-imports", setDumpFlag Opt_D_dump_minimal_imports)
955 , ( "ddump-vect", setDumpFlag Opt_D_dump_vect)
956 , ( "ddump-hpc", setDumpFlag Opt_D_dump_hpc)
957 , ( "ddump-mod-cycles", setDumpFlag Opt_D_dump_mod_cycles)
959 , ( "dcore-lint", NoArg (setDynFlag Opt_DoCoreLinting))
960 , ( "dstg-lint", NoArg (setDynFlag Opt_DoStgLinting))
961 , ( "dcmm-lint", NoArg (setDynFlag Opt_DoCmmLinting))
962 , ( "dshow-passes", NoArg (do setDynFlag Opt_ForceRecomp
963 setVerbosity (Just 2)) )
964 , ( "dfaststring-stats", NoArg (setDynFlag Opt_D_faststring_stats))
966 ------ Machine dependant (-m<blah>) stuff ---------------------------
968 , ( "monly-2-regs", NoArg (upd (\s -> s{stolen_x86_regs = 2}) ))
969 , ( "monly-3-regs", NoArg (upd (\s -> s{stolen_x86_regs = 3}) ))
970 , ( "monly-4-regs", NoArg (upd (\s -> s{stolen_x86_regs = 4}) ))
972 ------ Warning opts -------------------------------------------------
973 , ( "W" , NoArg (mapM_ setDynFlag minusWOpts) )
974 , ( "Werror" , NoArg (setDynFlag Opt_WarnIsError) )
975 , ( "Wall" , NoArg (mapM_ setDynFlag minusWallOpts) )
976 , ( "Wnot" , NoArg (mapM_ unSetDynFlag minusWallOpts) ) /* DEPREC */
977 , ( "w" , NoArg (mapM_ unSetDynFlag minusWallOpts) )
979 ------ Optimisation flags ------------------------------------------
980 , ( "O" , NoArg (upd (setOptLevel 1)))
981 , ( "Onot" , NoArg (upd (setOptLevel 0)))
982 , ( "O" , OptIntSuffix (\mb_n -> upd (setOptLevel (mb_n `orElse` 1))))
983 -- If the number is missing, use 1
985 , ( "fmax-simplifier-iterations", IntSuffix (\n ->
986 upd (\dfs -> dfs{ maxSimplIterations = n })) )
988 -- liberate-case-threshold is an old flag for '-fspec-threshold'
989 , ( "fspec-threshold", IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n })))
990 , ( "fliberate-case-threshold", IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n })))
992 , ( "frule-check", SepArg (\s -> upd (\dfs -> dfs{ ruleCheck = Just s })))
993 , ( "fcontext-stack" , IntSuffix $ \n -> upd $ \dfs -> dfs{ ctxtStkDepth = n })
995 ------ Compiler flags -----------------------------------------------
997 , ( "fasm", AnySuffix (\_ -> setObjTarget HscAsm) )
998 , ( "fvia-c", NoArg (setObjTarget HscC) )
999 , ( "fvia-C", NoArg (setObjTarget HscC) )
1001 , ( "fno-code", NoArg (setTarget HscNothing))
1002 , ( "fbyte-code", NoArg (setTarget HscInterpreted) )
1003 , ( "fobject-code", NoArg (setTarget defaultHscTarget) )
1005 , ( "fglasgow-exts", NoArg (mapM_ setDynFlag glasgowExtsFlags) )
1006 , ( "fno-glasgow-exts", NoArg (mapM_ unSetDynFlag glasgowExtsFlags) )
1009 -- the rest of the -f* and -fno-* flags
1010 , ( "fno-", PrefixPred (\f -> isFFlag f) (\f -> unSetDynFlag (getFFlag f)) )
1011 , ( "f", PrefixPred (\f -> isFFlag f) (\f -> setDynFlag (getFFlag f)) )
1014 -- these -f<blah> flags can all be reversed with -fno-<blah>
1017 ( "warn-duplicate-exports", Opt_WarnDuplicateExports ),
1018 ( "warn-hi-shadowing", Opt_WarnHiShadows ),
1019 ( "warn-incomplete-patterns", Opt_WarnIncompletePatterns ),
1020 ( "warn-incomplete-record-updates", Opt_WarnIncompletePatternsRecUpd ),
1021 ( "warn-missing-fields", Opt_WarnMissingFields ),
1022 ( "warn-missing-methods", Opt_WarnMissingMethods ),
1023 ( "warn-missing-signatures", Opt_WarnMissingSigs ),
1024 ( "warn-name-shadowing", Opt_WarnNameShadowing ),
1025 ( "warn-overlapping-patterns", Opt_WarnOverlappingPatterns ),
1026 ( "warn-simple-patterns", Opt_WarnSimplePatterns ),
1027 ( "warn-type-defaults", Opt_WarnTypeDefaults ),
1028 ( "warn-monomorphism-restriction", Opt_WarnMonomorphism ),
1029 ( "warn-unused-binds", Opt_WarnUnusedBinds ),
1030 ( "warn-unused-imports", Opt_WarnUnusedImports ),
1031 ( "warn-unused-matches", Opt_WarnUnusedMatches ),
1032 ( "warn-deprecations", Opt_WarnDeprecations ),
1033 ( "warn-orphans", Opt_WarnOrphans ),
1034 ( "warn-tabs", Opt_WarnTabs ),
1035 ( "fi", Opt_FFI ), -- support `-ffi'...
1036 ( "ffi", Opt_FFI ), -- ...and also `-fffi'
1037 ( "arrows", Opt_Arrows ), -- arrow syntax
1038 ( "parr", Opt_PArr ),
1040 ( "implicit-prelude", Opt_ImplicitPrelude ),
1041 ( "scoped-type-variables", Opt_ScopedTypeVariables ),
1042 ( "bang-patterns", Opt_BangPatterns ),
1043 ( "overloaded-strings", Opt_OverloadedStrings ),
1044 ( "indexed-types", Opt_IndexedTypes ),
1045 ( "monomorphism-restriction", Opt_MonomorphismRestriction ),
1046 ( "mono-pat-binds", Opt_MonoPatBinds ),
1047 ( "extended-default-rules", Opt_ExtendedDefaultRules ),
1048 ( "implicit-params", Opt_ImplicitParams ),
1049 ( "allow-overlapping-instances", Opt_AllowOverlappingInstances ),
1050 ( "allow-undecidable-instances", Opt_AllowUndecidableInstances ),
1051 ( "allow-incoherent-instances", Opt_AllowIncoherentInstances ),
1052 ( "generics", Opt_Generics ),
1053 ( "strictness", Opt_Strictness ),
1054 ( "full-laziness", Opt_FullLaziness ),
1055 ( "liberate-case", Opt_LiberateCase ),
1056 ( "spec-constr", Opt_SpecConstr ),
1058 ( "ignore-interface-pragmas", Opt_IgnoreInterfacePragmas ),
1059 ( "omit-interface-pragmas", Opt_OmitInterfacePragmas ),
1060 ( "do-lambda-eta-expansion", Opt_DoLambdaEtaExpansion ),
1061 ( "ignore-asserts", Opt_IgnoreAsserts ),
1062 ( "ignore-breakpoints", Opt_IgnoreBreakpoints),
1063 ( "do-eta-reduction", Opt_DoEtaReduction ),
1064 ( "case-merge", Opt_CaseMerge ),
1065 ( "unbox-strict-fields", Opt_UnboxStrictFields ),
1066 ( "dicts-cheap", Opt_DictsCheap ),
1067 ( "excess-precision", Opt_ExcessPrecision ),
1068 ( "asm-mangling", Opt_DoAsmMangling ),
1069 ( "print-bind-result", Opt_PrintBindResult ),
1070 ( "force-recomp", Opt_ForceRecomp ),
1071 ( "hpc-no-auto", Opt_Hpc_No_Auto )
1075 glasgowExtsFlags = [
1079 Opt_ScopedTypeVariables,
1082 isFFlag f = f `elem` (map fst fFlags)
1083 getFFlag f = fromJust (lookup f fFlags)
1085 -- -----------------------------------------------------------------------------
1086 -- Parsing the dynamic flags.
1088 parseDynamicFlags :: DynFlags -> [String] -> IO (DynFlags,[String])
1089 parseDynamicFlags dflags args = do
1090 let ((leftover,errs),dflags')
1091 = runCmdLine (processArgs dynamic_flags args) dflags
1092 when (not (null errs)) $ do
1093 throwDyn (UsageError (unlines errs))
1094 return (dflags', leftover)
1097 type DynP = CmdLineP DynFlags
1099 upd :: (DynFlags -> DynFlags) -> DynP ()
1101 dfs <- getCmdLineState
1102 putCmdLineState $! (f dfs)
1104 setDynFlag, unSetDynFlag :: DynFlag -> DynP ()
1105 setDynFlag f = upd (\dfs -> dopt_set dfs f)
1106 unSetDynFlag f = upd (\dfs -> dopt_unset dfs f)
1108 setDumpFlag :: DynFlag -> OptKind DynP
1109 setDumpFlag dump_flag
1110 = NoArg (setDynFlag Opt_ForceRecomp >> setDynFlag dump_flag)
1111 -- Whenver we -ddump, switch off the recompilation checker,
1112 -- else you don't see the dump!
1114 setVerbosity :: Maybe Int -> DynP ()
1115 setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 })
1117 addCmdlineHCInclude a = upd (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes s})
1119 extraPkgConf_ p = upd (\s -> s{ extraPkgConfs = p : extraPkgConfs s })
1122 upd (\s -> s{ packageFlags = ExposePackage p : packageFlags s })
1124 upd (\s -> s{ packageFlags = HidePackage p : packageFlags s })
1126 upd (\s -> s{ packageFlags = IgnorePackage p : packageFlags s })
1129 | Nothing <- unpackPackageId pid
1130 = throwDyn (CmdLineError ("cannot parse \'" ++ p ++ "\' as a package identifier"))
1132 = \s -> s{ thisPackage = pid }
1134 pid = stringToPackageId p
1136 -- If we're linking a binary, then only targets that produce object
1137 -- code are allowed (requests for other target types are ignored).
1138 setTarget l = upd set
1141 | ghcLink dfs /= LinkBinary || isObjectTarget l = dfs{ hscTarget = l }
1144 -- Changes the target only if we're compiling object code. This is
1145 -- used by -fasm and -fvia-C, which switch from one to the other, but
1146 -- not from bytecode to object-code. The idea is that -fasm/-fvia-C
1147 -- can be safely used in an OPTIONS_GHC pragma.
1148 setObjTarget l = upd set
1151 | isObjectTarget (hscTarget dfs) = dfs { hscTarget = l }
1154 setOptLevel :: Int -> DynFlags -> DynFlags
1155 setOptLevel n dflags
1156 | hscTarget dflags == HscInterpreted && n > 0
1158 -- not in IO any more, oh well:
1159 -- putStr "warning: -O conflicts with --interactive; -O ignored.\n"
1161 = updOptLevel n dflags
1164 setMainIs :: String -> DynP ()
1166 | not (null main_fn) -- The arg looked like "Foo.baz"
1167 = upd $ \d -> d{ mainFunIs = Just main_fn,
1168 mainModIs = mkModule mainPackageId (mkModuleName main_mod) }
1170 | isUpper (head main_mod) -- The arg looked like "Foo"
1171 = upd $ \d -> d{ mainModIs = mkModule mainPackageId (mkModuleName main_mod) }
1173 | otherwise -- The arg looked like "baz"
1174 = upd $ \d -> d{ mainFunIs = Just main_mod }
1176 (main_mod, main_fn) = splitLongestPrefix arg (== '.')
1178 -----------------------------------------------------------------------------
1179 -- Paths & Libraries
1181 -- -i on its own deletes the import paths
1182 addImportPath "" = upd (\s -> s{importPaths = []})
1183 addImportPath p = upd (\s -> s{importPaths = importPaths s ++ splitPathList p})
1187 upd (\s -> s{libraryPaths = libraryPaths s ++ splitPathList p})
1190 upd (\s -> s{includePaths = includePaths s ++ splitPathList p})
1192 addFrameworkPath p =
1193 upd (\s -> s{frameworkPaths = frameworkPaths s ++ splitPathList p})
1195 split_marker = ':' -- not configurable (ToDo)
1197 splitPathList :: String -> [String]
1198 splitPathList s = filter notNull (splitUp s)
1199 -- empty paths are ignored: there might be a trailing
1200 -- ':' in the initial list, for example. Empty paths can
1201 -- cause confusion when they are translated into -I options
1202 -- for passing to gcc.
1204 #ifndef mingw32_TARGET_OS
1205 splitUp xs = split split_marker xs
1207 -- Windows: 'hybrid' support for DOS-style paths in directory lists.
1209 -- That is, if "foo:bar:baz" is used, this interpreted as
1210 -- consisting of three entries, 'foo', 'bar', 'baz'.
1211 -- However, with "c:/foo:c:\\foo;x:/bar", this is interpreted
1212 -- as 3 elts, "c:/foo", "c:\\foo", "x:/bar"
1214 -- Notice that no attempt is made to fully replace the 'standard'
1215 -- split marker ':' with the Windows / DOS one, ';'. The reason being
1216 -- that this will cause too much breakage for users & ':' will
1217 -- work fine even with DOS paths, if you're not insisting on being silly.
1220 splitUp (x:':':div:xs) | div `elem` dir_markers
1221 = ((x:':':div:p): splitUp rs)
1223 (p,rs) = findNextPath xs
1224 -- we used to check for existence of the path here, but that
1225 -- required the IO monad to be threaded through the command-line
1226 -- parser which is quite inconvenient. The
1227 splitUp xs = cons p (splitUp rs)
1229 (p,rs) = findNextPath xs
1234 -- will be called either when we've consumed nought or the
1235 -- "<Drive>:/" part of a DOS path, so splitting is just a Q of
1236 -- finding the next split marker.
1238 case break (`elem` split_markers) xs of
1239 (p, d:ds) -> (p, ds)
1242 split_markers :: [Char]
1243 split_markers = [':', ';']
1245 dir_markers :: [Char]
1246 dir_markers = ['/', '\\']
1249 -- -----------------------------------------------------------------------------
1250 -- tmpDir, where we store temporary files.
1252 setTmpDir :: FilePath -> DynFlags -> DynFlags
1253 setTmpDir dir dflags = dflags{ tmpDir = canonicalise dir }
1255 #if !defined(mingw32_HOST_OS)
1256 canonicalise p = normalisePath p
1258 -- Canonicalisation of temp path under win32 is a bit more
1259 -- involved: (a) strip trailing slash,
1260 -- (b) normalise slashes
1261 -- (c) just in case, if there is a prefix /cygdrive/x/, change to x:
1263 canonicalise path = normalisePath (xltCygdrive (removeTrailingSlash path))
1265 -- if we're operating under cygwin, and TMP/TEMP is of
1266 -- the form "/cygdrive/drive/path", translate this to
1267 -- "drive:/path" (as GHC isn't a cygwin app and doesn't
1268 -- understand /cygdrive paths.)
1270 | "/cygdrive/" `isPrefixOf` path =
1271 case drop (length "/cygdrive/") path of
1272 drive:xs@('/':_) -> drive:':':xs
1276 -- strip the trailing backslash (awful, but we only do this once).
1277 removeTrailingSlash path =
1284 -----------------------------------------------------------------------------
1287 setOptHpcDir :: String -> DynP ()
1288 setOptHpcDir arg = upd $ \ d -> d{hpcDir = arg}
1290 -----------------------------------------------------------------------------
1291 -- Via-C compilation stuff
1293 machdepCCOpts :: DynFlags -> ([String], -- flags for all C compilations
1294 [String]) -- for registerised HC compilations
1295 machdepCCOpts dflags
1296 #if alpha_TARGET_ARCH
1298 #ifdef HAVE_THREADED_RTS_SUPPORT
1302 -- For now, to suppress the gcc warning "call-clobbered
1303 -- register used for global register variable", we simply
1304 -- disable all warnings altogether using the -w flag. Oh well.
1306 #elif hppa_TARGET_ARCH
1307 -- ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
1308 -- (very nice, but too bad the HP /usr/include files don't agree.)
1309 = ( ["-D_HPUX_SOURCE"], [] )
1311 #elif m68k_TARGET_ARCH
1312 -- -fno-defer-pop : for the .hc files, we want all the pushing/
1313 -- popping of args to routines to be explicit; if we let things
1314 -- be deferred 'til after an STGJUMP, imminent death is certain!
1316 -- -fomit-frame-pointer : *don't*
1317 -- It's better to have a6 completely tied up being a frame pointer
1318 -- rather than let GCC pick random things to do with it.
1319 -- (If we want to steal a6, then we would try to do things
1320 -- as on iX86, where we *do* steal the frame pointer [%ebp].)
1321 = ( [], ["-fno-defer-pop", "-fno-omit-frame-pointer"] )
1323 #elif i386_TARGET_ARCH
1324 -- -fno-defer-pop : basically the same game as for m68k
1326 -- -fomit-frame-pointer : *must* in .hc files; because we're stealing
1327 -- the fp (%ebp) for our register maps.
1328 = let n_regs = stolen_x86_regs dflags
1331 ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else ""
1332 -- , if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else ""
1335 #ifdef HAVE_GCC_MNO_OMIT_LFPTR
1336 -- Some gccs are configured with
1337 -- -momit-leaf-frame-pointer on by default, and it
1338 -- apparently takes precedence over
1339 -- -fomit-frame-pointer, so we disable it first here.
1340 "-mno-omit-leaf-frame-pointer",
1342 #ifdef HAVE_GCC_HAS_NO_UNIT_AT_A_TIME
1343 "-fno-unit-at-a-time",
1344 -- unit-at-a-time doesn't do us any good, and screws
1345 -- up -split-objs by moving the split markers around.
1346 -- It's only turned on with -O2, but put it here just
1347 -- in case someone uses -optc-O2.
1349 "-fomit-frame-pointer",
1350 -- we want -fno-builtin, because when gcc inlines
1351 -- built-in functions like memcpy() it tends to
1352 -- run out of registers, requiring -monly-n-regs
1354 "-DSTOLEN_X86_REGS="++show n_regs ]
1357 #elif ia64_TARGET_ARCH
1358 = ( [], ["-fomit-frame-pointer", "-G0"] )
1360 #elif x86_64_TARGET_ARCH
1361 = ( [], ["-fomit-frame-pointer",
1362 "-fno-asynchronous-unwind-tables",
1363 -- the unwind tables are unnecessary for HC code,
1364 -- and get in the way of -split-objs. Another option
1365 -- would be to throw them away in the mangler, but this
1367 #ifdef HAVE_GCC_HAS_NO_UNIT_AT_A_TIME
1368 "-fno-unit-at-a-time",
1369 -- unit-at-a-time doesn't do us any good, and screws
1370 -- up -split-objs by moving the split markers around.
1371 -- It's only turned on with -O2, but put it here just
1372 -- in case someone uses -optc-O2.
1375 -- calling builtins like strlen() using the FFI can
1376 -- cause gcc to run out of regs, so use the external
1380 #elif sparc_TARGET_ARCH
1382 -- For now, to suppress the gcc warning "call-clobbered
1383 -- register used for global register variable", we simply
1384 -- disable all warnings altogether using the -w flag. Oh well.
1386 #elif powerpc_apple_darwin_TARGET
1388 -- Disable Apple's precompiling preprocessor. It's a great thing
1389 -- for "normal" programs, but it doesn't support register variable
1391 = ( [], ["-no-cpp-precomp"] )
1396 picCCOpts :: DynFlags -> [String]
1398 #if darwin_TARGET_OS
1399 -- Apple prefers to do things the other way round.
1400 -- PIC is on by default.
1401 -- -mdynamic-no-pic:
1402 -- Turn off PIC code generation.
1404 -- Don't generate "common" symbols - these are unwanted
1405 -- in dynamic libraries.
1410 = ["-mdynamic-no-pic"]
1411 #elif mingw32_TARGET_OS
1412 -- no -fPIC for Windows
1421 -- -----------------------------------------------------------------------------
1426 #if defined(i386_TARGET_ARCH) \
1427 || defined(x86_64_TARGET_ARCH) \
1428 || defined(alpha_TARGET_ARCH) \
1429 || defined(hppa_TARGET_ARCH) \
1430 || defined(m68k_TARGET_ARCH) \
1431 || defined(mips_TARGET_ARCH) \
1432 || defined(powerpc_TARGET_ARCH) \
1433 || defined(rs6000_TARGET_ARCH) \
1434 || defined(sparc_TARGET_ARCH)