ghc - the Glasgow Haskell Compiler
ghc [option|filename]
ghci [option|filename]
This manual page documents briefly the ghc and ghci
commands. Note that ghci is not yet available on all architectures.
Extensive documentation is available in various other formats including
PDF
<https://downloads.haskell.org/ghc/latest/docs/users_guide.pdf>
and HTML
<https://downloads.haskell.org/ghc/latest/docs/html/>.
Each of GHC's command line options is classified as either
static or dynamic. A static flag may only be specified on the
command line, whereas a dynamic flag may also be given in an OPTIONS
pragma in a source file or set from the GHCi command-line with :set
.
As a rule of thumb, all the language options are dynamic, as are
the warning options and the debugging options.
The rest are static, with the notable exceptions of -v,
-cpp, -fasm, -fvia-C, -fllvm, and
-#include. The OPTIONS sections lists the status of each flag.
Common suffixes of file names for Haskell are:
- .hs
- Haskell source code; preprocess, compile
- .lhs
- literate Haskell source; unlit, preprocess, compile
- .hi
- Interface file; contains information about exported symbols
- .hc
- intermediate C files
- .⟨way⟩_o
- object files for "way" ⟨way⟩; common ways
are:
- dyn
- dynamically-linked
- p
- built with profiling
- .⟨way⟩_hi
- interface files for "way" ⟨way⟩; common ways
are:
- Code
generation
- -dynamic-too -fasm -fllvm -fbyte-code
-fexternal-dynamic-refs -fllvm -fasm -fno-code
-fobject-code -fPIC -fPIE
-fwrite-interface
- Debugging the
compiler
- -dcmm-lint -dcore-lint -ddump-asm
-ddump-asm-expanded -ddump-asm-liveness
-ddump-asm-native -ddump-asm-regalloc
-ddump-asm-regalloc-stages -ddump-asm-stats
-ddump-bcos -ddump-cfg-weights -ddump-cmm
-ddump-cmm-caf -ddump-cmm-cbe -ddump-cmm-cfg
-ddump-cmm-cps -ddump-cmm-from-stg -ddump-cmm-info
-ddump-cmm-opt -ddump-cmm-proc -ddump-cmm-procmap
-ddump-cmm-raw -ddump-cmm-sink -ddump-cmm-sp
-ddump-cmm-split -ddump-cmm-switch -ddump-cmm-verbose
-ddump-cmm-verbose-by-proc -ddump-core-stats
-ddump-cpr-signatures -ddump-cpranal -ddump-cse
-ddump-deriv -ddump-ds -ddump-ds-preopt
-ddump-ec-trace -ddump-file-prefix=⟨str⟩
-ddump-foreign -ddump-hie -ddump-hpc
-ddump-if-trace -ddump-inlinings -ddump-json
-ddump-llvm -ddump-mod-map -ddump-occur-anal
-ddump-opt-cmm -ddump-parsed -ddump-parsed-ast
-ddump-prep -ddump-rn -ddump-rn-ast
-ddump-rn-stats -ddump-rn-trace -ddump-rtti
-ddump-rule-firings -ddump-rule-rewrites -ddump-rules
-ddump-simpl -ddump-simpl-iterations
-ddump-simpl-stats -ddump-spec -ddump-splices
-ddump-stg -ddump-stg-final -ddump-stg-unarised
-ddump-str-signatures -ddump-stranal -ddump-tc
-ddump-tc-ast -ddump-tc-trace -ddump-ticked
-ddump-timings -ddump-to-file -ddump-types
-ddump-verbose-inlinings -ddump-worker-wrapper
-dfaststring-stats -dhex-word-literals
-dinitial-unique=⟨s⟩
-dinline-check=⟨str⟩ -dlinear-core-lint
-dno-debug-output -ddebug-output -dno-typeable-binds
-dppr-case-as-let -dppr-cols=⟨n⟩
-dppr-debug -dppr-user-length
-drule-check=⟨str⟩ -dshow-passes
-dstg-lint -dsuppress-all -dsuppress-coercions
-dsuppress-idinfo -dsuppress-module-prefixes
-dsuppress-stg-free-vars -dsuppress-ticks
-dsuppress-timestamps -dsuppress-type-applications
-dsuppress-type-signatures -dsuppress-unfoldings
-dsuppress-uniques -dsuppress-var-kinds -dth-dec-file
-dunique-increment=⟨i⟩ -dverbose-core2core
-dverbose-stg2stg -falignment-sanitisation
-fcatch-bottoms -fllvm-fill-undef-with-garbage
-fproc-alignment -g -g⟨n⟩
- C pre-processor
- -cpp -D⟨symbol⟩[=⟨value⟩]
-U⟨symbol⟩ -I⟨dir⟩
-U⟨symbol⟩
- Finding
imports
- -i -i⟨dir⟩[:⟨dir⟩]*
- Interactive
mode
- -fbreak-on-error -fno-break-on-error
-fbreak-on-exception -fno-break-on-exception
-fghci-hist-size=⟨n⟩ -fghci-leak-check
-fno-ghci-leak-check -flocal-ghci-history
-fno-local-ghci-history -fno-it -fno-no-it
-fprint-bind-result -fno-print-bind-result
-fprint-evld-with-show -fshow-loaded-modules
-ghci-script -ignore-dot-ghci -interactive-print
⟨name⟩
- Interface
files
- --show-iface ⟨file⟩ -ddump-hi
-ddump-hi-diffs -ddump-minimal-imports
- Keeping intermediate
files
- -keep-hc-file -keep-hc-files -keep-hi-files
-no-keep-hi-files -keep-hscpp-file -keep-hscpp-files
-keep-llvm-file -keep-llvm-files -keep-o-files
-no-keep-o-files -keep-s-file -keep-s-files
-keep-tmp-files
- Language
options
- -XAllowAmbiguousTypes -XApplicativeDo -XArrows
-XBangPatterns -XBinaryLiterals -XBlockArguments
-XCApiFFI -XConstrainedClassMethods -XConstraintKinds
-XCPP -XCUSKs -XDataKinds -XDatatypeContexts
-XDefaultSignatures -XDeriveAnyClass
-XDeriveDataTypeable -XDeriveFoldable -XDeriveFunctor
-XDeriveGeneric -XDeriveLift -XDeriveTraversable
-XDerivingStrategies -XDerivingVia
-XDisambiguateRecordFields -XDuplicateRecordFields
-XEmptyCase -XEmptyDataDecls -XEmptyDataDeriving
-XExistentialQuantification -XExplicitForAll
-XExplicitNamespaces -XExtendedDefaultRules
-XFlexibleContexts -XFlexibleInstances
-XForeignFunctionInterface -XFunctionalDependencies
-XGADTs -XGADTSyntax -XGeneralisedNewtypeDeriving
-XGeneralizedNewtypeDeriving -XGHCForeignImportPrim
-XHaskell2010 -XHaskell98 -XHexFloatLiterals
-XImplicitParams -XImportQualifiedPost
-XImpredicativeTypes -XIncoherentInstances
-XInstanceSigs -XInterruptibleFFI -XKindSignatures
-XLambdaCase -XLexicalNegation -XLiberalTypeSynonyms
-XLinearTypes -XMagicHash -XMonadComprehensions
-XMonadFailDesugaring -XMonoLocalBinds
-XMultiParamTypeClasses -XMultiWayIf -XNamedFieldPuns
-XNamedWildCards -XNegativeLiterals
-XNoImplicitPrelude -XNoMonomorphismRestriction
-XNondecreasingIndentation -XNoPatternGuards
-XNoTraditionalRecordSyntax -XNPlusKPatterns
-XNullaryTypeClasses -XNumDecimals
-XNumericUnderscores -XOverlappingInstances
-XOverloadedLabels -XOverloadedLists
-XOverloadedStrings -XPackageImports
-XParallelListComp -XPartialTypeSignatures
-XPatternSynonyms -XPolyKinds -XPostfixOperators
-XQualifiedDo -XQuantifiedConstraints -XQuasiQuotes
-XRank2Types -XRankNTypes -XRebindableSyntax
-XRecordWildCards -XRecursiveDo -XRoleAnnotations
-XSafe -XScopedTypeVariables -XStandaloneDeriving
-XStandaloneKindSignatures -XStarIsType
-XStaticPointers -XStrict -XStrictData
-XTemplateHaskell -XTemplateHaskellQuotes
-XTransformListComp -XTrustworthy -XTupleSections
-XTypeApplications -XTypeFamilies
-XTypeFamilyDependencies -XTypeInType -XTypeOperators
-XTypeSynonymInstances -XUnboxedSums -XUnboxedTuples
-XUndecidableInstances -XUndecidableSuperClasses
-XUnicodeSyntax -XUnliftedFFITypes -XUnliftedNewtypes
-XUnsafe -XViewPatterns
- Linking
options
- -c -debug -dylib-install-name ⟨path⟩
-dynamic -dynload -eventlog -fkeep-cafs
-flink-rts -fno-embed-manifest -fno-gen-manifest
-fno-shared-implib -framework ⟨name⟩
-framework-path ⟨dir⟩ -fuse-rpaths
-fno-use-rpaths -fwhole-archive-hs-libs -L
⟨dir⟩ -l ⟨lib⟩ -main-is
⟨thing⟩ -no-hs-main
-no-rtsopts-suggestions -package ⟨name⟩
-pie -rdynamic
-rtsopts[=⟨none|some|all|ignore|ignoreAll⟩]
-shared -split-sections -static -staticlib
-threaded -with-rtsopts=⟨opts⟩
- Miscellaneous
options
- -fexternal-interpreter -fglasgow-exts
-fno-glasgow-exts -fno-safe-haskell -ghcversion-file
⟨path to ghcversion.h⟩ -H ⟨size⟩
-j[⟨n⟩]
- Modes of
operation
- --frontend ⟨module⟩ --help -?
--info --interactive --make --mk-dll
--numeric-version --print-libdir --show-iface
⟨file⟩ --show-options
--supported-extensions --supported-languages
--version -V -e ⟨expr⟩ -M
- Individual
optimizations
- -fasm-shortcutting -fno-asm-shortcutting
-fbinary-blob-threshold=⟨n⟩ -fblock-layout-cfg
-fno-block-layout-cfg -fblock-layout-weightless
-fno-block-layout-weightless -fblock-layout-weights
-fcall-arity -fno-call-arity -fcase-folding
-fno-case-folding -fcase-merge -fno-case-merge
-fcmm-elim-common-blocks -fno-cmm-elim-common-blocks
-fcmm-sink -fno-cmm-sink -fcmm-static-pred
-fno-cmm-static-pred -fcpr-anal -fno-cpr-anal
-fcross-module-specialise -fno-cross-module-specialise
-fcse -fno-cse -fdicts-cheap -fno-dicts-cheap
-fdicts-strict -fno-dicts-strict -fdmd-tx-dict-sel
-fno-dmd-tx-dict-sel -fdo-eta-reduction
-fno-do-eta-reduction -fdo-lambda-eta-expansion
-fno-do-lambda-eta-expansion -feager-blackholing
-fenable-rewrite-rules -fno-enable-rewrite-rules
-fexcess-precision -fno-excess-precision
-fexitification -fno-exitification
-fexpose-all-unfoldings -fno-expose-all-unfoldings
-ffloat-in -fno-float-in -ffull-laziness
-fno-full-laziness -ffun-to-thunk -fno-fun-to-thunk
-fignore-asserts -fno-ignore-asserts
-fignore-interface-pragmas -fno-ignore-interface-pragmas
-flate-dmd-anal -fno-late-dmd-anal -flate-specialise
-fno-late-specialise -fliberate-case
-fno-liberate-case
-fliberate-case-threshold=⟨n⟩
-fno-liberate-case-threshold -fllvm-pass-vectors-in-regs
-fno-llvm-pass-vectors-in-regs -floopification
-fno-loopification -fmax-inline-alloc-size=⟨n⟩
-fmax-inline-memcpy-insns=⟨n⟩
-fmax-inline-memset-insns=⟨n⟩
-fmax-simplifier-iterations=⟨n⟩
-fmax-uncovered-patterns=⟨n⟩
-fmax-worker-args=⟨n⟩ -fno-opt-coercion
-fno-pre-inlining -fno-state-hack
-fomit-interface-pragmas -fno-omit-interface-pragmas
-fomit-yields -fno-omit-yields
-foptimal-applicative-do -fno-optimal-applicative-do
-fpedantic-bottoms -fno-pedantic-bottoms -fregs-graph
-fno-regs-graph -fregs-iterative -fno-regs-iterative
-fsimpl-tick-factor=⟨n⟩
-fsimplifier-phases=⟨n⟩ -fsolve-constant-dicts
-fno-solve-constant-dicts -fspec-constr
-fno-spec-constr -fspec-constr-count=⟨n⟩
-fno-spec-constr-count -fspec-constr-keen
-fno-spec-constr-keen
-fspec-constr-threshold=⟨n⟩
-fno-spec-constr-threshold -fspecialise
-fno-specialise -fspecialise-aggressively
-fno-specialise-aggressively
-fstatic-argument-transformation
-fno-static-argument-transformation -fstg-cse
-fno-stg-cse -fstg-lift-lams -fno-stg-lift-lams
-fstg-lift-lams-known -fno-stg-lift-lams-known
-fstg-lift-lams-non-rec-args
-fno-stg-lift-lams-non-rec-args-any -fstg-lift-lams-rec-args
-fno-stg-lift-lams-rec-args-any -fstrictness
-fno-strictness -fstrictness-before=⟨n⟩
-funbox-small-strict-fields -fno-unbox-small-strict-fields
-funbox-strict-fields -fno-unbox-strict-fields
-funfolding-creation-threshold=⟨n⟩
-funfolding-dict-discount=⟨n⟩
-funfolding-fun-discount=⟨n⟩
-funfolding-keeness-factor=⟨n⟩
-funfolding-use-threshold=⟨n⟩
-fworker-wrapper
- Optimization
levels
- -O -O1 -O0 -O0 -O2 -O0
-O⟨n⟩ -O0
- Package
options
- -clear-package-db -distrust ⟨pkg⟩
-distrust-all-packages -fpackage-trust
-global-package-db -hide-all-packages -hide-package
⟨pkg⟩ -ignore-package ⟨pkg⟩
-no-auto-link-packages -no-global-package-db
-no-user-package-db -package ⟨pkg⟩
-package-db ⟨file⟩ -package-env
⟨file⟩|⟨name⟩ -package-id
⟨unit-id⟩ -this-unit-id ⟨unit-id⟩
-trust ⟨pkg⟩ -user-package-db
- Phases of
compilation
- -C -c -E -F -S -x
⟨suffix⟩
- Overriding
external programs
- -pgma ⟨cmd⟩ -pgmc ⟨cmd⟩
-pgmdll ⟨cmd⟩ -pgmF ⟨cmd⟩
-pgmi ⟨cmd⟩ -pgminstall_name_tool
⟨cmd⟩ -pgmL ⟨cmd⟩ -pgml
⟨cmd⟩ -pgmlc ⟨cmd⟩ -pgmlibtool
⟨cmd⟩ -pgmlm ⟨cmd⟩ -pgmlo
⟨cmd⟩ -pgmotool ⟨cmd⟩ -pgmP
⟨cmd⟩ -pgms ⟨cmd⟩ -pgmwindres
⟨cmd⟩
- Phase-specific
options
- -opta ⟨option⟩ -optc ⟨option⟩
-optcxx ⟨option⟩ -optdll
⟨option⟩ -optF ⟨option⟩ -opti
⟨option⟩ -optL ⟨option⟩ -optl
⟨option⟩ -optlc ⟨option⟩ -optlm
⟨option⟩ -optlo ⟨option⟩ -optP
⟨option⟩ -optwindres ⟨option⟩
-pgmc-supports-no-pie
- Platform-specific
options
- -mbmi2 -msse2 -msse4.2
- Compiler
plugins
- -fclear-plugins
-fplugin-opt=⟨module⟩:⟨args⟩
-fplugin-trustworthy -fplugin=⟨module⟩
-hide-all-plugin-packages -plugin-package
⟨pkg⟩ -plugin-package-id
⟨pkg-id⟩
- Profiling
- -fno-prof-auto -fprof-auto -fno-prof-cafs
-fprof-cafs -fno-prof-count-entries
-fprof-count-entries -fprof-auto -fno-prof-auto
-fprof-auto-calls -fno-prof-auto-calls
-fprof-auto-exported -fno-prof-auto -fprof-auto-top
-fno-prof-auto -fprof-cafs -fno-prof-cafs
-prof -ticky
- Program
coverage
- -fhpc
- Recompilation
checking
- -fforce-recomp -fno-force-recomp -fignore-hpc-changes
-fno-ignore-hpc-changes -fignore-optim-changes
-fno-ignore-optim-changes
- Redirecting
output
- --exclude-module=⟨file⟩ -ddump-mod-cycles
-dep-makefile ⟨file⟩ -dep-suffix
⟨suffix⟩ -dumpdir ⟨dir⟩ -hcsuf
⟨suffix⟩ -hidir ⟨dir⟩ -hiedir
⟨dir⟩ -hiesuf ⟨suffix⟩ -hisuf
⟨suffix⟩ -include-cpp-deps
-include-pkg-deps -o ⟨file⟩ -odir
⟨dir⟩ -ohi ⟨file⟩ -osuf
⟨suffix⟩ -outputdir ⟨dir⟩
-stubdir ⟨dir⟩
- Temporary
files
- -tmpdir ⟨dir⟩
- Verbosity
options
- -fabstract-refinement-hole-fits
-fno-abstract-refinement-hole-fits -fdefer-diagnostics
-fdiagnostics-color=⟨always|auto|never⟩
-fdiagnostics-show-caret -fno-diagnostics-show-caret
-ferror-spans -fhide-source-paths -fkeep-going
-fmax-refinement-hole-fits=⟨n⟩
-fno-max-refinement-hole-fits
-fmax-relevant-binds=⟨n⟩
-fno-max-relevant-binds
-fmax-valid-hole-fits=⟨n⟩
-fno-max-valid-hole-fits -fno-show-valid-hole-fits
-fno-sort-valid-hole-fits -fsort-valid-hole-fits
-fprint-axiom-incomps -fno-print-axiom-incomps
-fprint-equality-relations -fno-print-equality-relations
-fprint-expanded-synonyms -fno-print-expanded-synonyms
-fprint-explicit-coercions -fno-print-explicit-coercions
-fprint-explicit-foralls -fno-print-explicit-foralls
-fprint-explicit-kinds -fno-print-explicit-kinds
-fprint-explicit-runtime-reps
-fno-print-explicit-runtime-reps -fprint-potential-instances
-fno-print-potential-instances
-fprint-typechecker-elaboration
-fno-print-typechecker-elaboration -fprint-unicode-syntax
-fno-print-unicode-syntax
-frefinement-level-hole-fits=⟨n⟩
-fno-refinement-level-hole-fits -freverse-errors
-fno-reverse-errors -fshow-docs-of-hole-fits
-fno-show-docs-of-hole-fits -fshow-hole-constraints
-fshow-hole-matches-of-hole-fits
-fno-show-hole-matches-of-hole-fits
-fshow-provenance-of-hole-fits
-fno-show-provenance-of-hole-fits
-fshow-type-app-of-hole-fits -fno-show-type-app-of-hole-fits
-fshow-type-app-vars-of-hole-fits
-fno-show-type-app-vars-of-hole-fits
-fshow-type-of-hole-fits -fno-type-of-hole-fits
-fsort-by-size-hole-fits -fno-sort-by-size-hole-fits
-fsort-by-subsumption-hole-fits
-fno-sort-by-subsumption-hole-fits
-funclutter-valid-hole-fits -Rghc-timing -v
-v⟨n⟩
- Warnings
- -fdefer-out-of-scope-variables
-fno-defer-out-of-scope-variables -fdefer-type-errors
-fno-defer-type-errors -fdefer-typed-holes
-fno-defer-typed-holes -fenable-th-splice-warnings
-fno-enable-th-splices -fhelpful-errors
-fno-helpful-errors -fmax-pmcheck-models=⟨n⟩
-fshow-warning-groups -fno-show-warning-groups
-fvia-C -W -w -w -Wall -w
-Wall-missed-specialisations -Wno-all-missed-specialisations
-Wauto-orphans -Wcompat -Wno-compat
-Wcompat-unqualified-imports -Wno-compat-unqualified-imports
-Wcpp-undef -Wdefault
-Wdeferred-out-of-scope-variables
-Wno-deferred-out-of-scope-variables -Wdeferred-type-errors
-Wno-deferred-type-errors -Wdeprecated-flags
-Wno-deprecated-flags -Wdeprecations
-Wno-deprecations -Wderiving-defaults
-Wno-deriving-defaults -Wderiving-typeable
-Wno-deriving-typeable -Wdodgy-exports
-Wno-dodgy-exports -Wdodgy-foreign-imports
-Wno-dodgy-foreign-import -Wdodgy-imports
-Wno-dodgy-imports -Wduplicate-constraints
-Wno-duplicate-constraints -Wduplicate-exports
-Wno-duplicate-exports -Wempty-enumerations
-Wno-empty-enumerations -Werror -Wwarn
-Weverything -Whi-shadowing -Wno-hi-shadowing
-Widentities -Wno-identities -Wimplicit-kind-vars
-Wno-implicit-kind-vars -Wimplicit-prelude
-Wno-implicit-prelude -Winaccessible-code
-Wno-inaccessible-code -Wincomplete-patterns
-Wno-incomplete-patterns -Wincomplete-record-updates
-Wno-incomplete-record-updates -Wincomplete-uni-patterns
-Wno-incomplete-uni-patterns -Winferred-safe-imports
-Wno-inferred-safe-imports -Winline-rule-shadowing
-Wno-inline-rule-shadowing -Winvalid-haddock
-Wmissed-extra-shared-lib -Wno-missed-extra-shared-lib
-Wmissed-specialisations -Wno-missed-specialisations
-Wmissing-deriving-strategies
-Wno-missing-deriving-strategies -Wmissing-export-lists
-fnowarn-missing-export-lists -Wmissing-exported-signatures
-Wno-missing-exported-signatures -Wmissing-exported-sigs
-Wno-missing-exported-sigs -Wmissing-fields
-Wno-missing-fields -Wmissing-home-modules
-Wno-missing-home-modules -Wmissing-import-lists
-fnowarn-missing-import-lists -Wmissing-local-signatures
-Wno-missing-local-signatures -Wmissing-local-sigs
-Wno-missing-local-sigs -Wmissing-methods
-Wno-missing-methods -Wmissing-monadfail-instances
-Wno-missing-monadfail-instances
-Wmissing-pattern-synonym-signatures
-Wno-missing-pattern-synonym-signatures
-Wmissing-safe-haskell-mode -Wno-missing-safe-haskell-mode
-Wmissing-signatures -Wno-missing-signatures
-Wmissing-space-after-bang -Wmonomorphism-restriction
-Wno-monomorphism-restriction -Wname-shadowing
-Wno-name-shadowing -Wno-compat -Wcompat
-Wnoncanonical-monad-instances
-Wno-noncanonical-monad-instances
-Wnoncanonical-monadfail-instances
-Wno-noncanonical-monadfail-instances
-Wnoncanonical-monoid-instances
-Wno-noncanonical-monoid-instances -Worphans
-Wno-orphans -Woverflowed-literals
-Wno-overflowed-literals -Woverlapping-patterns
-Wno-overlapping-patterns -Wpartial-fields
-Wno-partial-fields -Wpartial-type-signatures
-Wno-partial-type-signatures -Wredundant-constraints
-Wno-redundant-constraints -Wredundant-record-wildcards
-Wno-redundant-record-wildcards -Wsafe -Wno-safe
-Wsemigroup -Wno-semigroup
-Wsimplifiable-class-constraints
-Wno-simplifiable-class-constraints -Wstar-binder
-Wno-star-binder -Wstar-is-type -Wno-star-is-type
-Wtabs -Wno-tabs -Wtrustworthy-safe -Wno-safe
-Wtype-defaults -Wno-type-defaults -Wtyped-holes
-Wno-typed-holes -Wunbanged-strict-patterns
-Wno-unbanged-strict-patterns
-Wunicode-bidirectional-format-characters
-Wunrecognised-pragmas -Wno-unrecognised-pragmas
-Wunrecognised-warning-flags -Wno-unrecognised-warning-flags
-Wunsafe -Wno-unsafe
-Wunsupported-calling-conventions
-Wno-unsupported-calling-conventions
-Wunsupported-llvm-version -Wno-monomorphism-restriction
-Wunticked-promoted-constructors
-Wno-unticked-promoted-constructors -Wunused-binds
-Wno-unused-binds -Wunused-do-bind
-Wno-unused-do-bind -Wunused-foralls
-Wno-unused-foralls -Wunused-imports
-Wno-unused-imports -Wunused-local-binds
-Wno-unused-local-binds -Wunused-matches
-Wno-unused-matches -Wunused-packages
-Wno-unused-packages -Wunused-pattern-binds
-Wno-unused-pattern-binds -Wunused-record-wildcards
-Wno-unused-record-wildcards -Wunused-top-binds
-Wno-unused-top-binds -Wunused-type-patterns
-Wno-unused-type-patterns -Wwarn -Werror
-Wwarnings-deprecations -Wno-warnings-deprecations
-Wwrong-do-bind -Wno-wrong-do-bind
- -cpp
- Run the C pre-processor on Haskell source files
- -D⟨symbol⟩[=⟨value⟩]
- Define a symbol in the C pre-processor
- -I⟨dir⟩
- Add ⟨dir⟩ to the directory search list for #include
files
- -U⟨symbol⟩
- Undefine a symbol in the C pre-processor
- -i
- Empty the import directory list
- -i⟨dir⟩[:⟨dir⟩]*
- add ⟨dir⟩, ⟨dir2⟩, etc. to import path
- -c
- Stop after generating object (.o) file
- -debug
- Use the debugging runtime
- -dylib-install-name
⟨path⟩
- Set the install name (via -install_name passed to Apple's linker),
specifying the full install path of the library file. Any libraries or
executables that link with it later will pick up that path as their
runtime search location for it. (Darwin/OS X only)
- -dynamic
- Build dynamically-linked object files and executables
- -dynload
- Selects one of a number of modes for finding shared libraries at
runtime.
- -eventlog
- Enable runtime event tracing
- -fkeep-cafs
- Do not garbage-collect CAFs (top-level expressions) at runtime
- -flink-rts
- Link the runtime when generating a shared or static library
- -fno-embed-manifest
- Do not embed the manifest in the executable (Windows only)
- -fno-gen-manifest
- Do not generate a manifest file (Windows only)
- -fno-shared-implib
- Don't generate an import library for a DLL (Windows only)
- -framework
⟨name⟩
- On Darwin/OS X/iOS only, link in the framework ⟨name⟩. This
option corresponds to the -framework option for Apple's
Linker.
- -framework-path
⟨dir⟩
- On Darwin/OS X/iOS only, add ⟨dir⟩ to the list of
directories searched for frameworks. This option corresponds to the
-F option for Apple's Linker.
- -fuse-rpaths
- Set the rpath based on -L flags
- -fwhole-archive-hs-libs
- When linking a binary executable, this inserts the flag
-Wl,--whole-archive before any -l flags for Haskell
libraries, and -Wl,--no-whole-archive afterwards
- -L
⟨dir⟩
- Add ⟨dir⟩ to the list of directories searched for
libraries
- -l
⟨lib⟩
- Link in library ⟨lib⟩
- -main-is
⟨thing⟩
- Set main module and function
- -no-hs-main
- Don't assume this program contains main
- -no-rtsopts-suggestions
- Don't print RTS suggestions about linking with
-rtsopts[=⟨none|some|all|ignore|ignoreAll⟩].
- -package
⟨name⟩
- Expose package ⟨pkg⟩
- -pie
- Instruct the linker to produce a position-independent executable.
- -rdynamic
- This instructs the linker to add all symbols, not only used ones, to the
dynamic symbol table. Currently Linux and Windows/MinGW32 only. This is
equivalent to using -optl -rdynamic on Linux, and -optl
-export-all-symbols on Windows.
- -rtsopts[=⟨none|some|all|ignore|ignoreAll⟩]
- Control whether the RTS behaviour can be tweaked via command-line flags
and the GHCRTS environment variable. Using none means no RTS
flags can be given; some means only a minimum of safe options can
be given (the default); all (or no argument at all) means that all
RTS flags are permitted; ignore means RTS flags can be given, but
are treated as regular arguments and passed to the Haskell program as
arguments; ignoreAll is the same as ignore, but
GHCRTS is also ignored. -rtsopts does not affect
-with-rtsopts behavior; flags passed via -with-rtsopts are
used regardless of -rtsopts.
- -shared
- Generate a shared library (as opposed to an executable)
- -split-sections
- Split sections for link-time dead-code stripping
- -static
- Use static Haskell libraries
- -staticlib
- Generate a standalone static library (as opposed to an executable). This
is useful when cross compiling. The library together with all its
dependencies ends up in in a single static library that can be linked
against.
- -threaded
- Use the threaded runtime
- -with-rtsopts=⟨opts⟩
- Set the default RTS options to ⟨opts⟩.
- --frontend
⟨module⟩
- run GHC with the given frontend plugin; see Frontend plugins for
details.
- --help
- Display help
- --info
- display information about the compiler
- --interactive
- Interactive mode - normally used by just running ghci; see Using
GHCi for details.
- --make
- Build a multi-module Haskell program, automatically figuring out
dependencies. Likely to be much easier, and faster, than using
make; see Using ghc --make for details.
- --mk-dll
- DLL-creation mode (Windows only)
- --numeric-version
- display GHC version (numeric only)
- --print-libdir
- display GHC library directory
- --show-iface
⟨file⟩
- display the contents of an interface file.
- --show-options
- display the supported command line options
- --supported-extensions
- display the supported language extensions
- --version
- display GHC version
- -e
⟨expr⟩
- Evaluate expr; see Expression evaluation mode for
details.
- -M
- generate dependency information suitable for use in a Makefile; see
Dependency generation for details.
- -O
- Enable level 1 optimisations
- -O0
- Disable optimisations (default)
- -O2
- Enable level 2 optimisations
- -O⟨n⟩
- Any -On where n > 2 is the same as -O2.
- -C
- Stop after generating C (.hc file)
- -c
- Stop after generating object (.o) file
- -E
- Stop after preprocessing (.hspp file)
- -F
- Enable the use of a pre-processor (set with -pgmF
⟨cmd⟩)
- -S
- Stop after generating assembly (.s file)
- -x
⟨suffix⟩
- Override default behaviour for source files
Platform-specific options
- -mbmi2
- (x86 only) Use BMI2 for bit manipulation operations
- -msse2
- (x86 only) Use SSE2 for floating-point operations
- -msse4.2
- (x86 only) Use SSE4.2 for floating-point operations
- -fhpc
- Turn on Haskell program coverage instrumentation
- -fforce-recomp
- Turn off recompilation checking. This is implied by any -ddump-X
option when compiling a single file (i.e. when using -c).
- -fignore-hpc-changes
- Do not recompile modules just to match changes to HPC flags. This is
especially useful for avoiding recompilation when using GHCi, and is
enabled by default for GHCi.
- -fignore-optim-changes
- Do not recompile modules just to match changes to optimisation flags. This
is especially useful for avoiding recompilation when using GHCi, and is
enabled by default for GHCi.
- -fdefer-out-of-scope-variables
- Convert variable out of scope variables errors into warnings. Implied by
-fdefer-type-errors. See also
-Wdeferred-out-of-scope-variables.
- -fdefer-type-errors
- Turn type errors into warnings, deferring the error until
runtime. Implies -fdefer-typed-holes and
-fdefer-out-of-scope-variables. See also
-Wdeferred-type-errors
- -fdefer-typed-holes
- Convert typed hole errors into warnings, deferring the error
until runtime. Implied by -fdefer-type-errors. See also
-Wtyped-holes.
- -fenable-th-splice-warnings
- Generate warnings for Template Haskell splices
- -fhelpful-errors
- Make suggestions for mis-spelled names.
- -fmax-pmcheck-models=⟨n⟩
- soft limit on the number of parallel models the pattern match checker
should check a pattern match clause against
- -fshow-warning-groups
- show which group an emitted warning belongs to.
- -fvia-C
- use the C code generator
- -W
- enable normal warnings
- -w
- disable all warnings
- -Wall
- enable almost all warnings (details in Warnings and
sanity-checking)
- -Wall-missed-specialisations
- warn when specialisation of any overloaded function fails.
- -Wauto-orphans
- (deprecated) Does nothing
- -Wcompat
- enable future compatibility warnings (details in Warnings and
sanity-checking)
- -Wcompat-unqualified-imports
- Report unqualified imports of core libraries which are expected to cause
compatibility problems in future releases.
- -Wcpp-undef
- warn on uses of the #if directive on undefined identifiers
- -Wdefault
- enable default flags
- -Wdeferred-out-of-scope-variables
- Report warnings when variable out-of-scope errors are deferred until
runtime. See -fdefer-out-of-scope-variables.
- -Wdeferred-type-errors
- Report warnings when deferred type errors are enabled. This option
is enabled by default. See -fdefer-type-errors.
- -Wdeprecated-flags
- warn about uses of commandline flags that are deprecated
- -Wdeprecations
- warn about uses of functions & types that have warnings or deprecated
pragmas. Alias for -Wwarnings-deprecations
- -Wderiving-defaults
- warn about default deriving when using both DeriveAnyClass and
GeneralizedNewtypeDeriving
- -Wderiving-typeable
- warn when Typeable is derived
- -Wdodgy-exports
- warn about dodgy exports
- -Wdodgy-foreign-imports
- warn about dodgy foreign imports
- -Wdodgy-imports
- warn about dodgy imports
- -Wduplicate-constraints
- warn when a constraint appears duplicated in a type signature
- -Wduplicate-exports
- warn when an entity is exported multiple times
- -Wempty-enumerations
- warn about enumerations that are empty
- -Werror
- make warnings fatal
- -Weverything
- enable all warnings supported by GHC
- -Whi-shadowing
- (deprecated) warn when a .hi file in the current directory
shadows a library
- -Widentities
- warn about uses of Prelude numeric conversions that are probably the
identity (and hence could be omitted)
- -Wimplicit-kind-vars
- warn when kind variables are implicitly quantified over.
- -Wimplicit-prelude
- warn when the Prelude is implicitly imported
- -Winaccessible-code
- warn about inaccessible code
- -Wincomplete-patterns
- warn when a pattern match could fail
- -Wincomplete-record-updates
- warn when a record update could fail
- -Wincomplete-uni-patterns
- warn when a pattern match in a lambda expression or pattern binding could
fail
- -Winferred-safe-imports
- warn when an explicitly Safe Haskell module imports a Safe-Inferred
one
- -Winline-rule-shadowing
- Warn if a rewrite RULE might fail to fire because the function might be
inlined before the rule has a chance to fire. See How rules interact
with INLINE/NOINLINE pragmas.
- -Winvalid-haddock
- warn when a Haddock comment occurs in an invalid position
- -Wmissed-extra-shared-lib
- Warn when GHCi can't load a shared lib.
- -Wmissed-specialisations
- warn when specialisation of an imported, overloaded function fails.
- -Wmissing-deriving-strategies
- warn when a deriving clause is missing a deriving strategy
- -Wmissing-export-lists
- warn when a module declaration does not explicitly list all exports
- -Wmissing-exported-signatures
- warn about top-level functions without signatures, only if they are
exported. takes precedence over -Wmissing-signatures
- -Wmissing-exported-sigs
- (deprecated) warn about top-level functions without signatures,
only if they are exported. takes precedence over -Wmissing-signatures
- -Wmissing-fields
- warn when fields of a record are uninitialised
- -Wmissing-home-modules
- warn when encountering a home module imported, but not listed on the
command line. Useful for cabal to ensure GHC won't pick up modules, not
listed neither in exposed-modules, nor in
other-modules.
- -Wmissing-import-lists
- warn when an import declaration does not explicitly list all the names
brought into scope
- -Wmissing-local-signatures
- warn about polymorphic local bindings without signatures
- -Wmissing-local-sigs
- (deprecated) warn about polymorphic local bindings without
signatures
- -Wmissing-methods
- warn when class methods are undefined
- -Wmissing-monadfail-instances
- Warn when a failable pattern is used in a do-block that does not have a
MonadFail instance.
- -Wmissing-pattern-synonym-signatures
- warn when pattern synonyms do not have type signatures
- -Wmissing-safe-haskell-mode
- warn when the Safe Haskell mode is not explicitly specified.
- -Wmissing-signatures
- warn about top-level functions without signatures
- -Wmissing-space-after-bang
- (deprecated) Does nothing
- -Wmonomorphism-restriction
- warn when the Monomorphism Restriction is applied
- -Wname-shadowing
- warn when names are shadowed
- -Wno-compat
- Disables all warnings enabled by -Wcompat.
- -Wnoncanonical-monad-instances
- warn when Applicative or Monad instances have noncanonical
definitions of return, pure, (>>), or
(*>). See flag description in Warnings and
sanity-checking for more details.
- -Wnoncanonical-monadfail-instances
- warn when Monad or MonadFail instances have noncanonical
definitions of fail. See flag description in Warnings and
sanity-checking for more details.
- -Wnoncanonical-monoid-instances
- warn when Semigroup or Monoid instances have noncanonical
definitions of (<>) or mappend. See flag description
in Warnings and sanity-checking for more details.
- -Worphans
- warn when the module contains orphan instance declarations or
rewrite rules
- -Woverflowed-literals
- warn about literals that will overflow their type
- -Woverlapping-patterns
- warn about overlapping patterns
- -Wpartial-fields
- warn when defining a partial record field.
- -Wpartial-type-signatures
- warn about holes in partial type signatures when
PartialTypeSignatures is enabled. Not applicable when
PartialTypeSignatures is not enabled, in which case errors are
generated for such holes.
- -Wredundant-constraints
- Have the compiler warn about redundant constraints in type
signatures.
- -Wredundant-record-wildcards
- Warn about record wildcard matches when the wildcard binds no
patterns.
- -Wsafe
- warn if the module being compiled is regarded to be safe.
- -Wsemigroup
- warn when a Monoid is not Semigroup, and on non-
Semigroup definitions of (<>)?
- -Wsimplifiable-class-constraints
- Warn about class constraints in a type signature that can be simplified
using a top-level instance declaration.
- -Wstar-binder
- warn about binding the (*) type operator despite
StarIsType
- -Wstar-is-type
- warn when * is used to mean Data.Kind.Type
- -Wtabs
- warn if there are tabs in the source file
- -Wtrustworthy-safe
- warn if the module being compiled is marked as Trustworthy but it
could instead be marked as Safe, a more informative bound.
- -Wtype-defaults
- warn when defaulting happens
- -Wtyped-holes
- Report warnings when typed hole errors are deferred until
runtime. See -fdefer-typed-holes.
- -Wunbanged-strict-patterns
- warn on pattern bind of unlifted variable that is neither bare nor
banged
- -Wunicode-bidirectional-format-characters
- warn about the usage of unicode bidirectional layout override
characters
- -Wunrecognised-pragmas
- warn about uses of pragmas that GHC doesn't recognise
- -Wunrecognised-warning-flags
- throw a warning when an unrecognised -W... flag is encountered on
the command line.
- -Wunsafe
- warn if the module being compiled is regarded to be unsafe. See Safe
Haskell
- -Wunsupported-calling-conventions
- warn about use of an unsupported calling convention
- -Wunsupported-llvm-version
- Warn when using -fllvm with an unsupported version of LLVM.
- -Wunticked-promoted-constructors
- warn if promoted constructors are not ticked
- -Wunused-binds
- warn about bindings that are unused. Alias for -Wunused-top-binds,
-Wunused-local-binds and -Wunused-pattern-binds
- -Wunused-do-bind
- warn about do bindings that appear to throw away values of types other
than ()
- -Wunused-foralls
- warn about type variables in user-written forall\s that are
unused
- -Wunused-imports
- warn about unnecessary imports
- -Wunused-local-binds
- warn about local bindings that are unused
- -Wunused-matches
- warn about variables in patterns that aren't used
- -Wunused-packages
- warn when package is requested on command line, but was never loaded.
- -Wunused-pattern-binds
- warn about pattern match bindings that are unused
- -Wunused-record-wildcards
- Warn about record wildcard matches when none of the bound variables are
used.
- -Wunused-top-binds
- warn about top-level bindings that are unused
- -Wunused-type-patterns
- warn about unused type variables which arise from patterns in in type
family and data family instances
- -Wwarn
- make warnings non-fatal
- -Wwarnings-deprecations
- warn about uses of functions & types that have warnings or deprecated
pragmas
- -Wwrong-do-bind
- warn about do bindings that appear to throw away monadic values that you
should have bound instead
Copyright 2015. The University Court of the University of Glasgow.
All rights reserved.
https://www.haskell.org/ghc the GHC homepage