5.17. Flag reference

This section is a quick-reference for GHC's command-line flags. For each flag, we also list its static/dynamic status (see Section 5.2, “Static, Dynamic, and Mode options”), and the flag's opposite (if available).

5.17.1. Help and verbosity options

Section 5.5, “Help and verbosity options”

FlagDescriptionStatic/DynamicReverse
-?helpmode-
-helphelpmode-
-ndo a dry rundynamic-
-vverbose mode (equivalent to -v3)dynamic-
-vnset verbosity leveldynamic-
-Vdisplay GHC versionmode-
––supported-languagesdisplay the supported language extensionsmode-
––infodisplay information about the compilermode-
––versiondisplay GHC versionmode-
––numeric-versiondisplay GHC version (numeric only)mode-
––print-libdirdisplay GHC library directorymode-
-ferror-spansoutput full span in error messagesstatic-
-HsizeSet the minimum heap size to sizestatic-
-Rghc-timingSummarise timing stats for GHC (same as +RTS -tstderr)static-

5.17.2. Which phases to run

Section 5.4.3, “Batch compiler mode”

FlagDescriptionStatic/DynamicReverse
-EStop after preprocessing (.hspp file)mode-
-CStop after generating C (.hc file)mode-
-SStop after generating assembly (.s file)mode-
-cDo not linkdynamic-
-x suffixOverride default behaviour for source filesstatic-

5.17.3. Alternative modes of operation

Section 5.4, “Modes of operation”

FlagDescriptionStatic/DynamicReverse
--interactiveInteractive mode - normally used by just running ghci; see Chapter 3, Using GHCi for details.mode-
--makeBuild a multi-module Haskell program, automatically figuring out dependencies. Likely to be much easier, and faster, than using make; see Section 5.4.1, “Using ghc ––make for details..mode-
-e exprEvaluate expr; see Section 5.4.2, “Expression evaluation mode” for details.mode-
-MGenerate dependency information suitable for use in a Makefile; see Section 5.6.11, “Dependency generation” for details.mode-

5.17.4. Redirecting output

Section 5.6.4, “Redirecting the compilation output(s)”

FlagDescriptionStatic/DynamicReverse
-hcsuf suffixset the suffix to use for intermediate C filesdynamic-
-hidir dirset directory for interface filesdynamic-
-hisuf suffixset the suffix to use for interface filesdynamic-
-o filenameset output filenamedynamic-
-odir dirset output directorydynamic-
-ohi filenameset the filename in which to put the interfacedynamic 
-osuf suffixset the output file suffixdynamic-
-stubdir dirredirect FFi stub filesdynamic-

5.17.5. Keeping intermediate files

Section 5.6.5, “Keeping Intermediate Files”

FlagDescriptionStatic/DynamicReverse
-keep-hc-file or -keep-hc-filesretain intermediate .hc filesdynamic-
-keep-s-file or -keep-s-filesretain intermediate .s filesdynamic-
-keep-raw-s-file or -keep-raw-s-filesretain intermediate .raw_s filesdynamic-
-keep-tmp-filesretain all intermediate temporary filesdynamic-

5.17.6. Temporary files

Section 5.6.6, “Redirecting temporary files”

FlagDescriptionStatic/DynamicReverse
-tmpdirset the directory for temporary filesdynamic-

5.17.7. Finding imports

Section 5.6.3, “The search path”

FlagDescriptionStatic/DynamicReverse
-idir1:dir2:...add dir, dir2, etc. to import pathstatic/:set-
-iEmpty the import directory liststatic/:set-

5.17.8. Interface file options

Section 5.6.7, “Other options related to interface files”

FlagDescriptionStatic/DynamicReverse
-ddump-hiDump the new interface to stdoutdynamic-
-ddump-hi-diffsShow the differences vs. the old interfacedynamic-
-ddump-minimal-importsDump a minimal set of importsdynamic-
--show-iface fileSee Section 5.4, “Modes of operation”.  

5.17.9. Recompilation checking

Section 5.6.8, “The recompilation checker”

FlagDescriptionStatic/DynamicReverse
-fforce-recompTurn off recompilation checking; implied by any -ddump-X optiondynamic-fno-force-recomp

