1 Project Description — cabal.project File
2 ========================================
4 ``cabal.project`` files support a variety of options which configure the
5 details of your build. The general syntax of a ``cabal.project`` file is
6 similar to that of a Cabal file: there are a number of fields, some of
7 which live inside stanzas (groups of fields that apply to only part of a
8 project or can be referenced as a unit):
13 with-compiler: /opt/ghc/8.0.1/bin/ghc
18 In general, the accepted field names coincide with the accepted command
19 line flags that ``cabal install`` and other commands take. For example,
20 ``cabal configure --enable-profiling`` will write out a project
21 file with ``profiling: True``.
23 The full configuration of a project is determined by combining the
24 following sources (later entries override earlier ones, except for appendable
27 1. :ref:`The user-wide global configuration <config-file-discovery>` (default: ``~/.config/cabal/config``)
29 2. ``cabal.project`` (the project configuration)
31 3. ``cabal.project.freeze`` (the output of ``cabal freeze``)
33 4. ``cabal.project.local`` (the output of ``cabal configure``)
35 Any call to ``cabal build`` will consider ``cabal.project*`` files from parent
36 directories when there is none in the current directory.
38 .. _conditionals and imports:
40 Conditionals and imports
41 ------------------------
43 As of ``cabal-install`` version 3.8, cabal supports conditional logic and
44 imports in ``cabal.project`` files.
48 While :ref:`conditional blocks<conditional-blocks>` can appear anywhere
49 within component or common sections of a package, their placement within a
50 project is restricted. Conditions may only be introduced at the top level
53 Of the :ref:`condition tests<conditions>`, only packages can test for
54 flags. Projects can test for operating system, architecture, compiler and
55 the boolean constants.
58 - :samp:`arch({name})`
59 - :samp:`impl({compiler})`
63 Imports may specify local filepaths or remote urls, and may reference either
64 cabal.project files or v1-style cabal.config freeze files. As a usage example:
71 packages: freebsd/*.cabal
75 import: https://some.remote.source/subdir/cabal.config
77 import: relativepath/extra-project.project
79 import: /absolutepath/some-project.project
81 Using conditionals will force cabal to find a ghc to derive
82 architecture and version information from, which will force some
83 commands (update, sdist) to require ghc present where otherwise it
84 would not be necessitated.
86 Specifying the local packages
87 -----------------------------
89 You *must* provide a non-empty list of local packages in your project, filling
90 out either a ``packages`` field or an ``optional-packages`` field or both to
91 satisfy this requirement.
93 When ``cabal.project`` doesn't exist, ``cabal-install`` fabricates an ephemeral
94 project for its own use with this simple content, a glob that will find any (but
95 expects to find one) package in the current directory:
101 The following top-level options specify what the local packages of a
104 .. cfg-field:: packages: package location list (space or comma separated)
105 :synopsis: Project packages.
109 Specifies the list of package locations which contain the local
110 packages to be built by this project. Package locations can take the
113 1. They can specify a Cabal file, or a directory containing a Cabal
114 file, e.g., ``packages: Cabal cabal-install/cabal-install.cabal``.
116 2. They can specify glob-style wildcards, which must match one or
117 more (a) directories containing a (single) Cabal file, (b) Cabal
118 files (extension ``.cabal``), or (c) tarballs which contain Cabal
119 packages (extension ``.tar.gz``).
120 For example, to match all Cabal files in all
121 subdirectories, as well as the Cabal projects in the parent
122 directories ``foo`` and ``bar``, use
123 ``packages: */*.cabal ../{foo,bar}/``
125 3. They can specify an ``http``, ``https`` or ``file``
126 URL, representing the path to a remote tarball to be downloaded
129 There is no command line variant of this field; see :issue:`3585`.
130 Note that the default value is only included if there is no
131 ``cabal.project`` file. The field is appendable which means there would be
132 no way to drop the default value if it was included.
134 .. cfg-field:: optional-packages: package location list (space or comma-separated)
135 :synopsis: Optional project packages.
139 Like :cfg-field:`packages`, specifies a list of package locations
140 containing local packages to be built. Unlike :cfg-field:`packages`,
141 if we glob for a package, it is permissible for the glob to match against
142 zero packages. The intended use-case for :cfg-field:`optional-packages`
143 is to make it so that vendored packages can be automatically picked up if
144 they are placed in a subdirectory, but not error if there aren't any.
146 There is no command line variant of this field.
148 .. cfg-field:: extra-packages: package list with version bounds (comma separated)
149 :synopsis: Adds external packages as local
151 Specifies a list of external packages from Hackage, which
152 should be considered local packages. The motivation for
153 :cfg-field:`extra-packages` is making libraries that are not
154 dependencies of any package in the project available for use in ghci.
156 There is no command line variant of this field.
160 All local packages are *vendored*, in the sense that if other packages
161 (including external ones from Hackage) depend on a package with the name
162 of a local package, the local package is preferentially used.
163 For subdirectories to be considered local packages, the following setting
167 optional-packages: ./*/*.cabal
169 ...then any package can be vendored simply by making a checkout in the
170 top-level project directory, as might be seen in this hypothetical
174 foo-helper/ # local package
175 unix/ # vendored external package
177 All of these options support globs. ``cabal build`` has its own glob
180 - Anywhere in a path, as many times as you like, you can specify an
181 asterisk ``*`` wildcard. E.g., ``*/*.cabal`` matches all ``.cabal``
182 files in all immediate subdirectories. Like in glob(7), asterisks do
183 not match hidden files unless there is an explicit period, e.g.,
184 ``.*/foo.cabal`` will match ``.private/foo.cabal`` (but
185 ``*/foo.cabal`` will not).
187 - You can use braces to specify specific directories; e.g.,
188 ``{vendor,pkgs}/*.cabal`` matches all Cabal files in the ``vendor``
189 and ``pkgs`` subdirectories.
191 Formally, the format is described by the following BNF:
194 convert globbing grammar to proper ABNF_ syntax
198 RootedGlob ::= FilePathRoot Glob
199 FilePathRoot ::= {- empty -} # relative to cabal.project
201 | [a-zA-Z] ":" [/\\] # Windows root
202 | "~" # home directory
203 Glob ::= GlobPieces [/\\] Glob # Unix or Windows directory
204 | "..[**/\\]" GlobPieces # Recursive directory glob
206 | [/\\] # trailing slash
207 GlobPieces ::= GlobPiece *
208 GlobPiece ::= "*" # wildcard
209 | [^*{},/\\] * # literal string
210 | "\\" [*{},] # escaped reserved character
211 | "{" Glob "," ... "," Glob "}" # union (match any of these)
214 .. _pkg-consume-source:
216 Taking a dependency from a *source code* repository
217 ---------------------------------------------------
219 Since version 2.4, the ``source-repository-package`` stanza allows for
220 specifying packages in a remote version control system that cabal should
221 consider during package retrieval. This allows use of a package from a
222 remote version control system, rather than looking for that package in
225 Since version 3.4, cabal-install creates tarballs for each package coming from a
226 ``source-repository-package`` stanza (effectively applying cabal sdists to such
227 packages). It gathers the names of the packages from the appropriate ``.cabal``
228 file in the version control repository, and allows their use just like Hackage
229 or locally defined packages.
231 There is no command line variant of this stanza.
233 .. code-block:: cabal
237 source-repository-package
239 location: https://github.com/hvr/HsYAML.git
240 tag: e70cf0c171c9a586b62b3f75d72f1591e4e6aaa1
242 source-repository-package
244 location: https://github.com/well-typed/cborg
245 tag: 3d274c14ca3077c3a081ba7ad57c5182da65c8c1
248 source-repository-package
250 location: https://github.com/haskell/network.git
251 tag: e76fdc753e660dfa615af6c8b6a2ad9ddf6afe70
252 post-checkout-command: autoreconf -i
254 .. _source-repository-package-fields:
256 The :ref:`VCS fields<vcs-fields>` of ``source-repository-package`` are:
259 data SourceRepositoryPackage f = SourceRepositoryPackage
260 { srpType :: !RepoType
261 , srpLocation :: !String
262 , srpTag :: !(Maybe String)
263 , srpBranch :: !(Maybe String)
264 , srpSubdir :: !(f FilePath)
265 , srpCommand :: ![String]
268 .. cfg-field:: type: VCS kind
270 This field is required.
272 .. cfg-field:: location: VCS location
274 This field is required.
276 .. cfg-field:: branch: VCS branch
278 This field is optional.
280 .. cfg-field:: tag: VCS tag
282 This field is optional.
284 .. cfg-field:: subdir: VCS subdirectory list
286 Look in one or more subdirectories of the repository for cabal files, rather
287 than the root. This field is optional.
289 .. cfg-field:: post-checkout-command: command
291 Run command in the checked out repository, prior sdisting.
293 Global configuration options
294 ----------------------------
296 The following top-level configuration options are not specific to any
297 package, and thus apply globally:
300 .. cfg-field:: verbose: nat
302 :synopsis: Build verbosity level.
306 Control the verbosity of ``cabal`` commands, valid values are from 0
309 The command line variant of this field is ``--verbose=2``; a short
310 form ``-v2`` is also supported.
312 .. cfg-field:: jobs: nat or $ncpus
313 -j[NUM], --jobs[=NUM], --jobs=$ncpus
314 :synopsis: Number of builds running in parallel.
318 Run *nat* jobs simultaneously when building. If ``$ncpus`` is
319 specified, run the number of jobs equal to the number of CPUs.
320 Package building is often quite parallel, so turning on parallelism
321 can speed up build times quite a bit!
323 The command line variant of this field is ``--jobs=2``; a short form
324 ``-j2`` is also supported; a bare ``--jobs`` or ``-j`` is equivalent
325 to ``--jobs=$ncpus``.
327 .. cfg-field:: semaphore: boolean
330 :synopsis: Use GHC's support for semaphore based parallelism.
334 This option instructs cabal to control parallelism by creating a new system semaphore,
335 whose number of tokens is specified by ``--jobs`` (or ``-j``).
336 This semaphore is passed to GHC, which allows it to use any leftover parallelism
337 that ``cabal-install`` is not using.
339 Requires ``ghc >= 9.8``.
341 The command line variant of this field is ``--semaphore``.
343 .. cfg-field:: keep-going: boolean
345 :synopsis: Try to continue building on failure.
349 If true, after a build failure, continue to build other unaffected
352 The command line variant of this field is ``--keep-going``.
354 .. option:: --builddir=DIR
356 Specifies the name of the directory where build products for
357 build will be stored; defaults to ``dist-newstyle``. If a
358 relative name is specified, this directory is resolved relative
359 to the root of the project (i.e., where the ``cabal.project``
362 This option can only be specified from the command line.
364 .. _cmdoption-project-dir:
365 .. option:: --project-dir=DIR
367 Specifies the path of the project directory. If a relative
368 :ref:`project-file<cmdoption-project-file>` path is also specified,
369 it will be resolved relative to this directory.
371 The project directory does not need to contain a ``cabal.project`` file.
373 This option can only be specified from the command line.
375 .. _cmdoption-project-file:
376 .. option:: --project-file=FILE
378 Specifies the path and name of the project file used to specify the
379 rest of the top-level configuration; defaults to ``cabal.project``.
380 This name not only specifies the name of the main project file,
381 but also the auxiliary project files ``cabal.project.freeze``
382 and ``cabal.project.local``; for example, if you specify
383 ``--project-file=my.project``, then the other files that will
384 be probed are ``my.project.freeze`` and ``my.project.local``.
386 If :ref:`project-dir<cmdoption-project-dir>` is not specified,
387 and the path is relative, we will
388 look for the file relative to the current working directory,
389 and then for the parent directory, until the project file is
390 found or we have hit the top of the user's home directory.
392 This option can only be specified from the command line.
394 .. option:: -z, --ignore-project
396 Ignores the local ``cabal.project`` file and uses the default
397 configuration with the local ``foo.cabal`` file. Note that
398 this flag will be ignored if either of the ``--project-dir`` or
399 ``--project-file`` flags are also set.
401 .. option:: --store-dir=DIR
403 Specifies the name of the directory of the global package store.
405 .. cfg-field:: package-dbs: package DB stack (comma separated)
406 --package-db=[clear, global, user, PATH]
407 :synopsis: PackageDB stack manipulation
410 By modifying ``package-dbs`` you can modify the default package environment
411 which ``cabal`` will see. The package databases you add using ``package-dbs``
412 will not be written into and only used as immutable package stores to initialise
413 the environment with additional packages that ``cabal`` can choose to use.
415 There are three package databases involved with most builds:
418 Compiler installation of rts, base, etc.
420 Nix-style local build cache
422 Project-specific build directory
424 By default, the initial package stack prefix you will have with v2 commands is:
430 So the initial set of packages which is used by cabal is just the packages
431 installed in the global package database which comes with ``ghc``.
433 When cabal builds a package it will start populating the ``store`` package database,
434 whose packages will then be subsequently be available to be used in future runs.
440 When cabal builds your local projects, packages are registered into the local
441 in-place package database.
445 -- prefix ++ [store, in-place]
447 This flag manipulates the default prefix: ``[global]`` and accepts
448 paths, the special value ``global`` referring to the global package db, and
449 ``clear`` which removes all prior entries. For example,
453 -- prefix = [global, foo]
457 package-dbs: clear, foo
459 -- prefix = [bar, baz]
460 package-dbs: clear, foo, clear, bar, baz
462 The command line variant of this flag is ``--package-db=DB`` which can be
463 specified multiple times.
468 The following settings apply to commands that result in build actions
469 (``build``, ``run``, ``repl``, ``test``...), and control which phases of the
472 .. option:: --dry-run
474 Do not download, build, or install anything, only print what would happen.
476 .. option:: --only-configure
478 Instead of performing a full build just run the configure step.
479 Only accepted by the ``build`` command.
481 .. option:: --only-download
483 Do not build anything, only fetch the packages.
485 .. option:: --only-dependencies
487 Install only the dependencies necessary to build the given packages.
488 Not accepted by the ``repl`` command.
490 Solver configuration options
491 ----------------------------
493 The following settings control the behavior of the dependency solver:
495 .. cfg-field:: constraints: CONSTRAINT (comma separated list)
496 -c CONSTRAINT or -cCONSTRAINT, --constraint=CONSTRAINT
497 --constraint="pkg >= 2.0", -c "pkg >= 2.0"
498 :synopsis: Extra dependencies constraints.
500 Add extra constraints to the version bounds, flag settings,
501 and other properties a solver can pick for a
502 package. For example:
506 constraints: bar == 2.1
508 A package can be specified multiple times in ``constraints``, in
509 which case the specified constraints are intersected. This is
510 useful, since the syntax does not allow you to specify multiple
511 constraints at once. For example, to specify both version bounds and
512 flag assignments, you would write:
520 This is equivalent to writing constraints and :cfg-field:`flags` separately:
524 constraints: bar == 2.1
528 Valid constraints take the same form as for the
529 :option:`runhaskell Setup.hs configure --constraint`
532 .. cfg-field:: preferences: CONSTRAINT (comma separated list)
533 --preference=CONSTRAINT
534 --preference="pkg >= 2.0"
535 :synopsis: Preferred dependency versions.
537 Like :cfg-field:`constraints`, but the solver will attempt to satisfy
538 these preferences on a best-effort basis. The resulting install is locally
539 optimal with respect to preferences; specifically, no single package
540 could be replaced with a more preferred version that still satisfies
541 the hard constraints.
543 Operationally, preferences can cause the solver to attempt certain
544 version choices of a package before others, which can improve
545 dependency solver runtime.
547 One way to use :cfg-field:`preferences` is to take a known working set of
548 constraints (e.g., via ``cabal freeze``) and record them as
549 preferences. In this case, the solver will first attempt to use this
550 configuration, and if this violates hard constraints, it will try to
551 find the minimal number of upgrades to satisfy the hard constraints
554 The command line variant of this field is
555 ``--preference="pkg >= 2.0"``; to specify multiple preferences, pass
556 the flag multiple times.
558 .. cfg-field:: allow-newer: none, all or list of scoped package names (space or comma separated)
559 --allow-newer, --allow-newer=[none,all,[scope:][^]pkg]
560 :synopsis: Lift dependencies upper bound constraints.
564 Allow the solver to pick more recent version of some packages than
565 would normally be permitted by the :pkg-field:`build-depends` bounds
566 of packages in the install plan. This option may be useful if the
567 dependency solver cannot otherwise find a valid install plan.
569 For example, to relax ``pkg``\ s :pkg-field:`build-depends` upper bound on
570 ``dep-pkg``, write a scoped package name of the form:
574 allow-newer: pkg:dep-pkg
576 If the scope shall be limited to specific releases of ``pkg``, the
581 allow-newer: pkg-1.2.3:dep-pkg, pkg-1.1.2:dep-pkg
583 can be used to limit the relaxation of dependencies on
584 ``dep-pkg`` by the ``pkg-1.2.3`` and ``pkg-1.1.2`` releases only.
586 The scoped syntax is recommended, as it is often only a single package
587 whose upper bound is misbehaving. In this case, the upper bounds of
588 other packages should still be respected; indeed, relaxing the bound
589 can break some packages which test the selected version of packages.
591 The syntax also allows to prefix the dependee package with a
592 modifier symbol to modify the scope/semantic of the relaxation
593 transformation in a additional ways. Currently only one modifier
594 symbol is defined, i.e. ``^`` (i.e. caret) which causes the
595 relaxation to be applied only to ``^>=`` operators and leave all other
596 version operators untouched.
598 However, in some situations (e.g., when attempting to build packages
599 on a new version of GHC), it is useful to disregard *all*
600 upper-bounds, with respect to a package or all packages. This can be
601 done by specifying just a package name, or using the keyword ``all``
602 to specify all packages:
606 -- Disregard upper bounds involving the dependencies on
607 -- packages bar, baz. For quux only, relax
608 -- 'quux ^>= ...'-style constraints only.
609 allow-newer: bar, baz, ^quux
611 -- Disregard all upper bounds when dependency solving
614 -- Disregard all `^>=`-style upper bounds when dependency solving
618 For consistency, there is also the explicit wildcard scope syntax
619 ``*`` (or its alphabetic synonym ``all``). Consequently, the
620 examples above are equivalent to the explicitly scoped variants:
624 allow-newer: all:bar, *:baz, *:^quux
630 allow-newer: all:^all
632 In order to ignore all bounds specified by a package ``pkg-1.2.3``
633 you can combine scoping with a right-hand-side wildcard like so
637 -- Disregard any upper bounds specified by pkg-1.2.3
638 allow-newer: pkg-1.2.3:*
640 -- Disregard only `^>=`-style upper bounds in pkg-1.2.3
641 allow-newer: pkg-1.2.3:^*
644 :cfg-field:`allow-newer` is often used in conjunction with a constraint
645 (in the :cfg-field:`constraints` field) forcing the usage of a specific,
646 newer version of a package.
648 The command line variant of this field is e.g. ``--allow-newer=bar``. A
649 bare ``--allow-newer`` is equivalent to ``--allow-newer=all``.
651 .. cfg-field:: allow-older: none, all, list of scoped package names (space or comma separated)
652 --allow-older, --allow-older=[none,all,[scope:][^]pkg]
653 :synopsis: Lift dependency lower bound constraints.
658 Like :cfg-field:`allow-newer`, but applied to lower bounds rather than
661 The command line variant of this field is ``--allow-older=all``. A
662 bare ``--allow-older`` is equivalent to ``--allow-older=all``.
665 .. cfg-field:: index-state: HEAD, unix-timestamp, ISO8601 UTC timestamp.
666 :synopsis: Use source package index state as it existed at a previous time.
671 This allows to change the source package index state the solver uses
672 to compute install-plans. This is particularly useful in
673 combination with freeze-files in order to also freeze the state the
674 package index was in at the time the install-plan was frozen.
678 -- UNIX timestamp format example
679 index-state: @1474739268
681 -- ISO8601 UTC timestamp format example
682 -- This format is used by 'cabal configure'
683 -- for storing `--index-state` values.
684 index-state: 2016-09-24T17:47:48Z
686 -- Specify different index-states per package repository
687 -- Supported since 3.4
689 , hackage.haskell.org 2020-05-06T22:33:27Z
690 , head.hackage 2020-04-29T04:11:05Z
692 .. cfg-field:: active-repositories: reponame1, reponame2
694 :synopsis: Specify active package repositories
699 Specifies which of the package repositories defined in the configuration
700 should be active. It's also useful for specifying the order and the way
701 active repositories are merged.
703 When searching for a certain version of a certain package name, the list of
704 active repositories is searched last-to-first.
706 For example, suppose hackage.haskell.org has versions 1.0 and 2.0 of
707 package X, and my-repository has version 2.0 of a similarly named package.
708 Then, with the following configuration:
712 -- Force my-repository to be the first repository considered
714 , hackage.haskell.org
717 version 2.0 of X will come from my-repository, and version 1.0 will come
718 from hackage.haskell.org.
720 If we want to make a repository the sole provider of certain packages, we
721 can put it last in the active repositories list, and add the :override
724 For example, if we modify the previous example like this:
729 , hackage.haskell.org
730 , my-repository:override
732 then version 1.0 of package X won't be found in any case, because X is
733 present in my-repository only in version 2.0, and the :override forbids
734 searching for other versions of X further up the list.
736 :override has no effect for package names that aren't present in the
737 overriding repository.
739 The special repository reference :rest stands for "all the other repositories"
740 and can be useful to avoid lengthy lists of repository names:
744 -- Force my-repository to be the first repository considered
745 active-repositories: :rest, my-repository
747 The special repository reference :none disables all repositories, effectively
748 putting cabal in "offline" mode:
752 active-repositories: :none
755 .. cfg-field:: reject-unconstrained-dependencies: all, none
756 --reject-unconstrained-dependencies=[all|none]
757 :synopsis: Restrict the solver to packages that have constraints on them.
762 By default, the dependency solver can include any package that it's
763 aware of in a build plan. If you wish to restrict the build plan to
764 a closed set of packages (e.g., from a freeze file), use this flag.
766 When set to `all`, all non-local packages that aren't goals must be
767 explicitly constrained. When set to `none`, the solver will
768 consider all packages.
771 Package configuration options
772 -----------------------------
774 Package options affect the building of specific packages. There are three
775 ways a package option can be specified:
777 - They can be specified at the top-level, in which case they apply only
778 to **local package**, or
780 - They can be specified inside a ``package`` stanza, in which case they
781 apply to the build of the package, whether or not it is local or
784 - They can be specified inside an ``package *`` stanza, in which case they
785 apply to all packages, local ones from the project and also external
788 For example, the following options specify that :cfg-field:`optimization`
789 should be turned off for all local packages, and that ``awesome-package`` (possibly
790 an external dependency) should have the flag ``some-flag`` disabled ::
794 package awesome-package
797 Note that options at the top level take precedence over those at the ``package``
798 stanza for local packages.
800 On the command line, these options are applied to all local packages.
801 There is no per-package command line interface.
803 Some flags were added by more recent versions of the Cabal library. This
804 means that they are NOT supported by packages which use Custom setup
805 scripts that require a version of the Cabal library older than when the
808 .. cfg-section:: package name or *
810 Specify package configuration options for the specific package (be it an
811 external or local package) or for all packages (external and local).
813 A ``package`` stanza can contain the configuration fields listed in this
814 section and ``<progname>-options``:
818 package awesome-package
823 Program options are not extensively described in this documentation but a
824 good amount of them can be found in the :ref:`build-info` section.
826 .. cfg-section:: None
828 .. cfg-field:: flags: list of +flagname or -flagname (space separated)
829 -f FLAGS or -fFLAGS, --flags=FLAGS
830 --flags="+foo -bar", -ffoo, -f-bar
831 :synopsis: Enable or disable package flags.
833 Force all flags specified as ``+flagname`` to be true, and all flags
834 specified as ``-flagname`` to be false. For example, to enable the
835 flag ``foo`` and disable ``bar``, set:
841 Exactly one of + or - is required before each flag.
843 Flags are *per-package*, so it doesn't make much sense to specify
844 flags at the top-level, unless you happen to know that *all* of your
845 local packages support the same named flags. If a flag is not
846 supported by a package, it is ignored.
848 The command line variant of this flag is ``--flags``. There is also
849 a shortened form ``-ffoo -f-bar``.
851 A common mistake is to say ``cabal build -fhans``, where
852 ``hans`` is a flag for a transitive dependency that is not in the
853 local package; in this case, the flag will be silently ignored. If
854 ``haskell-tor`` is the package you want this flag to apply to, try
855 ``--constraint="haskell-tor +hans"`` instead. Flags can be specified as
856 package :cfg-field:`constraints`.
858 .. cfg-field:: with-compiler: PATH
859 -w PATH or -wPATH, --with-compiler=PATH
860 :synopsis: Path to compiler executable.
862 Specify the path to a particular compiler to be used. If not an
863 absolute path, it will be resolved according to the ``PATH``
864 environment. The type of the compiler (GHC, GHCJS, etc) must be
865 consistent with the setting of the :cfg-field:`compiler` field.
867 The most common use of this option is to specify a different version
868 of your compiler to be used; e.g., if you have ``ghc-7.8`` in your
869 path, you can specify ``with-compiler: ghc-7.8`` to use it.
871 This flag also sets the default value of :cfg-field:`with-hc-pkg`, using
872 the heuristic that it is named ``ghc-pkg-7.8`` (if your executable name
873 is suffixed with a version number), or is the executable named
874 ``ghc-pkg`` in the same directory as the ``ghc`` directory. If this
875 heuristic does not work, set :cfg-field:`with-hc-pkg` explicitly.
877 For inplace packages, ``cabal build`` maintains a separate build
878 directory for each version of GHC, so you can maintain multiple
879 build trees for different versions of GHC without clobbering each
882 It's not possible to set :cfg-field:`with-compiler` on a
885 The command line variant of this flag is
886 ``--with-compiler=ghc-7.8``; there is also a short version
889 .. cfg-field:: with-hc-pkg: PATH
891 :synopsis: Path to package tool.
893 Specify the path to the package tool, e.g., ``ghc-pkg``. This
894 package tool must be compatible with the compiler specified by
895 :cfg-field:`with-compiler` (generally speaking, it should be precisely
896 the tool that was distributed with the compiler). If this option is
897 omitted, the default value is determined from :cfg-field:`with-compiler`.
899 The command line variant of this flag is
900 ``--with-hc-pkg=ghc-pkg-7.8``.
902 .. cfg-field:: optimization: nat
903 -O[n], --enable-optimization[=n]
904 --disable-optimization
905 :synopsis: Build with optimization.
909 Build with optimization. This is appropriate for production use,
910 taking more time to build faster libraries and programs.
912 The optional *nat* value is the optimisation level. Some compilers
913 support multiple optimisation levels. The range is 0 to 2. Level 0
914 disables optimization, level 1 is the default. Level 2 is higher
915 optimisation if the compiler supports it. Level 2 is likely to lead
916 to longer compile times and bigger generated code. If you are not
917 planning to run code, turning off optimization will lead to better
918 build times and less code to be rebuilt when a module changes.
920 When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
922 We also accept ``True`` (equivalent to 1) and ``False`` (equivalent
925 Note that as of GHC 8.0, GHC does not recompile when optimization
926 levels change (see :ghc-ticket:`10923`), so if
927 you change the optimization level for a local package you may need
928 to blow away your old build products in order to rebuild with the
929 new optimization level.
931 The command line variant of this flag is ``-O2`` (with ``-O1``
932 equivalent to ``-O``). There are also long-form variants
933 ``--enable-optimization`` and ``--disable-optimization``.
935 .. cfg-field:: configure-options: OPT (space separated list)
936 --configure-option=OPT
937 :synopsis: Options to pass to configure script.
939 A list of extra arguments to pass to the external ``./configure``
940 script, if one is used. This is only useful for packages which have
941 the ``Configure`` build type. See also the section on
942 :ref:`system-dependent parameters`.
944 The command line variant of this flag is ``--configure-option=arg``,
945 which can be specified multiple times to pass multiple options.
947 .. cfg-field:: compiler: ghc, ghcjs, jhc, lhc, uhc or haskell-suite
949 :synopsis: Compiler to build with.
953 Specify the compiler toolchain to be used. This is independent of
954 ``with-compiler``, because the choice of toolchain affects Cabal's
957 The command line variant of this flag is ``--compiler=ghc``.
959 It's not possible to set :cfg-field:`compiler` on a
962 .. cfg-field:: tests: boolean
965 :synopsis: Build tests.
969 Force test suites to be enabled. For most users this should not be
970 needed, as we always attempt to solve for test suite dependencies,
971 even when this value is ``False``; furthermore, test suites are
972 automatically enabled if they are requested as a built target.
974 The command line variant of this flag is ``--enable-tests`` and
977 .. cfg-field:: benchmarks: boolean
980 :synopsis: Build benchmarks.
984 Force benchmarks to be enabled. For most users this should not be
985 needed, as we always attempt to solve for benchmark dependencies,
986 even when this value is ``False``; furthermore, benchmarks are
987 automatically enabled if they are requested as a built target.
989 The command line variant of this flag is ``--enable-benchmarks`` and
990 ``--disable-benchmarks``.
992 .. _cmdoption-extra-prog-path:
993 .. cfg-field:: extra-prog-path: PATH (newline or comma separated list)
994 --extra-prog-path=PATH
995 :synopsis: Add directories to program search path.
998 A list of directories to search for extra required programs. Most
999 users should not need this, as programs like ``happy`` and ``alex``
1000 will automatically be installed and added to the path. This can be
1001 useful if a ``Custom`` setup script relies on an exotic extra
1004 The command line variant of this flag is ``--extra-prog-path=PATH``,
1005 which can be specified multiple times.
1007 When specifying :ref:`--http-transport<cmdoption-http-transport>` from the
1008 command line, only extra-prog-path from the command line are added to the
1009 program search path.
1011 .. cfg-field:: run-tests: boolean
1013 :synopsis: Run package test suite during installation.
1017 Run the package test suite during installation. This is useful for
1018 saying "When this package is installed, check that the test suite
1019 passes, terminating the rest of the build if it is broken."
1023 One deficiency: the :cfg-field:`run-tests` setting of a package is NOT
1024 recorded as part of the hash, so if you install something without
1025 :cfg-field:`run-tests` and then turn on ``run-tests``, we won't
1026 subsequently test the package. If this is causing you problems, give
1029 The command line variant of this flag is ``--run-tests``.
1034 .. cfg-field:: debug-info: integer
1035 --enable-debug-info[=n]
1036 --disable-debug-info
1037 :synopsis: Build with debug info enabled.
1042 If the compiler (e.g., GHC 7.10 and later) supports outputting OS
1043 native debug info (e.g., DWARF), setting ``debug-info: True`` will
1044 instruct it to do so. See the GHC wiki page on :ghc-wiki:`DWARF`
1045 for more information about this feature.
1047 (This field also accepts numeric syntax, but until GHC 8.2 this didn't
1050 The command line variant of this flag is ``--enable-debug-info`` and
1051 ``--disable-debug-info``.
1053 .. cfg-field:: split-sections: boolean
1054 --enable-split-sections
1055 --disable-split-sections
1056 :synopsis: Use GHC's split sections feature.
1061 Use the GHC ``-split-sections`` feature when building the library. This
1062 reduces the final size of the executables that use the library by
1063 allowing them to link with only the bits that they use rather than
1064 the entire library. The downside is that building the library takes
1065 longer and uses a bit more memory.
1067 This feature is supported by GHC 8.0 and later.
1069 The command line variant of this flag is ``--enable-split-sections`` and
1070 ``--disable-split-sections``.
1072 .. cfg-field:: split-objs: boolean
1074 --disable-split-objs
1075 :synopsis: Use GHC's split objects feature.
1079 Use the GHC ``-split-objs`` feature when building the library. This
1080 reduces the final size of the executables that use the library by
1081 allowing them to link with only the bits that they use rather than
1082 the entire library. The downside is that building the library takes
1083 longer and uses considerably more memory.
1085 It is generally recommend that you use ``split-sections`` instead
1086 of ``split-objs`` where possible.
1088 The command line variant of this flag is ``--enable-split-objs`` and
1089 ``--disable-split-objs``.
1091 .. cfg-field:: executable-stripping: boolean
1092 --enable-executable-stripping
1093 --disable-executable-stripping
1094 :synopsis: Strip installed programs.
1098 When installing binary executable programs, run the ``strip``
1099 program on the binary. This can considerably reduce the size of the
1100 executable binary file. It does this by removing debugging
1101 information and symbols.
1103 Not all Haskell implementations generate native binaries. For such
1104 implementations this option has no effect.
1106 If ``debug-info`` is set explicitly then ``executable-stripping`` is set
1107 to ``False`` as otherwise all the debug symbols will be stripped.
1109 The command line variant of this flag is
1110 ``--enable-executable-stripping`` and
1111 ``--disable-executable-stripping``.
1113 .. cfg-field:: library-stripping: boolean
1114 --enable-library-stripping
1115 --disable-library-stripping
1116 :synopsis: Strip installed libraries.
1119 When installing binary libraries, run the ``strip`` program on the
1120 binary, saving space on the file system. See also
1121 ``executable-stripping``.
1123 If ``debug-info`` is set explicitly then ``library-stripping`` is set
1124 to ``False`` as otherwise all the debug symbols will be stripped.
1126 The command line variant of this flag is
1127 ``--enable-library-stripping`` and ``--disable-library-stripping``.
1132 .. cfg-field:: program-prefix: PREFIX
1133 --program-prefix=PREFIX
1134 :synopsis: Prepend prefix to program names.
1136 :strike:`Prepend *prefix* to installed program names.` (Currently
1137 implemented in a silly and not useful way. If you need this to work
1140 *prefix* may contain the following path variables: ``$pkgid``,
1141 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1144 The command line variant of this flag is ``--program-prefix=foo-``.
1146 .. cfg-field:: program-suffix: SUFFIX
1147 --program-suffix=SUFFIX
1148 :synopsis: Append refix to program names.
1150 :strike:`Append *suffix* to installed program names.` (Currently
1151 implemented in a silly and not useful way. If you need this to work
1154 The most obvious use for this is to append the program's version
1155 number to make it possible to install several versions of a program
1156 at once: ``program-suffix: $version``.
1158 *suffix* may contain the following path variables: ``$pkgid``,
1159 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1162 The command line variant of this flag is
1163 ``--program-suffix='$version'``.
1165 Dynamic linking options
1166 ^^^^^^^^^^^^^^^^^^^^^^^
1168 .. cfg-field:: shared: boolean
1171 :synopsis: Build shared library.
1175 Build shared library. This implies a separate compiler run to
1176 generate position independent code as required on most platforms.
1178 The command line variant of this flag is ``--enable-shared`` and
1179 ``--disable-shared``.
1181 .. cfg-field:: executable-dynamic: boolean
1182 --enable-executable-dynamic
1183 --disable-executable-dynamic
1184 :synopsis: Link executables dynamically.
1188 Link executables dynamically. The executable's library dependencies
1189 should be built as shared objects. This implies ``shared: True``
1190 unless ``shared: False`` is explicitly specified.
1192 The command line variant of this flag is
1193 ``--enable-executable-dynamic`` and
1194 ``--disable-executable-dynamic``.
1196 .. cfg-field:: library-for-ghci: boolean
1197 --enable-library-for-ghci
1198 --disable-library-for-ghci
1199 :synopsis: Build libraries suitable for use with GHCi.
1203 Build libraries suitable for use with GHCi. This involves an extra
1204 linking step after the build.
1206 Not all platforms support GHCi and indeed on some platforms, trying
1207 to build GHCi libs fails. In such cases, consider setting
1208 ``library-for-ghci: False``.
1210 The command line variant of this flag is
1211 ``--enable-library-for-ghci`` and ``--disable-library-for-ghci``.
1213 .. cfg-field:: relocatable:
1215 :synopsis: Build relocatable package.
1220 :strike:`Build a package which is relocatable.` (TODO: It is not
1221 clear what this actually does, or if it works at all.)
1223 The command line variant of this flag is ``--relocatable``.
1225 Static linking options
1226 ^^^^^^^^^^^^^^^^^^^^^^
1228 .. cfg-field:: static: boolean
1231 :synopsis: Build static library.
1236 Roll this and all dependent libraries into a combined ``.a`` archive.
1237 This uses GHCs ``-staticlib`` flag, which is available for iOS and with
1238 GHC 8.4 and later for other platforms as well.
1240 .. cfg-field:: executable-static: boolean
1241 --enable-executable-static
1242 --disable-executable-static
1243 :synopsis: Build fully static executables.
1248 Build fully static executables.
1249 This links all dependent libraries into executables statically,
1251 This passes ``-static`` and ``-optl=-static`` to GHC.
1253 Foreign function interface options
1254 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1256 .. cfg-field:: extra-include-dirs: directories (comma or newline separated list)
1257 --extra-include-dirs=DIR
1258 :synopsis: Adds C header search path.
1260 An extra directory to search for C header files. You can use this
1261 flag multiple times to get a list of directories.
1263 You might need to use this flag if you have standard system header
1264 files in a non-standard location that is not mentioned in the
1265 package's ``.cabal`` file. Using this option has the same affect as
1266 appending the directory *dir* to the :pkg-field:`include-dirs` field in each
1267 library and executable in the package's ``.cabal`` file. The
1268 advantage of course is that you do not have to modify the package at
1269 all. These extra directories will be used while building the package
1270 and for libraries it is also saved in the package registration
1271 information and used when compiling modules that use the library.
1273 The command line variant of this flag is
1274 ``--extra-include-dirs=DIR``, which can be specified multiple times.
1276 .. cfg-field:: extra-lib-dirs: directories (comma or newline separated list)
1277 --extra-lib-dirs=DIR
1278 :synopsis: Adds library search directory.
1280 An extra directory to search for system libraries files.
1282 The command line variant of this flag is ``--extra-lib-dirs=DIR``,
1283 which can be specified multiple times.
1285 .. cfg-field:: extra-framework-dirs: directories (comma or newline separated list)
1286 --extra-framework-dirs=DIR
1287 :synopsis: Adds framework search directory (OS X only).
1289 An extra directory to search for frameworks (OS X only).
1291 You might need to use this flag if you have standard system
1292 libraries in a non-standard location that is not mentioned in the
1293 package's ``.cabal`` file. Using this option has the same affect as
1294 appending the directory *dir* to the :cfg-field:`extra-lib-dirs` field in
1295 each library and executable in the package's ``.cabal`` file. The
1296 advantage of course is that you do not have to modify the package at
1297 all. These extra directories will be used while building the package
1298 and for libraries it is also saved in the package registration
1299 information and used when compiling modules that use the library.
1301 The command line variant of this flag is
1302 ``--extra-framework-dirs=DIR``, which can be specified multiple
1308 .. cfg-field:: profiling: boolean
1311 :synopsis: Enable profiling builds.
1316 Build libraries and executables with profiling enabled (for
1317 compilers that support profiling as a separate mode). It is only
1318 necessary to specify :cfg-field:`profiling` for the specific package you
1319 want to profile; ``cabal build`` will ensure that all of its
1320 transitive dependencies are built with profiling enabled.
1322 To enable profiling for only libraries or executables, see
1323 :cfg-field:`library-profiling` and :cfg-field:`executable-profiling`.
1325 For useful profiling, it can be important to control precisely what
1326 cost centers are allocated; see :cfg-field:`profiling-detail`.
1328 The command line variant of this flag is ``--enable-profiling`` and
1329 ``--disable-profiling``.
1331 .. cfg-field:: profiling-detail: level
1332 --profiling-detail=level
1333 :synopsis: Profiling detail level.
1336 Some compilers that support profiling, notably GHC, can allocate
1337 costs to different parts of the program and there are different
1338 levels of granularity or detail with which this can be done. In
1339 particular for GHC this concept is called "cost centers", and GHC
1340 can automatically add cost centers, and can do so in different ways.
1342 This flag covers both libraries and executables, but can be
1343 overridden by the ``library-profiling-detail`` field.
1345 Currently this setting is ignored for compilers other than GHC. The
1346 levels that cabal currently supports are:
1349 For GHC this uses ``exported-functions`` for libraries and
1350 ``toplevel-functions`` for executables.
1352 No costs will be assigned to any code within this component.
1354 Costs will be assigned at the granularity of all top level
1355 functions exported from each module. In GHC, this
1356 is for non-inline functions. Corresponds to ``-fprof-auto-exported``.
1358 Costs will be assigned at the granularity of all top level
1359 functions in each module, whether they are exported from the
1360 module or not. In GHC specifically, this is for non-inline
1361 functions. Corresponds to ``-fprof-auto-top``.
1363 Costs will be assigned at the granularity of all functions in
1364 each module, whether top level or local. In GHC specifically,
1365 this is for non-inline toplevel or where-bound functions or
1366 values. Corresponds to ``-fprof-auto``.
1368 Like top-level but costs will be assigned to top level definitions after
1369 optimization. This lowers profiling overhead massively while giving similar
1370 levels of detail as toplevle-functions. However it means functions introduced
1371 by GHC during optimization will show up in profiles as well.
1372 Corresponds to ``-fprof-late`` if supported and ``-fprof-auto-top`` otherwise.
1374 Currently an alias for late-toplevel
1376 The command line variant of this flag is
1377 ``--profiling-detail=none``.
1379 .. cfg-field:: library-profiling-detail: level
1380 --library-profiling-detail=level
1381 :synopsis: Libraries profiling detail level.
1384 Like :cfg-field:`profiling-detail`, but applied only to libraries
1386 The command line variant of this flag is
1387 ``--library-profiling-detail=none``.
1389 .. cfg-field:: library-vanilla: boolean
1390 --enable-library-vanilla
1391 --disable-library-vanilla
1392 :synopsis: Build libraries without profiling.
1396 Build ordinary libraries (as opposed to profiling libraries).
1397 Mostly, you can set this to False to avoid building ordinary
1398 libraries when you are profiling.
1400 The command line variant of this flag is
1401 ``--enable-library-vanilla`` and ``--disable-library-vanilla``.
1403 .. cfg-field:: library-profiling: boolean
1404 --enable-library-profiling
1405 --disable-library-profiling
1406 :synopsis: Build libraries with profiling enabled.
1411 Build libraries with profiling enabled. You probably want
1412 to use :cfg-field:`profiling` instead.
1414 The command line variant of this flag is
1415 ``--enable-library-profiling`` and ``--disable-library-profiling``.
1417 .. cfg-field:: executable-profiling: boolean
1418 --enable-executable-profiling
1419 --disable-executable-profiling
1420 :synopsis: Build executables with profiling enabled.
1425 Build executables with profiling enabled. You probably want
1426 to use :cfg-field:`profiling` instead.
1428 The command line variant of this flag is
1429 ``--enable-executable-profiling`` and
1430 ``--disable-executable-profiling``.
1435 .. cfg-field:: coverage: boolean
1438 :synopsis: Build with coverage enabled.
1443 Build libraries and executables (including test suites) with Haskell
1444 Program Coverage enabled. Running the test suites will automatically
1445 generate coverage reports with HPC.
1447 The command line variant of this flag is ``--enable-coverage`` and
1448 ``--disable-coverage``.
1450 .. cfg-field:: library-coverage: boolean
1451 --enable-library-coverage
1452 --disable-library-coverage
1458 Deprecated, use :cfg-field:`coverage`.
1460 The command line variant of this flag is
1461 ``--enable-library-coverage`` and ``--disable-library-coverage``.
1466 .. cfg-field:: documentation: boolean
1467 --enable-documentation
1468 --disable-documentation
1469 :synopsis: Enable building of documentation.
1473 Enables building of Haddock documentation.
1474 Implied when calling ``cabal haddock``.
1476 The command line variant of this flag is ``--enable-documentation``
1477 and ``--disable-documentation``.
1479 ``documentation: true`` does not imply
1480 :cfg-field:`haddock-all`,
1481 :cfg-field:`haddock-benchmarks`,
1482 :cfg-field:`haddock-executables`,
1483 :cfg-field:`haddock-internal` or
1484 :cfg-field:`haddock-tests`.
1485 These need to be enabled separately if desired.
1487 .. cfg-field:: doc-index-file: templated path
1488 --doc-index-file=TEMPLATE
1489 :synopsis: Path to haddock templates.
1491 A central index of Haddock API documentation (template cannot use
1492 ``$pkgid``), which should be updated as documentation is built.
1494 The following commands are equivalent to ones that would be passed when
1495 running ``setup haddock``.
1497 .. cfg-field:: haddock-hoogle: boolean
1499 :synopsis: Generate Hoogle file.
1503 Generate a text file which can be converted by Hoogle_
1504 into a database for searching.
1505 This is equivalent to running ``haddock`` with the ``--hoogle`` flag.
1507 .. cfg-field:: haddock-html: boolean
1509 :synopsis: Build HTML documentation.
1513 Build HTML documentation.
1515 .. cfg-field:: haddock-quickjump: boolean
1517 :synopsis: Generate Quickjump file.
1521 Generate an index for interactive documentation navigation.
1522 This is equivalent to running ``haddock`` with the ``--quickjump`` flag.
1524 .. cfg-field:: haddock-html-location: URL (templated path)
1525 --haddock-html-location=URL
1526 :synopsis: Location of HTML documentation for prerequisite packages.
1528 Specify a template for the location of HTML documentation for
1529 prerequisite packages. The substitutions are applied to the template
1530 to obtain a location for each package, which will be used by
1531 hyperlinks in the generated documentation. For example, the
1532 following command generates links pointing at Hackage pages:
1536 html-location: http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html
1538 If passed on the command line,
1539 the argument may be quoted to prevent substitution by the shell.
1543 --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
1545 If this option is omitted, the location for each package is obtained
1546 using the package tool (e.g. ``ghc-pkg``).
1548 .. cfg-field:: haddock-executables: boolean
1549 --haddock-executables
1550 :synopsis: Generate documentation for executables.
1554 Run haddock on all executable programs.
1556 .. cfg-field:: haddock-tests: boolean
1558 :synopsis: Generate documentation for tests.
1562 Run haddock on all test suites.
1564 .. cfg-field:: haddock-benchmarks: boolean
1565 --haddock-benchmarks
1566 :synopsis: Generate documentation for benchmarks.
1570 Run haddock on all benchmarks.
1572 .. cfg-field:: haddock-internal: boolean
1574 :synopsis: Generate documentation for internal modules
1578 Build haddock documentation which includes unexposed modules and
1581 .. cfg-field:: haddock-all: boolean
1583 :synopsis: Generate documentation for everything
1587 Run haddock on all components.
1589 .. cfg-field:: haddock-css: PATH
1591 :synopsis: Location of Haddock CSS file.
1593 The CSS file that should be used to style the generated
1594 documentation (overriding haddock's default).
1596 .. cfg-field:: haddock-hyperlink-source: boolean
1597 --haddock-hyperlink-source
1598 :synopsis: Generate hyperlinked source code for documentation
1602 Generated hyperlinked source code using `HsColour`_, and have
1603 Haddock documentation link to it.
1604 This is equivalent to running ``haddock`` with the ``--hyperlinked-source`` flag.
1606 .. cfg-field:: haddock-hscolour-css: PATH
1607 --haddock-hscolour-css=PATH
1608 :synopsis: Location of CSS file for HsColour
1610 The CSS file that should be used to style the generated hyperlinked
1611 source code (from `HsColour`_).
1613 .. cfg-field:: haddock-contents-location: URL
1614 --haddock-contents-location=URL
1615 :synopsis: URL for contents page.
1617 A baked-in URL to be used as the location for the contents page.
1619 .. cfg-field:: haddock-keep-temp-files: boolean
1620 :synopsis: Keep temporary Haddock files.
1622 Keep temporary files.
1624 There is no command line variant of this flag.
1626 .. cfg-field:: haddock-output-dir: DIR
1627 --haddock-output-dir=DIR
1628 :synopsis: Generate haddock documentation into this directory.
1630 Generate haddock documentation into this directory instead of the default
1631 location next to other build products.
1633 This flag is provided as a technology preview and is subject to change in the
1636 .. cfg-field:: haddock-use-unicode: boolean
1637 --haddock-use-unicode
1638 :synopsis: Pass --use-unicode option to haddock.
1640 Generate HTML documentation which contains unicode characters.
1642 .. cfg-field:: haddock-resources-dir: DIR
1643 --haddock-resources-dir=DIR
1644 :synopsis: Location of Haddock's static/auxiliary files.
1646 Location of Haddock's static/auxiliary files. For Haddock distributed with
1647 GHC (or, more precisely, built within the GHC source tree), this path should
1648 be automatically inferred. For Haddock built from source, however, this path
1649 should likely be explicitly set for every Haddock invocation.
1651 .. cfg-field:: open: boolean
1653 :synopsis: Open generated documentation in-browser.
1655 When generating HTML documentation, attempt to open it in a browser
1656 when complete. This will use ``xdg-open`` on Linux and BSD systems,
1657 ``open`` on macOS, and ``start`` on Windows.
1662 .. cfg-section:: program-options
1664 :ref:`Program options<program_options>` can be specified once for all local packages by means of the
1665 ``program-options`` stanza. For example:
1670 ghc-options: -Werror
1672 indicates that all **local packages** will provide ``-Werror`` to GHC when being
1673 built. On the other hand, the following snippet:
1678 ghc-options: -Werror
1680 will apply ``-Werror`` to all packages, local and remote.
1682 Advanced global configuration options
1683 -------------------------------------
1685 .. cfg-section:: None
1687 .. cfg-field:: write-ghc-environment-files: always, never, or ghc8.4.4+
1688 --write-ghc-environment-files=always|never|ghc8.4.4+
1689 :synopsis: Whether a ``.ghc.environment`` should be created after a successful build.
1693 Whether a `GHC package environment file <https://downloads.haskell.org/~ghc/master/users-guide/packages.html#package-environments>`_
1694 should be created after a successful build.
1696 Since Cabal 3.0, defaults to ``never``. Before that, defaulted to
1697 creating them only when compiling with GHC 8.4.4 and older (GHC
1698 8.4.4 `is the first version
1699 <https://gitlab.haskell.org/ghc/ghc/-/issues/13753>`_ that supports
1700 the ``-package-env -`` option that allows ignoring the package
1703 .. cfg-field:: build-info: True, False
1705 --disable-build-info
1706 :synopsis: Whether build information for each individual component should be
1707 written in a machine readable format.
1711 Enable generation of build information for Cabal components. Contains very
1712 detailed information on how to build an individual component, such as
1713 compiler version, modules of a component and how to compile the component.
1715 The output format is in json, and the exact location can be discovered from
1716 ``plan.json``, where it is identified by ``build-info`` within the items in
1717 the ``install-plan``.
1718 Note, that this field in ``plan.json`` can be ``null``, if and only if
1719 ``build-type: Custom`` is set, and the ``Cabal`` version is too
1720 old (i.e. ``< 3.7``).
1721 If the field is missing entirely, the component is not a local one, thus,
1722 no ``build-info`` exists for that particular component within the
1726 The format and fields of the generated build information is currently experimental,
1727 in the future we might add or remove fields, depending on the needs of other tooling.
1729 .. _cmdoption-http-transport:
1730 .. cfg-field:: http-transport: curl, wget, powershell, or plain-http
1731 --http-transport=transport
1732 :synopsis: Transport to use with http(s) requests.
1736 Set a transport to be used when making http(s) requests.
1738 The command line variant of this field is ``--http-transport=curl``.
1740 If the project configuration imports remote urls, the user can only specify
1741 the http-transport option from the command line.
1743 When specifying the http-transport from the command line, the program
1744 search path can only be influenced using :ref:`--extra-prog-path<cmdoption-extra-prog-path>`.
1746 .. cfg-field:: ignore-expiry: boolean
1748 :synopsis: Ignore Hackage expiration dates.
1752 If ``True``, we will ignore expiry dates on metadata from Hackage.
1754 In general, you should not set this to ``True`` as it will leave you
1755 vulnerable to stale cache attacks. However, it may be temporarily
1756 useful if the main Hackage server is down, and we need to rely on
1757 mirrors which have not been updated for longer than the expiry
1758 period on the timestamp.
1760 The command line variant of this field is ``--ignore-expiry``.
1762 .. cfg-field:: remote-repo-cache: directory
1763 --remote-repo-cache=DIR
1764 :synopsis: Location of packages cache.
1766 :default: ``~/.cabal/packages``
1768 The location where packages downloaded from remote repositories will be
1771 The command line variant of this flag is
1772 ``--remote-repo-cache=DIR``.
1774 .. cfg-field:: logs-dir: directory
1776 :synopsis: Directory to store build logs.
1778 :default: ``~/.cabal/logs``
1780 :strike:`The location where build logs for packages are stored.`
1781 Not implemented yet.
1783 The command line variant of this flag is ``--logs-dir=DIR``.
1785 .. cfg-field:: build-summary: template filepath
1786 --build-summary=TEMPLATE
1787 :synopsis: Build summaries location.
1789 :default: ``~/.cabal/logs/build.log``
1791 :strike:`The file to save build summaries.` Not implemented yet.
1793 Valid variables which can be used in the path are ``$pkgid``,
1794 ``$compiler``, ``$os`` and ``$arch``.
1796 The command line variant of this flag is
1797 ``--build-summary=TEMPLATE``.
1799 Undocumented fields: ``root-cmd``, ``symlink-bindir``, ``build-log``,
1800 ``remote-build-reporting``, ``report-planned-failure``, ``offline``.
1802 Advanced solver options
1803 ^^^^^^^^^^^^^^^^^^^^^^^
1805 Most users generally won't need these.
1807 .. cfg-field:: solver: SOLVER
1809 :synopsis: Which solver to use.
1811 This field is reserved to allow the specification of alternative
1812 dependency solvers. At the moment, the only accepted option is
1815 The command line variant of this field is ``--solver=modular``.
1817 .. cfg-field:: max-backjumps: nat
1819 :synopsis: Maximum number of solver backjumps.
1823 Maximum number of backjumps (backtracking multiple steps) allowed
1824 while solving. Set -1 to allow unlimited backtracking, and 0 to
1825 disable backtracking completely.
1827 The command line variant of this field is ``--max-backjumps=4000``.
1829 .. cfg-field:: reorder-goals: boolean
1832 :synopsis: Allow solver to reorder goals.
1836 When enabled, the solver will reorder goals according to certain
1837 heuristics. Slows things down on average, but may make backtracking
1838 faster for some packages. It's unlikely to help for small projects,
1839 but for big install plans it may help you find a plan when otherwise
1840 this is not possible. See :issue:`1780` for more commentary.
1842 The command line variant of this field is ``--(no-)reorder-goals``.
1844 .. cfg-field:: count-conflicts: boolean
1846 --no-count-conflicts
1847 :synopsis: Solver prefers versions with less conflicts.
1851 Try to speed up solving by preferring goals that are involved in a
1854 The command line variant of this field is
1855 ``--(no-)count-conflicts``.
1857 .. cfg-field:: fine-grained-conflicts: boolean
1858 --fine-grained-conflicts
1859 --no-fine-grained-conflicts
1860 :synopsis: Skip a version of a package if it does not resolve any conflicts
1861 encountered in the last version (solver optimization).
1865 When enabled, the solver will skip a version of a package if it does not
1866 resolve any of the conflicts encountered in the last version of that
1867 package. For example, if ``foo-1.2`` depended on ``bar``, and the solver
1868 couldn't find consistent versions for ``bar``'s dependencies, then the
1869 solver would skip ``foo-1.1`` if it also depended on ``bar``.
1871 The command line variant of this field is
1872 ``--(no-)fine-grained-conflicts``.
1874 .. cfg-field:: minimize-conflict-set: boolean
1875 --minimize-conflict-set
1876 --no-minimize-conflict-set
1877 :synopsis: Try to improve the solver error message when there is no
1882 When there is no solution, try to improve the solver error message
1883 by finding a minimal conflict set. This option may increase run
1884 time significantly, so it is off by default.
1886 The command line variant of this field is
1887 ``--(no-)minimize-conflict-set``.
1889 .. cfg-field:: strong-flags: boolean
1892 :synopsis: Do not defer flag choices when solving.
1896 Do not defer flag choices. (TODO: Better documentation.)
1898 The command line variant of this field is ``--(no-)strong-flags``.
1900 .. cfg-field:: allow-boot-library-installs: boolean
1901 --allow-boot-library-installs
1902 --no-allow-boot-library-installs
1903 :synopsis: Allow cabal to install or upgrade any package.
1907 By default, the dependency solver doesn't allow ``base``,
1908 ``ghc-prim``, ``integer-simple``, ``integer-gmp``, and
1909 ``template-haskell`` to be installed or upgraded. This flag
1910 removes the restriction.
1912 The command line variant of this field is
1913 ``--(no-)allow-boot-library-installs``.
1915 .. cfg-field:: cabal-lib-version: VERSION
1916 --cabal-lib-version=VERSION
1917 :synopsis: Version of Cabal library used to build package.
1919 This field selects the version of the Cabal library which should be
1920 used to build packages. This option is intended primarily for
1921 internal development use (e.g., forcing a package to build with a
1922 newer version of Cabal, to test a new version of Cabal.) (TODO:
1923 Specify its semantics more clearly.)
1925 The command line variant of this field is
1926 ``--cabal-lib-version=1.24.0.1``.
1928 .. cfg-field:: prefer-oldest: boolean
1931 :synopsis: Prefer the oldest versions of packages available.
1936 By default, when solver has a choice of multiple versions of the same
1937 package, it will first try to derive a build plan with the latest
1938 version. This flag switches the behaviour, making the solver
1939 to prefer the oldest packages available.
1941 The primary use case is to help users in establishing lower bounds
1942 of upstream dependencies.
1944 The command line variant of this field is ``--(no-)prefer-oldest``.
1946 .. include:: references.inc