Fix closeOverKinds to use unclosed sets internally
[ghc.git] / mk / warnings.mk
1 # See Note [Order of warning flags].
2 SRC_CC_OPTS += -Wall $(WERROR)
3 SRC_HC_OPTS += -Wall
4 # Don't add -Werror to SRC_HC_OPTS_STAGE0 (or SRC_HC_OPTS), because otherwise
5 # validate may unnecessarily fail when booting with an older compiler.
6 # It would be better to only exclude certain warnings from becoming errors
7 # (e.g. '-Werror -Wno-error=unused-imports -Wno-error=...'), but -Wno-error
8 # isn't supported yet (https://ghc.haskell.org/trac/ghc/wiki/Design/Warnings).
9 #
10 # See Note [Stage number in build variables] in mk/config.mk.in.
11 SRC_HC_OPTS_STAGE1 += $(WERROR)
12 SRC_HC_OPTS_STAGE2 += $(WERROR)
13
14 # Enable -Wcpp-undef for GHC components only, as we don't (currently) expect
15 # core libraries to build in this configuration (see #13636).
16 GhcRtsHcOpts += -Wcpp-undef
17 GhcStage1HcOpts += -Wcpp-undef
18 GhcStage2HcOpts += -Wcpp-undef
19
20 ifneq "$(GccIsClang)" "YES"
21
22 # Debian doesn't turn -Werror=unused-but-set-variable on by default, so
23 # we turn it on explicitly for consistency with other users
24 ifeq "$(GccLT46)" "NO"
25 # Never set the flag on Windows as the host gcc may be too old.
26 ifneq "$(HostOS_CPP)" "mingw32"
27 SRC_CC_WARNING_OPTS += -Werror=unused-but-set-variable
28 endif
29 endif
30
31 # Suppress the warning about __sync_fetch_and_nand (#9678).
32 libraries/ghc-prim/cbits/atomic_CC_OPTS += -Wno-sync-nand
33 # gcc 4.6 gives 3 warnings for giveCapabilityToTask not being inlined
34 # gcc 4.4 gives 2 warnings for lockClosure not being inlined
35 SRC_CC_WARNING_OPTS += -Wno-error=inline
36
37 else
38
39 # Don't warn about unknown GCC pragmas when using clang
40 SRC_CC_WARNING_OPTS += -Wno-unknown-pragmas
41
42 endif
43
44 SRC_HC_WARNING_OPTS_STAGE1 += -Wnoncanonical-monad-instances
45 SRC_HC_WARNING_OPTS_STAGE2 += -Wnoncanonical-monad-instances
46
47
48 ######################################################################
49 # Disable some warnings in packages we use
50
51 # NB: The GHC version used for bootstrapping may not support the
52 # `-W`-aliases for `-f(no-)warn` flags introduced in GHC 8.0, so in
53 # some cases (watch out for make-variables with a name containing
54 # "boot") we need to pass the legacy `-f(no-)warn`-flags instead.
55
56 # Libraries that have dubious RULES
57 libraries/bytestring_dist-install_EXTRA_HC_OPTS += -Wno-inline-rule-shadowing
58
59 # Turn off import warnings for bad unused imports
60 utils/haddock_dist_EXTRA_HC_OPTS += -Wno-unused-imports
61 libraries/vector_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
62 libraries/directory_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
63
64 # haddock's attoparsec uses deprecated `inlinePerformIO`
65 utils/haddock_dist_EXTRA_HC_OPTS += -Wno-deprecations
66 # binary too
67 libraries/binary_dist-install_EXTRA_HC_OPTS += -Wno-deprecations
68
69 # On Windows, there are/were some unused import warnings
70 ifeq "$(HostOS_CPP)" "mingw32"
71 libraries/time_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports -Wno-identities
72 endif
73
74 # On Windows, the pattern for CallConv is already exaustive. Ignore the warning
75 ifeq "$(HostOS_CPP)" "mingw32"
76 libraries/ghci_dist-install_EXTRA_HC_OPTS += -Wno-overlapping-patterns
77 endif
78
79 # haskeline has warnings about deprecated use of block/unblock
80 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-deprecations
81 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
82 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-redundant-constraints
83 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-simplifiable-class-constraints
84
85
86 # temporarily turn off unused-imports warnings for pretty
87 libraries/pretty_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
88
89 # primitive has a warning about deprecated use of GHC.IOBase
90 libraries/primitive_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
91 # primitive uses deprecated Control.Monad.Trans.Error
92 libraries/primitive_dist-install_EXTRA_HC_OPTS += -Wno-deprecations
93
94 # See https://github.com/haskell/random/pull/20
95 libraries/random_dist-install_EXTRA_HC_OPTS += -Wno-redundant-constraints
96
97 # temporarily turn off unused-imports warnings for terminfo
98 libraries/terminfo_dist-boot_EXTRA_HC_OPTS += -fno-warn-unused-imports
99 libraries/terminfo_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
100
101 # vector has some unused match warnings
102 libraries/vector_dist-install_EXTRA_HC_OPTS += -Wwarn
103
104 # temporarily turn off unused-imports warnings for xhtml
105 libraries/xhtml_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
106 libraries/xhtml_dist-install_EXTRA_HC_OPTS += -Wno-tabs
107
108 libraries/dph/dph-base_dist-install_EXTRA_HC_OPTS += -Wwarn
109 libraries/dph/dph-prim-interface_dist-install_EXTRA_HC_OPTS += -Wwarn
110 libraries/dph/dph-prim-seq_dist-install_EXTRA_HC_OPTS += -Wwarn
111 libraries/dph/dph-prim-par_dist-install_EXTRA_HC_OPTS += -Wwarn
112 libraries/dph/dph-lifted-common-install_EXTRA_HC_OPTS += -Wwarn
113
114 # transformers has unused function parameters warnings
115 libraries/transformers_dist-boot_EXTRA_HC_OPTS += -fno-warn-unused-matches -fno-warn-unused-imports
116 libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-unused-matches -Wno-unused-imports
117 libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-redundant-constraints
118 libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-orphans
119
120 # parsec has various warnings
121 libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-name-shadowing -Wno-unused-matches
122 libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-unused-do-bind -Wno-missing-signatures
123 libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports -Wno-type-defaults
124
125 # Turn of trustworthy-safe warning
126 libraries/base_dist-install_EXTRA_HC_OPTS += -Wno-trustworthy-safe
127 libraries/ghc-prim_dist-install_EXTRA_HC_OPTS += -Wno-trustworthy-safe
128 libraries/Win32_dist-install_EXTRA_HC_OPTS += -Wno-trustworthy-safe
129
130 # We need -Wno-deprecated-flags to avoid failure with -Werror
131 GhcLibExtraHcOpts += -Wno-deprecated-flags
132 GhcBootLibExtraHcOpts += -fno-warn-deprecated-flags
133
134 # Note [Order of warning flags]
135 #
136 # In distdir-way-opts, build flags are added in the following order (this
137 # list is not exhaustive):
138 #
139 # * SRC_HC_OPTS(_STAGE$4)
140 # * ghc-options from .cabal files ($1_$2_HC_OPTS)
141 # * SRC_HC_WARNING_OPTS(_STAGE$4)
142 #
143 # Considerations:
144 #
145 # * Most .cabal files specify -Wall. But not all, and not all building we
146 # do relies on .cabal files. So we have to add -Wall ourselves somewhere.
147 #
148 # * Some .cabal also specify warning suppression flags. Because -Wall
149 # overrides any warning suppression flags that come before it, we have to
150 # make sure -Wall comes before any warning suppression flags. So we add it
151 # to SRC_HC_OPTS.
152 #
153 # * Similarly, our own warning suppression should come after the -Wall from
154 # the .cabal files, so we do *not* add them to SRC_HC_OPTS.