5.17.10. Interactive-mode options

Section 3.9, “The .ghci file”

FlagDescriptionStatic/DynamicReverse
-ignore-dot-ghciDisable reading of .ghci filesstatic-
-read-dot-ghciEnable reading of .ghci filesstatic-
-fbreak-on-exceptionBreak on any exception throwndynamic-fno-break-on-exception
-fbreak-on-errorBreak on uncaught exceptions and errorsdynamic-fno-break-on-error
-fprint-evld-with-showEnable usage of Show instances in :printdynamic-fno-print-evld-with-show
-fno-print-bind-resultTurn off printing of binding results in GHCidynamic-
-fno-print-bind-contentsTurn off printing of binding contents in GHCidynamic-

5.17.11. Packages

Section 5.8, “ Packages ”

FlagDescriptionStatic/DynamicReverse
-package-name PCompile to be part of package Pdynamic-
-package PExpose package Pstatic/:set-
-hide-all-packagesHide all packages by defaultstatic-
-hide-package nameHide package Pstatic/:set-
-ignore-package nameIgnore package Pstatic/:set-
-package-conf fileLoad more packages from filestatic-
-no-user-package-confDon't load the user's package config file.static-

5.17.12. Language options

Section 8.1, “Language options”

FlagDescriptionStatic/DynamicReverse
-fglasgow-extsEnable most language extensionsdynamic-fno-glasgow-exts
-XOverlappingInstancesEnable overlapping instancesdynamic-XNoOverlappingInstances
-XIncoherentInstancesEnable incoherent instances. Implies -XOverlappingInstances dynamic-XNoIncoherentInstances
-XUndecidableInstancesEnable undecidable instancesdynamic-XNoUndecidableInstances
-fcontext-stack=Nnset the limit for context reduction. Default is 20.dynamic 
-XArrowsEnable arrow notation extensiondynamic-XNoArrows
-fdisambiguate-record-fieldsEnable record field disambiguationdynamic-fno-disambiguate-record-fields
-XForeignFunctionInterfaceEnable foreign function interface (implied by -fglasgow-exts)dynamic-XNoForeignFunctionInterface
-XGenericsEnable generic classesdynamic-XNoGenerics
-XImplicitParamsEnable Implicit Parameters. Implied by -fglasgow-exts.dynamic-XNoImplicitParams
-firrefutable-tuplesMake tuple pattern matching irrefutabledynamic-fno-irrefutable-tuples
-XNoImplicitPreludeDon't implicitly import Preludedynamic-XImplicitPrelude
-XNoMonomorphismRestrictionDisable the monomorphism restrictiondynamic-XMonomorphismRrestriction
-XNoMonoPatBindsMake pattern bindings polymorphicdynamic-XMonoPatBinds
-XRelaxedPolyRecRelaxed checking for mutually-recursive polymorphic functionsdynamic-XNoRelaxedPolyRec
-XExtendedDefaultRulesUse GHCi's extended default rules in a normal moduledynamic-XNoExtendedDefaultRules
-XOverloadedStringsEnable overloaded string literals. dynamic-XNoOverloadedStrings
-XGADTsEnable generalised algebraic data types. dynamic-XNoGADTs
-XTypeFamiliesEnable type families.dynamic-XNoTypeFamilies
-XScopedTypeVariablesEnable lexically-scoped type variables. Implied by -fglasgow-exts.dynamic-XNoScopedTypeVariables
-XTemplateHaskellEnable Template Haskell. No longer implied by -fglasgow-exts.dynamic-XNoTemplateHaskell
-XBangPatternsEnable bang patterns.dynamic-XNoBangPatterns
-XCPPEnable the C preprocessor.dynamic-XNoCPP
-XPatternGuardsEnable pattern guards.dynamic-XNoPatternGuards
-XUnicodeSyntaxEnable unicode syntax.dynamic-XNoUnicodeSyntax
-XMagicHashEnable the “magic hash”.dynamic-XNoMagicHash
-XPolymorphicComponentsEnable polymorphic components for data constructors.dynamic-XNoPolymorphicComponents
-XRank2TypesEnable rank-2 types.dynamic-XNoRank2Types
-XRankNTypesEnable rank-N types.dynamic-XNoRankNTypes
-XExistentialQuantificationEnable existential quantification.dynamic-XNoExistentialQuantification
-XKindSignaturesEnable kind signatures.dynamic-XNoKindSignatures
-XPatternSignaturesEnable pattern type signatures.dynamic-XNoPatternSignatures
-XEmptyDataDeclsEnable empty data declarations.dynamic-XNoEmptyDataDecls
-XParallelListCompEnable parallel list comprehensions.dynamic-XNoParallelListComp
-XUnliftedFFITypesEnable unlifted FFI types.dynamic-XNoUnliftedFFITypes
-XLiberalTypeSynonymsEnable liberalised type synonyms.dynamic-XNoLiberalTypeSynonyms
-XTypeOperatorsEnable type operators.dynamic-XNoTypeOperators
-XRecursiveDoEnable recursive do (mdo) notation.dynamic-XNoRecursiveDo
-XPArrEnable parallel arrays.dynamic-XNoPArr
-XRecordWildCardsEnable record wildcards.dynamic-XNoRecordWildCards
-XRecordPunsEnable record puns.dynamic-XNoRecordPuns
-XDisambiguateRecordFieldsEnable record field disambiguation. dynamic-XNoDisambiguateRecordFields
-XUnboxedTuplesEnable unboxed tuples.dynamic-XNoUnboxedTuples
-XStandaloneDerivingEnable standalone deriving.dynamic-XNoStandaloneDeriving
-XDeriveDataTypeableEnable deriving for the Data and Typeable classes.dynamic-XNoDeriveDataTypeable
-XGeneralizedNewtypeDerivingEnable newtype deriving.dynamic-XNoGeneralizedNewtypeDeriving
-XTypeSynonymInstancesEnable type synonyms.dynamic-XNoTypeSynonymInstances
-XFlexibleContextsEnable flexible contexts.dynamic-XNoFlexibleContexts
-XFlexibleInstancesEnable flexible instances.dynamic-XNoFlexibleInstances
-XConstrainedClassMethodsEnable constrained class methods.dynamic-XNoConstrainedClassMethods
-XMultiParamTypeClassesEnable multi parameter type classes.dynamic-XNoMultiParamTypeClasses
-XFunctionalDependenciesEnable functional dependencies.dynamic-XNoFunctionalDependencies

