-
Notifications
You must be signed in to change notification settings - Fork 696
/
cabal-project.rst
1526 lines (1081 loc) · 53.5 KB
/
cabal-project.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cabal.project Reference
=======================
``cabal.project`` files support a variety of options which configure the
details of your build. The general syntax of a ``cabal.project`` file is
similar to that of a Cabal file: there are a number of fields, some of
which live inside stanzas:
::
packages: */*.cabal
with-compiler: /opt/ghc/8.0.1/bin/ghc
package cryptohash
optimization: False
In general, the accepted field names coincide with the accepted command
line flags that ``cabal install`` and other commands take. For example,
``cabal v2-configure --enable-profiling`` will write out a project
file with ``profiling: True``.
The full configuration of a project is determined by combining the
following sources (later entries override earlier ones):
1. ``~/.cabal/config`` (the user-wide global configuration)
2. ``cabal.project`` (the project configuration)
3. ``cabal.project.freeze`` (the output of ``cabal v2-freeze``)
4. ``cabal.project.local`` (the output of ``cabal v2-configure``)
Specifying the local packages
-----------------------------
The following top-level options specify what the local packages of a
project are:
.. cfg-field:: packages: package location list (space or comma separated)
:synopsis: Project packages.
:default: ``./*.cabal``
Specifies the list of package locations which contain the local
packages to be built by this project. Package locations can take the
following forms:
1. They can specify a Cabal file, or a directory containing a Cabal
file, e.g., ``packages: Cabal cabal-install/cabal-install.cabal``.
2. They can specify a glob-style wildcards, which must match one or
more (a) directories containing a (single) Cabal file, (b) Cabal
files (extension ``.cabal``), or (c) tarballs which contain Cabal
packages (extension ``.tar.gz``).
For example, to match all Cabal files in all
subdirectories, as well as the Cabal projects in the parent
directories ``foo`` and ``bar``, use
``packages: */*.cabal ../{foo,bar}/``
3. They can specify an ``http``, ``https`` or ``file``
URL, representing the path to a remote tarball to be downloaded
and built.
There is no command line variant of this field; see :issue:`3585`.
.. cfg-field:: optional-packages: package location list (space or comma-separated)
:synopsis: Optional project packages.
:default: ``./*/*.cabal``
Like :cfg-field:`packages`, specifies a list of package locations
containing local packages to be built. Unlike :cfg-field:`packages`,
if we glob for a package, it is permissible for the glob to match against
zero packages. The intended use-case for :cfg-field:`optional-packages`
is to make it so that vendored packages can be automatically picked up if
they are placed in a subdirectory, but not error if there aren't any.
There is no command line variant of this field.
.. cfg-field:: extra-packages: package list with version bounds (comma separated)
:synopsis: Adds external pacakges as local
[STRIKEOUT:Specifies a list of external packages from Hackage which
should be considered local packages.] (Not implemented)
There is no command line variant of this field.
All local packages are *vendored*, in the sense that if other packages
(including external ones from Hackage) depend on a package with the name
of a local package, the local package is preferentially used. This
motivates the default settings::
packages: ./*.cabal
optional-packages: ./*/*.cabal
...any package can be vendored simply by making a checkout in the
top-level project directory, as might be seen in this hypothetical
directory layout::
foo.cabal
foo-helper/ # local package
unix/ # vendored external package
All of these options support globs. ``cabal v2-build`` has its own glob
format:
- Anywhere in a path, as many times as you like, you can specify an
asterisk ``*`` wildcard. E.g., ``*/*.cabal`` matches all ``.cabal``
files in all immediate subdirectories. Like in glob(7), asterisks do
not match hidden files unless there is an explicit period, e.g.,
``.*/foo.cabal`` will match ``.private/foo.cabal`` (but
``*/foo.cabal`` will not).
- You can use braces to specify specific directories; e.g.,
``{vendor,pkgs}/*.cabal`` matches all Cabal files in the ``vendor``
and ``pkgs`` subdirectories.
Formally, the format described by the following BNF:
.. todo::
convert globbing grammar to proper ABNF_ syntax
.. code-block:: abnf
FilePathGlob ::= FilePathRoot FilePathGlobRel
FilePathRoot ::= {- empty -} # relative to cabal.project
| "/" # Unix root
| [a-zA-Z] ":" [/\\] # Windows root
| "~" # home directory
FilePathGlobRel ::= Glob "/" FilePathGlobRel # Unix directory
| Glob "\\" FilePathGlobRel # Windows directory
| Glob # file
| {- empty -} # trailing slash
Glob ::= GlobPiece *
GlobPiece ::= "*" # wildcard
| [^*{},/\\] * # literal string
| "\\" [*{},] # escaped reserved character
| "{" Glob "," ... "," Glob "}" # union (match any of these)
Specifying Packages from Remote Version Control Locations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting with Cabal 2.4, there is now a stanza
``source-repository-package`` for specifying packages from an external
version control which supports the following fields:
- :pkg-field:`source-repository:type`
- :pkg-field:`source-repository:location`
- :pkg-field:`source-repository:tag`
- :pkg-field:`source-repository:subdir`
A simple example is shown below:
.. code-block:: cabal
packages: .
source-repository-package
type: git
location: https://github.com/hvr/HsYAML.git
tag: e70cf0c171c9a586b62b3f75d72f1591e4e6aaa1
source-repository-package
type: git
location: https://github.com/well-typed/cborg
tag: 3d274c14ca3077c3a081ba7ad57c5182da65c8c1
subdir: cborg
Global configuration options
----------------------------
The following top-level configuration options are not specific to any
package, and thus apply globally:
.. cfg-field:: verbose: nat
--verbose=n, -vn
:synopsis: Build verbosity level.
:default: 1
Control the verbosity of ``cabal`` commands, valid values are from 0
to 3.
The command line variant of this field is ``--verbose=2``; a short
form ``-v2`` is also supported.
.. cfg-field:: jobs: nat or $ncpus
--jobs=n, -jn, --jobs=$ncpus
:synopsis: Number of builds running in parallel.
:default: 1
Run *nat* jobs simultaneously when building. If ``$ncpus`` is
specified, run the number of jobs equal to the number of CPUs.
Package building is often quite parallel, so turning on parallelism
can speed up build times quite a bit!
The command line variant of this field is ``--jobs=2``; a short form
``-j2`` is also supported; a bare ``--jobs`` or ``-j`` is equivalent
to ``--jobs=$ncpus``.
.. cfg-field:: keep-going: boolean
--keep-going
:synopsis: Try to continue building on failure.
:default: False
If true, after a build failure, continue to build other unaffected
packages.
The command line variant of this field is ``--keep-going``.
.. option:: --builddir=DIR
Specifies the name of the directory where build products for
build will be stored; defaults to ``dist-newstyle``. If a
relative name is specified, this directory is resolved relative
to the root of the project (i.e., where the ``cabal.project``
file lives.)
This option cannot be specified via a ``cabal.project`` file.
.. _cmdoption-project-file:
.. option:: --project-file=FILE
Specifies the name of the project file used to specify the
rest of the top-level configuration; defaults to ``cabal.project``.
This name not only specifies the name of the main project file,
but also the auxiliary project files ``cabal.project.freeze``
and ``cabal.project.local``; for example, if you specify
``--project-file=my.project``, then the other files that will
be probed are ``my.project.freeze`` and ``my.project.local``.
If the specified project file is a relative path, we will
look for the file relative to the current working directory,
and then for the parent directory, until the project file is
found or we have hit the top of the user's home directory.
This option cannot be specified via a ``cabal.project`` file.
.. option:: --store-dir=DIR
Specifies the name of the directory of the global package store.
Solver configuration options
----------------------------
The following settings control the behavior of the dependency solver:
.. cfg-field:: constraints: constraints list (comma separated)
--constraint="pkg >= 2.0"
:synopsis: Extra dependencies constraints.
Add extra constraints to the version bounds, flag settings,
and other properties a solver can pick for a
package. For example:
::
constraints: bar == 2.1
A package can be specified multiple times in ``constraints``, in
which case the specified constraints are intersected. This is
useful, since the syntax does not allow you to specify multiple
constraints at once. For example, to specify both version bounds and
flag assignments, you would write:
::
constraints: bar == 2.1,
bar +foo -baz
Valid constraints take the same form as for the `constraint
command line option
<installing-packages.html#cmdoption-setup-configure-constraint>`__.
.. cfg-field:: preferences: preference (comma separated)
--preference="pkg >= 2.0"
:synopsis: Prefered dependency versions.
Like :cfg-field:`constraints`, but the solver will attempt to satisfy
these preferences on a best-effort basis. The resulting install is locally
optimal with respect to preferences; specifically, no single package
could be replaced with a more preferred version that still satisfies
the hard constraints.
Operationally, preferences can cause the solver to attempt certain
version choices of a package before others, which can improve
dependency solver runtime.
One way to use :cfg-field:`preferences` is to take a known working set of
constraints (e.g., via ``cabal v2-freeze``) and record them as
preferences. In this case, the solver will first attempt to use this
configuration, and if this violates hard constraints, it will try to
find the minimal number of upgrades to satisfy the hard constraints
again.
The command line variant of this field is
``--preference="pkg >= 2.0"``; to specify multiple preferences, pass
the flag multiple times.
.. cfg-field:: allow-newer: none, all or list of scoped package names (space or comma separated)
--allow-newer, --allow-newer=[none,all,[scope:][^]pkg]
:synopsis: Lift dependencies upper bound constraints.
:default: ``none``
Allow the solver to pick an newer version of some packages than
would normally be permitted by than the :pkg-field:`build-depends` bounds
of packages in the install plan. This option may be useful if the
dependency solver cannot otherwise find a valid install plan.
For example, to relax ``pkg``\ s :pkg-field:`build-depends` upper bound on
``dep-pkg``, write a scoped package name of the form:
::
allow-newer: pkg:dep-pkg
If the scope shall be limited to specific releases of ``pkg``, the
extended form as in
::
allow-newer: pkg-1.2.3:dep-pkg, pkg-1.1.2:dep-pkg
can be used to limit the relaxation of dependencies on
``dep-pkg`` by the ``pkg-1.2.3`` and ``pkg-1.1.2`` releases only.
The scoped syntax is recommended, as it is often only a single package
whose upper bound is misbehaving. In this case, the upper bounds of
other packages should still be respected; indeed, relaxing the bound
can break some packages which test the selected version of packages.
The syntax also allows to prefix the dependee package with a
modifier symbol to modify the scope/semantic of the relaxation
transformation in a additional ways. Currently only one modifier
symbol is defined, i.e. ``^`` (i.e. caret) which causes the
relaxation to be applied only to ``^>=`` operators and leave all other
version operators untouched.
However, in some situations (e.g., when attempting to build packages
on a new version of GHC), it is useful to disregard *all*
upper-bounds, with respect to a package or all packages. This can be
done by specifying just a package name, or using the keyword ``all``
to specify all packages:
::
-- Disregard upper bounds involving the dependencies on
-- packages bar, baz. For quux only, relax
-- 'quux ^>= ...'-style constraints only.
allow-newer: bar, baz, ^quux
-- Disregard all upper bounds when dependency solving
allow-newer: all
-- Disregard all `^>=`-style upper bounds when dependency solving
allow-newer: ^all
For consistency, there is also the explicit wildcard scope syntax
``*`` (or its alphabetic synonym ``all``). Consequently, the
examples above are equivalent to the explicitly scoped variants:
::
allow-newer: all:bar, *:baz, *:^quux
allow-newer: *:*
allow-newer: all:all
allow-newer: *:^*
allow-newer: all:^all
In order to ignore all bounds specified by a package ``pkg-1.2.3``
you can combine scoping with a right-hand-side wildcard like so
::
-- Disregard any upper bounds specified by pkg-1.2.3
allow-newer: pkg-1.2.3:*
-- Disregard only `^>=`-style upper bounds in pkg-1.2.3
allow-newer: pkg-1.2.3:^*
:cfg-field:`allow-newer` is often used in conjunction with a constraint
(in the cfg-field:`constraints` field) forcing the usage of a specific,
newer version of a package.
The command line variant of this field is e.g. ``--allow-newer=bar``. A
bare ``--allow-newer`` is equivalent to ``--allow-newer=all``.
.. cfg-field:: allow-older: none, all, list of scoped package names (space or comma separated)
--allow-older, --allow-older=[none,all,[scope:][^]pkg]
:synopsis: Lift dependency lower bound constraints.
:since: 2.0
:default: ``none``
Like :cfg-field:`allow-newer`, but applied to lower bounds rather than
upper bounds.
The command line variant of this field is ``--allow-older=all``. A
bare ``--allow-older`` is equivalent to ``--allow-older=all``.
.. cfg-field:: index-state: HEAD, unix-timestamp, ISO8601 UTC timestamp.
:synopsis: Use source package index state as it existed at a previous time.
:since: 2.0
:default: ``HEAD``
This allows to change the source package index state the solver uses
to compute install-plans. This is particularly useful in
combination with freeze-files in order to also freeze the state the
package index was in at the time the install-plan was frozen.
::
-- UNIX timestamp format example
index-state: @1474739268
-- ISO8601 UTC timestamp format example
-- This format is used by 'cabal v2-configure'
-- for storing `--index-state` values.
index-state: 2016-09-24T17:47:48Z
.. cfg-field:: reject-unconstrained-dependencies: all, none
--reject-unconstrained-dependencies=[all|none]
:synopsis: Restrict the solver to packages that have constraints on them.
:default: none
:since: 2.6
By default, the dependency solver can include any package that it's
aware of in a build plan. If you wish to restrict the build plan to
a closed set of packages (e.g., from a freeze file), use this flag.
When set to `all`, all non-local packages that aren't goals must be
explicitly constrained. When set to `none`, the solver will
consider all packages.
Package configuration options
-----------------------------
Package options affect the building of specific packages. There are three
ways a package option can be specified:
- They can be specified at the top-level, in which case they apply only
to **local package**, or
- They can be specified inside a ``package`` stanza, in which case they
apply to the build of the package, whether or not it is local or
external.
- They can be specified inside an ``package *`` stanza, in which case they
apply to all packages, local ones from the project and also external
dependencies.
For example, the following options specify that :cfg-field:`optimization`
should be turned off for all local packages, and that ``bytestring`` (possibly
an external dependency) should be built with ``-fno-state-hack``::
optimization: False
package bytestring
ghc-options: -fno-state-hack
``ghc-options`` is not specifically described in this documentation,
but is one of many fields for configuring programs. They take the form
``progname-options`` and ``progname-location``, and
can only be set inside package stanzas. (TODO: They are not supported
at top-level, see :issue:`3579`.)
At the moment, there is no way to specify an option to apply to all
external packages or all inplace packages. Additionally, it is only
possible to specify these options on the command line for all local
packages (there is no per-package command line interface.)
Some flags were added by more recent versions of the Cabal library. This
means that they are NOT supported by packages which use Custom setup
scripts that require a version of the Cabal library older than when the
feature was added.
.. cfg-field:: flags: list of +flagname or -flagname (space separated)
--flags="+foo -bar", -ffoo, -f-bar
:synopsis: Enable or disable package flags.
Force all flags specified as ``+flagname`` to be true, and all flags
specified as ``-flagname`` to be false. For example, to enable the
flag ``foo`` and disable ``bar``, set:
::
flags: +foo -bar
If there is no leading punctuation, it is assumed that the flag
should be enabled; e.g., this is equivalent:
::
flags: foo -bar
Flags are *per-package*, so it doesn't make much sense to specify
flags at the top-level, unless you happen to know that *all* of your
local packages support the same named flags. If a flag is not
supported by a package, it is ignored.
See also the solver configuration field :cfg-field:`constraints`.
The command line variant of this flag is ``--flags``. There is also
a shortened form ``-ffoo -f-bar``.
A common mistake is to say ``cabal v2-build -fhans``, where
``hans`` is a flag for a transitive dependency that is not in the
local package; in this case, the flag will be silently ignored. If
``haskell-tor`` is the package you want this flag to apply to, try
``--constraint="haskell-tor +hans"`` instead.
.. cfg-field:: with-compiler: executable
--with-compiler=executable
:synopsis: Path to compiler executable.
Specify the path to a particular compiler to be used. If not an
absolute path, it will be resolved according to the :envvar:`PATH`
environment. The type of the compiler (GHC, GHCJS, etc) must be
consistent with the setting of the :cfg-field:`compiler` field.
The most common use of this option is to specify a different version
of your compiler to be used; e.g., if you have ``ghc-7.8`` in your
path, you can specify ``with-compiler: ghc-7.8`` to use it.
This flag also sets the default value of :cfg-field:`with-hc-pkg`, using
the heuristic that it is named ``ghc-pkg-7.8`` (if your executable name
is suffixed with a version number), or is the executable named
``ghc-pkg`` in the same directory as the ``ghc`` directory. If this
heuristic does not work, set :cfg-field:`with-hc-pkg` explicitly.
For inplace packages, ``cabal v2-build`` maintains a separate build
directory for each version of GHC, so you can maintain multiple
build trees for different versions of GHC without clobbering each
other.
At the moment, it's not possible to set :cfg-field:`with-compiler` on a
per-package basis, but eventually we plan on relaxing this
restriction. If this is something you need, give us a shout.
The command line variant of this flag is
``--with-compiler=ghc-7.8``; there is also a short version
``-w ghc-7.8``.
.. cfg-field:: with-hc-pkg: executable
--with-hc-pkg=executable
:synopsis: Specifies package tool.
Specify the path to the package tool, e.g., ``ghc-pkg``. This
package tool must be compatible with the compiler specified by
:cfg-field:`with-compiler` (generally speaking, it should be precisely
the tool that was distributed with the compiler). If this option is
omitted, the default value is determined from :cfg-field:`with-compiler`.
The command line variant of this flag is
``--with-hc-pkg=ghc-pkg-7.8``.
.. cfg-field:: optimization: nat
--enable-optimization
--disable-optimization
:synopsis: Build with optimization.
:default: ``1``
Build with optimization. This is appropriate for production use,
taking more time to build faster libraries and programs.
The optional *nat* value is the optimisation level. Some compilers
support multiple optimisation levels. The range is 0 to 2. Level 0
disables optimization, level 1 is the default. Level 2 is higher
optimisation if the compiler supports it. Level 2 is likely to lead
to longer compile times and bigger generated code. If you are not
planning to run code, turning off optimization will lead to better
build times and less code to be rebuilt when a module changes.
When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
We also accept ``True`` (equivalent to 1) and ``False`` (equivalent
to 0).
Note that as of GHC 8.0, GHC does not recompile when optimization
levels change (see :ghc-ticket:`10923`), so if
you change the optimization level for a local package you may need
to blow away your old build products in order to rebuild with the
new optimization level.
The command line variant of this flag is ``-O2`` (with ``-O1``
equivalent to ``-O``). There are also long-form variants
``--enable-optimization`` and ``--disable-optimization``.
.. cfg-field:: configure-options: args (space separated)
--configure-option=arg
:synopsis: Options to pass to configure script.
A list of extra arguments to pass to the external ``./configure``
script, if one is used. This is only useful for packages which have
the ``Configure`` build type. See also the section on
`system-dependent
parameters <developing-packages.html#system-dependent-parameters>`__.
The command line variant of this flag is ``--configure-option=arg``,
which can be specified multiple times to pass multiple options.
.. cfg-field:: compiler: ghc, ghcjs, jhc, lhc, uhc or haskell-suite
--compiler=compiler
:synopsis: Compiler to build with.
:default: ``ghc``
Specify which compiler toolchain to be used. This is independent of
``with-compiler``, because the choice of toolchain affects Cabal's
build logic.
The command line variant of this flag is ``--compiler=ghc``.
.. cfg-field:: tests: boolean
--enable-tests
--disable-tests
:synopsis: Build tests.
:default: ``False``
Force test suites to be enabled. For most users this should not be
needed, as we always attempt to solve for test suite dependencies,
even when this value is ``False``; furthermore, test suites are
automatically enabled if they are requested as a built target.
The command line variant of this flag is ``--enable-tests`` and
``--disable-tests``.
.. cfg-field:: benchmarks: boolean
--enable-benchmarks
--disable-benchmarks
:synopsis: Build benchmarks.
:default: ``False``
Force benchmarks to be enabled. For most users this should not be
needed, as we always attempt to solve for benchmark dependencies,
even when this value is ``False``; furthermore, benchmarks are
automatically enabled if they are requested as a built target.
The command line variant of this flag is ``--enable-benchmarks`` and
``--disable-benchmarks``.
.. cfg-field:: extra-prog-path: paths (newline or comma separated)
--extra-prog-path=PATH
:synopsis: Add directories to program search path.
:since: 1.18
A list of directories to search for extra required programs. Most
users should not need this, as programs like ``happy`` and ``alex``
will automatically be installed and added to the path. This can be
useful if a ``Custom`` setup script relies on an exotic extra
program.
The command line variant of this flag is ``--extra-prog-path=PATH``,
which can be specified multiple times.
.. cfg-field:: run-tests: boolean
--run-tests
:synopsis: Run package test suite upon installation.
:default: ``False``
Run the package test suite upon installation. This is useful for
saying "When this package is installed, check that the test suite
passes, terminating the rest of the build if it is broken."
.. warning::
One deficiency: the :cfg-field:`run-tests` setting of a package is NOT
recorded as part of the hash, so if you install something without
:cfg-field:`run-tests` and then turn on ``run-tests``, we won't
subsequently test the package. If this is causing you problems, give
us a shout.
The command line variant of this flag is ``--run-tests``.
Object code options
^^^^^^^^^^^^^^^^^^^
.. cfg-field:: debug-info: integer
--enable-debug-info=<n>
--disable-debug-info
:synopsis: Build with debug info enabled.
:since: 1.22
:default: False
If the compiler (e.g., GHC 7.10 and later) supports outputing OS
native debug info (e.g., DWARF), setting ``debug-info: True`` will
instruct it to do so. See the GHC wiki page on :ghc-wiki:`DWARF`
for more information about this feature.
(This field also accepts numeric syntax, but until GHC 8.2 this didn't
do anything.)
The command line variant of this flag is ``--enable-debug-info`` and
``--disable-debug-info``.
.. cfg-field:: split-sections: boolean
--enable-split-sections
--disable-split-sections
:synopsis: Use GHC's split sections feature.
:since: 2.2
:default: False
Use the GHC ``-split-sections`` feature when building the library. This
reduces the final size of the executables that use the library by
allowing them to link with only the bits that they use rather than
the entire library. The downside is that building the library takes
longer and uses a bit more memory.
This feature is supported by GHC 8.0 and later.
The command line variant of this flag is ``--enable-split-sections`` and
``--disable-split-sections``.
.. cfg-field:: split-objs: boolean
--enable-split-objs
--disable-split-objs
:synopsis: Use GHC's split objects feature.
:default: False
Use the GHC ``-split-objs`` feature when building the library. This
reduces the final size of the executables that use the library by
allowing them to link with only the bits that they use rather than
the entire library. The downside is that building the library takes
longer and uses considerably more memory.
It is generally recommend that you use ``split-sections`` instead
of ``split-objs`` where possible.
The command line variant of this flag is ``--enable-split-objs`` and
``--disable-split-objs``.
.. cfg-field:: executable-stripping: boolean
--enable-executable-stripping
--disable-executable-stripping
:synopsis: Strip installed programs.
:default: True
When installing binary executable programs, run the ``strip``
program on the binary. This can considerably reduce the size of the
executable binary file. It does this by removing debugging
information and symbols.
Not all Haskell implementations generate native binaries. For such
implementations this option has no effect.
If ``debug-info`` is set explicitly then ``executable-stripping`` is set
to ``False`` as otherwise all the debug symbols will be stripped.
The command line variant of this flag is
``--enable-executable-stripping`` and
``--disable-executable-stripping``.
.. cfg-field:: library-stripping: boolean
--enable-library-stripping
--disable-library-stripping
:synopsis: Strip installed libraries.
:since: 1.20
When installing binary libraries, run the ``strip`` program on the
binary, saving space on the file system. See also
``executable-stripping``.
If ``debug-info`` is set explicitly then ``library-stripping`` is set
to ``False`` as otherwise all the debug symbols will be stripped.
The command line variant of this flag is
``--enable-library-stripping`` and ``--disable-library-stripping``.
Executable options
^^^^^^^^^^^^^^^^^^
.. cfg-field:: program-prefix: prefix
--program-prefix=prefix
:synopsis: Prepend prefix to program names.
[STRIKEOUT:Prepend *prefix* to installed program names.] (Currently
implemented in a silly and not useful way. If you need this to work
give us a shout.)
*prefix* may contain the following path variables: ``$pkgid``,
``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
``$abitag``
The command line variant of this flag is ``--program-prefix=foo-``.
.. cfg-field:: program-suffix: suffix
--program-suffix=suffix
:synopsis: Append refix to program names.
[STRIKEOUT:Append *suffix* to installed program names.] (Currently
implemented in a silly and not useful way. If you need this to work
give us a shout.)
The most obvious use for this is to append the program's version
number to make it possible to install several versions of a program
at once: ``program-suffix: $version``.
*suffix* may contain the following path variables: ``$pkgid``,
``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
``$abitag``
The command line variant of this flag is
``--program-suffix='$version'``.
Dynamic linking options
^^^^^^^^^^^^^^^^^^^^^^^
.. cfg-field:: shared: boolean
--enable-shared
--disable-shared
:synopsis: Build shared library.
:default: False
Build shared library. This implies a separate compiler run to
generate position independent code as required on most platforms.
The command line variant of this flag is ``--enable-shared`` and
``--disable-shared``.
.. cfg-field:: executable-dynamic: boolean
--enable-executable-dynamic
--disable-executable-dynamic
:synopsis: Link executables dynamically.
:default: False
Link executables dynamically. The executable's library dependencies
should be built as shared objects. This implies ``shared: True``
unless ``shared: False`` is explicitly specified.
The command line variant of this flag is
``--enable-executable-dynamic`` and
``--disable-executable-dynamic``.
.. cfg-field:: library-for-ghci: boolean
--enable-library-for-ghci
--disable-library-for-ghci
:synopsis: Build libraries suitable for use with GHCi.
:default: True
Build libraries suitable for use with GHCi. This involves an extra
linking step after the build.
Not all platforms support GHCi and indeed on some platforms, trying
to build GHCi libs fails. In such cases, consider setting
``library-for-ghci: False``.
The command line variant of this flag is
``--enable-library-for-ghci`` and ``--disable-library-for-ghci``.
.. cfg-field:: relocatable:
--relocatable
:synopsis: Build relocatable package.
:since: 1.22
:default: False
[STRIKEOUT:Build a package which is relocatable.] (TODO: It is not
clear what this actually does, or if it works at all.)
The command line variant of this flag is ``--relocatable``.
Static linking options
^^^^^^^^^^^^^^^^^^^^^^
.. cfg-field:: static: boolean
--enable-static
--disable-static
:synopsis: Build static library.
:default: False
Roll this and all dependent libraries into a combined ``.a`` archive.
This uses GHCs ``-staticlib`` flag, which is available for iOS and with
GHC 8.4 and later for other platforms as well.
.. cfg-field:: executable-static: boolean
--enable-executable-static
--disable-executable-static
:synopsis: Build fully static executables.
:default: False
Build fully static executables.
This link all dependent libraries into executables statically,
including libc.
This passes ``-static`` and ``-optl=-static`` to GHC.
Foreign function interface options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. cfg-field:: extra-include-dirs: directories (comma or newline separated list)
--extra-include-dirs=DIR
:synopsis: Adds C header search path.
An extra directory to search for C header files. You can use this
flag multiple times to get a list of directories.
You might need to use this flag if you have standard system header
files in a non-standard location that is not mentioned in the
package's ``.cabal`` file. Using this option has the same affect as
appending the directory *dir* to the :pkg-field:`include-dirs` field in each
library and executable in the package's ``.cabal`` file. The
advantage of course is that you do not have to modify the package at
all. These extra directories will be used while building the package
and for libraries it is also saved in the package registration
information and used when compiling modules that use the library.
The command line variant of this flag is
``--extra-include-dirs=DIR``, which can be specified multiple times.
.. cfg-field:: extra-lib-dirs: directories (comma or newline separated list)
--extra-lib-dirs=DIR
:synopsis: Adds library search directory.
An extra directory to search for system libraries files.
The command line variant of this flag is ``--extra-lib-dirs=DIR``,
which can be specified multiple times.
.. cfg-field:: extra-framework-dirs: directories (comma or newline separated list)
--extra-framework-dirs=DIR
:synopsis: Adds framework search directory (OS X only).
An extra directory to search for frameworks (OS X only).
You might need to use this flag if you have standard system
libraries in a non-standard location that is not mentioned in the
package's ``.cabal`` file. Using this option has the same affect as
appending the directory *dir* to the :cfg-field:`extra-lib-dirs` field in
each library and executable in the package's ``.cabal`` file. The
advantage of course is that you do not have to modify the package at
all. These extra directories will be used while building the package
and for libraries it is also saved in the package registration
information and used when compiling modules that use the library.
The command line variant of this flag is
``--extra-framework-dirs=DIR``, which can be specified multiple
times.
Profiling options
^^^^^^^^^^^^^^^^^
.. cfg-field:: profiling: boolean
--enable-profiling
--disable-profiling
:synopsis: Enable profiling builds.
:since: 1.22
:default: False
Build libraries and executables with profiling enabled (for
compilers that support profiling as a separate mode). It is only
necessary to specify :cfg-field:`profiling` for the specific package you
want to profile; ``cabal v2-build`` will ensure that all of its
transitive dependencies are built with profiling enabled.
To enable profiling for only libraries or executables, see
:cfg-field:`library-profiling` and :cfg-field:`executable-profiling`.
For useful profiling, it can be important to control precisely what
cost centers are allocated; see :cfg-field:`profiling-detail`.
The command line variant of this flag is ``--enable-profiling`` and
``--disable-profiling``.
.. cfg-field:: profiling-detail: level
--profiling-detail=level
:synopsis: Profiling detail level.
:since: 1.24