5.17.13. Warnings

Section 5.7, “Warnings and sanity-checking”

FlagDescriptionStatic/DynamicReverse
-Wenable normal warningsdynamic-w
-wdisable all warningsdynamic-
-Wallenable almost all warnings (details in Section 5.7, “Warnings and sanity-checking”)dynamic-w
-Werrormake warnings fataldynamic-Wwarn
-Wwarnmake warnings non-fataldynamic-Werror
-fwarn-deprecationswarn about uses of functions & types that are deprecateddynamic-fno-warn-deprecations
-fwarn-duplicate-exportswarn when an entity is exported multiple timesdynamic-fno-warn-duplicate-exports
-fwarn-hi-shadowingwarn when a .hi file in the current directory shadows a librarydynamic-fno-warn-hi-shadowing
-fwarn-implicit-preludewarn when the Prelude is implicitly importeddynamic-fno-warn-implicit-prelude
-fwarn-incomplete-patternswarn when a pattern match could faildynamic-fno-warn-incomplete-patterns
-fwarn-incomplete-record-updateswarn when a record update could faildynamic-fno-warn-incomplete-record-updates
-fwarn-missing-fieldswarn when fields of a record are uninitialiseddynamic-fno-warn-missing-fields
-fwarn-missing-methodswarn when class methods are undefineddynamic-fno-warn-missing-methods
-fwarn-missing-signatureswarn about top-level functions without signaturesdynamic-fno-warn-missing-signatures
-fwarn-name-shadowingwarn when names are shadoweddynamic-fno-warn-name-shadowing
-fwarn-orphanswarn when the module contains orphan instance declarations or rewrite rulesdynamic-fno-warn-orphans
-fwarn-overlapping-patternswarn about overlapping patternsdynamic-fno-warn-overlapping-patterns
-fwarn-simple-patternswarn about lambda-patterns that can faildynamic-fno-warn-simple-patterns
-fwarn-tabswarn if there are tabs in the source filedynamic-fno-warn-tabs
-fwarn-type-defaultswarn when defaulting happensdynamic-fno-warn-type-defaults
-fwarn-monomorphism-restrictionwarn when the Monomorphism Restriction is applieddynamic-fno-warn-monomorphism-restriction
-fwarn-unused-bindswarn about bindings that are unuseddynamic-fno-warn-unused-binds
-fwarn-unused-importswarn about unnecessary importsdynamic-fno-warn-unused-imports
-fwarn-unused-matcheswarn about variables in patterns that aren't useddynamic-fno-warn-unused-matches

5.17.14. Optimisation levels

Section 5.9, “Optimisation (code improvement)”

FlagDescriptionStatic/DynamicReverse
-OEnable default optimisation (level 1)dynamic-O0
-OnSet optimisation level ndynamic-O0

5.17.15. Individual optimisations

Section 5.9.2, “-f*: platform-independent flags”

FlagDescriptionStatic/DynamicReverse
-fcase-mergeEnable case-merging. Implied by -O.dynamic-fno-case-merge
-fdicts-strictMake dictionaries strictstatic-fno-dicts-strict
-fdo-eta-reductionEnable eta-reduction. Implied by -O.dynamic-fno-do-eta-reduction
-fdo-lambda-eta-expansionEnable lambda eta-reductiondynamic-fno-do-lambda-eta-expansion
-fexcess-precisionEnable excess intermediate precisiondynamic-fno-excess-precision
-fignore-assertsIgnore assertions in the sourcedynamic-fno-ignore-asserts
-fignore-interface-pragmasIgnore pragmas in interface filesdynamic-fno-ignore-interface-pragmas
-fomit-interface-pragmasDon't generate interface pragmasdynamic-fno-omit-interface-pragmas
-fmax-worker-argsIf a worker has that many arguments, none will be unpacked anymore (default: 10)static-
-fmax-simplifier-iterationsSet the max iterations for the simplifierdynamic-
-fno-state-hackTurn off the "state hack" whereby any lambda with a real-world state token as argument is considered to be single-entry. Hence OK to inline things inside it.static-
-fcseTurn on common sub-expression elimination. Implied by -O.dynamic-fno-cse
-ffull-lazinessTurn on full laziness (floating bindings outwards). Implied by -O.dynamic-fno-full-laziness
-frewrite-rulesSwitch on all rewrite rules (including rules generated by automatic specialisation of overloaded functions). Implied by -O. dynamic-fno-rewrite-rules
-fstrictnessTurn on strictness analysis. Implied by -O.dynamic-fno-strictness
-fspec-constrTurn on the SpecConstr transformation. Implied by -O2.dynamic-fno-spec-constr
-fliberate-caseTurn on the liberate-case transformation. Implied by -O2.dynamic-fno-liberate-case
-fspec-threshold=nSet the size threshold for function specialisation to n, for both the liberate-case and SpecConstr transformations (default: 200)static-
-funbox-strict-fieldsFlatten strict constructor fieldsdynamic-fno-unbox-strict-fields
-funfolding-creation-thresholdTweak unfolding settingsstatic-fno-unfolding-creation-threshold
-funfolding-fun-discountTweak unfolding settingsstatic-fno-unfolding-fun-discount
-funfolding-keeness-factorTweak unfolding settingsstatic-fno-unfolding-keeness-factor
-funfolding-update-in-placeTweak unfolding settingsstatic-fno-unfolding-update-in-place
-funfolding-use-thresholdTweak unfolding settingsstatic-fno-unfolding-use-threshold
-fno-pre-inliningTurn off pre-inliningstatic-

5.17.16. Profiling options

Chapter 6, Profiling

FlagDescriptionStatic/DynamicReverse
-autoAuto-add _scc_s to all exported functionsstatic-no-auto
-auto-allAuto-add _scc_s to all top-level functionsstatic-no-auto-all
-caf-allAuto-add _scc_s to all CAFsstatic-no-caf-all
-profTurn on profilingstatic-
-tickyTurn on ticky-ticky profilingstatic-

5.17.17. Program coverage options

Section 6.6, “Observing Code Coverage”

FlagDescriptionStatic/DynamicReverse
-fhpcTurn on Haskell program coverage instrumentationstatic-
-hpcdir dirDirectory to deposit .mix files during compilation (default is .hpc)dynamic-

5.17.18. Haskell pre-processor options

Section 5.10.4, “Options affecting a Haskell pre-processor”

FlagDescriptionStatic/DynamicReverse
-F Enable the use of a pre-processor (set with -pgmF) dynamic-

5.17.19. C pre-processor options

Section 5.10.3, “Options affecting the C pre-processor”

FlagDescriptionStatic/DynamicReverse
-cppRun the C pre-processor on Haskell source filesdynamic-
-Dsymbol[=value]Define a symbol in the C pre-processordynamic-Usymbol
-UsymbolUndefine a symbol in the C pre-processordynamic-
-IdirAdd dir to the directory search list for #include filesdynamic-

5.17.20. C compiler options

Section 5.10.5, “Options affecting the C compiler (if applicable)”

FlagDescriptionStatic/DynamicReverse
-#include fileInclude file when compiling the .hc filedynamic-

5.17.21. Code generation options

Section 5.10.6, “Options affecting code generation”

FlagDescriptionStatic/DynamicReverse
-fasmUse the native code generatordynamic-fvia-C
-fvia-CCompile via Cdynamic-fasm
-fno-codeOmit code generationdynamic-
-fbyte-codeGenerate byte-codedynamic-
-fobject-codeGenerate object codedynamic-

5.17.22. Linking options

Section 5.10.7, “Options affecting linking”

FlagDescriptionStatic/DynamicReverse
-fPICGenerate position-independent code (where available)static-
-dynamicUse dynamic Haskell libraries (if available)static-
-framework nameOn Darwin/MacOS X only, link in the framework name. This option corresponds to the -framework option for Apple's Linker.dynamic-
-framework-path nameOn Darwin/MacOS X only, add dir to the list of directories searched for frameworks. This option corresponds to the -F option for Apple's Linker.dynamic-
-llibLink in library libdynamic-
-LdirAdd dir to the list of directories searched for librariesdynamic-
-main-isSet main module and functiondynamic-
--mk-dllDLL-creation mode (Windows only)dynamic-
-no-hs-mainDon't assume this program contains maindynamic-
-no-linkOmit linkingdynamic-
-split-objsSplit objects (for libraries)dynamic-
-staticUse static Haskell librariesstatic-
-threadedUse the threaded runtimestatic-
-debugUse the debugging runtimestatic-
-fno-gen-manifestDo not generate a manifest file (Windows only)dynamic-
-fno-embed-manifestDo not embed the manifest in the executable (Windows only)dynamic-

5.17.23. Replacing phases

Section 5.10.1, “Replacing the program for one or more phases”

FlagDescriptionStatic/DynamicReverse
-pgmL cmdUse cmd as the literate pre-processordynamic-
-pgmP cmdUse cmd as the C pre-processor (with -cpp only)dynamic-
-pgmc cmdUse cmd as the C compilerdynamic-
-pgmm cmdUse cmd as the manglerdynamic-
-pgms cmdUse cmd as the splitterdynamic-
-pgma cmdUse cmd as the assemblerdynamic-
-pgml cmdUse cmd as the linkerdynamic-
-pgmdll cmdUse cmd as the DLL generatordynamic-
-pgmF cmdUse cmd as the pre-processor (with -F only)dynamic-
-pgmwindres cmdUse cmd as the program for embedding manifests on Windows.dynamic-

5.17.24. Forcing options to particular phases

Section 5.10.2, “Forcing options to a particular phase”

FlagDescriptionStatic/DynamicReverse
-optL optionpass option to the literate pre-processordynamic-
-optP optionpass option to cpp (with -cpp only)dynamic-
-optF optionpass option to the custom pre-processordynamic-
-optc optionpass option to the C compilerdynamic-
-optm optionpass option to the manglerdynamic-
-opta optionpass option to the assemblerdynamic-
-optl optionpass option to the linkerdynamic-
-optdll optionpass option to the DLL generatordynamic-
-optdep optionpass option to the dependency generatordynamic-
-optwindres optionpass option to windres.dynamic-

5.17.25. Platform-specific options

Section 5.13, “Platform-specific Flags”

FlagDescriptionStatic/DynamicReverse
-monly-[432]-regs(x86 only) give some registers back to the C compilerdynamic-

5.17.26. External core file options

Section 5.15, “Generating and compiling External Core Files”

FlagDescriptionStatic/DynamicReverse
-fext-coreGenerate .hcr external Core filesstatic-

5.17.27. Compiler debugging options

Section 5.16, “Debugging the compiler”

FlagDescriptionStatic/DynamicReverse
-dcore-lintTurn on internal sanity checkingdynamic-
-ddump-asmDump assemblydynamic-
-ddump-bcosDump interpreter byte codedynamic-
-ddump-cmmDump C-- outputdynamic-
-ddump-cpranalDump output from CPR analysisdynamic-
-ddump-cseDump CSE outputdynamic-
-ddump-derivDump deriving outputdynamic-
-ddump-dsDump desugarer outputdynamic-
-ddump-flatCDump “flat” Cdynamic-
-ddump-foreignDump foreign export stubsdynamic-
-ddump-hpcDump after instrumentation for program coveragedynamic-
-ddump-inliningsDump inlining infodynamic-
-ddump-occur-analDump occurrence analysis outputdynamic-
-ddump-opt-cmmDump the results of C-- to C-- optimising passesdynamic-
-ddump-parsedDump parse treedynamic-
-ddump-prepDump prepared coredynamic-
-ddump-rnDump renamer outputdynamic-
-ddump-rulesDump rulesdynamic-
-ddump-simplDump final simplifier outputdynamic-
-ddump-simpl-iterationsDump output from each simplifier iterationdynamic-
-ddump-specDump specialiser outputdynamic-
-ddump-splicesDump TH spliced expressions, and what they evaluate todynamic-
-ddump-stgDump final STGdynamic-
-ddump-stranalDump strictness analyser outputdynamic-
-ddump-tcDump typechecker outputdynamic-
-ddump-typesDump type signaturesdynamic-
-ddump-worker-wrapperDump worker-wrapper outputdynamic-
-ddump-if-traceTrace interface filesdynamic-
-ddump-tc-traceTrace typecheckerdynamic-
-ddump-rn-traceTrace renamerdynamic-
-ddump-rn-statsRenamer statsdynamic-
-ddump-simpl-statsDump simplifier statsdynamic-
-dppr-debugTurn on debug printing (more verbose)static-
-dppr-nopragsDon't output pragma info in dumpsstatic-
-dppr-user-lengthSet the depth for printing expressions in error msgsstatic-
-dsource-statsDump haskell source statsdynamic-
-dcmm-lintC-- pass sanity checkingdynamic-
-dstg-lintSTG pass sanity checkingdynamic-
-dstg-statsDump STG statsdynamic-
-dverbose-core2coreShow output from each core-to-core passdynamic-
-dverbose-stg2stgShow output from each STG-to-STG passdynamic-
-dshow-passesPrint out each pass name as it happensdynamic-
-dfaststring-statsShow statistics for fast string usage when finisheddynamic-
-unregEnable unregisterised compilationstatic-

5.17.28. Misc compiler options

FlagDescriptionStatic/DynamicReverse
-fno-hi-version-checkDon't complain about .hi file mismatchesstatic-
-dno-black-holingTurn off black holing (probably doesn't work)static-
-fno-method-sharingDon't share specialisations of overloaded functionsstatic-
-fhistory-sizeSet simplification history sizestatic-
-funregisterisedUnregisterised compilation (use -unreg instead)static-
-fno-asm-manglingTurn off assembly mangling (use -unreg instead)dynamic-