summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-11-30 12:35:58 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2015-12-01 10:52:11 +0100
commit14d0f7f1221db758cd06a69f53803d9d0150164a (patch)
tree0df6ccac45cffee6ceaa86f275be1b3ed2d4f6a6 /mk
parentafb721390cd506f09ce9f04aa3fb19324c2ae5a0 (diff)
downloadhaskell-14d0f7f1221db758cd06a69f53803d9d0150164a.tar.gz
Build system: Add stage specific SRC_HC_(WARNING_)OPTS
* Add stage specific versions of SRC_HC_OPTS. These are currently only used for -Werror. The previous combination of GhcStage2HcOpts and GhcLibHcOpts didn't apply to utils/*. * Add stage specific versions of SRC_HC_WARNING_OPTS. These will later be used for new warning supression flags that should not be passed to the bootstrap compiler. * Move -Wall (and -Werror) related code back to mk/warnings.mk, where it was before 987d54274. Now all warning related code is nicely together. Include mk/warnings.mk after mk/custom-settings.mk to make this work. Reviewed By: bgamari, hvr Differential Revision: https://phabricator.haskell.org/D1536
Diffstat (limited to 'mk')
-rw-r--r--mk/config.mk.in49
-rw-r--r--mk/warnings.mk44
2 files changed, 75 insertions, 18 deletions
diff --git a/mk/config.mk.in b/mk/config.mk.in
index f9394429bf..967c7510a1 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -64,10 +64,36 @@ GhcHcOpts=-Rghc-timing
# Extra options added to specific stages of the compiler bootstrap.
# These are placed later on the command line, and may therefore
# override options from $(GhcHcOpts).
+#
+# See Note [Stage number in build variables].
GhcStage1HcOpts=
GhcStage2HcOpts=-O2
GhcStage3HcOpts=-O2
+# Disable -O2 optimization. Otherwise amount of generated C code
+# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
+# and sometimes not compile at all (powerpc64 overflows something
+# on 'compiler/hsSyn/HsExpr.lhs').
+ifeq "$(GhcUnregisterised)" "YES"
+GhcStage1HcOpts=
+GhcStage2HcOpts=
+GhcStage3HcOpts=
+endif
+
+# Note [Stage number in build variables].
+#
+# There are (unfortunately) two different naming schemes for build variables
+# specific to a certain stage.
+#
+# * GhcStage1HcOpts/GhcStage2HcOpts/GhcStage3HcOpts:
+#
+# The stage number refers to the compiler stage being built (ghc library
+# and executable).
+#
+# * SRC_HC_OPTS_STAGE$4 and SRC_HC_WARNING_OPTS_STAGE$4:
+#
+# The stage number refers to the compiler stage the options are passed to.
+
GhcDebugged=NO
GhcDynamic=NO
@@ -408,15 +434,20 @@ BIN_DIST_TAR_COMP = $(BIN_DIST_NAME)-$(TARGETPLATFORM).tar.$(TAR_COMP_EXT)
#
SRC_HC_OPTS += -H32m -O
-# Disable -O2 optimization. Otherwise amount of generated C code
-# makes things very slow to compile (~5 minutes on core-i7 for 'compiler/hsSyn/HsExpr.lhs')
-# and sometimes not compile at all (powerpc64 overflows something
-# on 'compiler/hsSyn/HsExpr.lhs').
-ifeq "$(GhcUnregisterised)" "YES"
-GhcStage1HcOpts=
-GhcStage2HcOpts=
-GhcStage3HcOpts=
-endif
+
+# See Note [Stage number in build variables].
+SRC_HC_OPTS_STAGE0 =
+SRC_HC_OPTS_STAGE1 =
+SRC_HC_OPTS_STAGE2 =
+
+# Warning supression flags. See mk/warnings.mk.
+SRC_CC_WARNING_OPTS =
+SRC_HC_WARNING_OPTS =
+
+# See Note [Stage number in build variables].
+SRC_HC_WARNING_OPTS_STAGE0 =
+SRC_HC_WARNING_OPTS_STAGE1 =
+SRC_HC_WARNING_OPTS_STAGE2 =
# -----------------------------------------------------------------------------
# Names of programs in the GHC tree
diff --git a/mk/warnings.mk b/mk/warnings.mk
index 267aef6a36..d604f9ae2d 100644
--- a/mk/warnings.mk
+++ b/mk/warnings.mk
@@ -1,9 +1,16 @@
-SRC_CC_WARNING_OPTS =
-SRC_HC_WARNING_OPTS =
-
+# See Note [Order of warning flags].
+SRC_CC_OPTS += -Wall $(WERROR)
+SRC_HC_OPTS += -Wall
+# Don't add -Werror to SRC_HC_OPTS_STAGE0 (or SRC_HC_OPTS), because otherwise
+# validate may unnecessarily fail when booting with an older compiler.
+# It would be better to only exclude certain warnings from becoming errors
+# (e.g. '-Werror -Wno-error=unused-imports -Wno-error=...'), but -Wno-error
+# isn't supported yet (https://ghc.haskell.org/trac/ghc/wiki/Design/Warnings).
+#
+# See Note [Stage number in build variables] in mk/config.mk.in.
+SRC_HC_OPTS_STAGE1 += $(WERROR)
+SRC_HC_OPTS_STAGE2 += $(WERROR)
-#####################
-# Warnings
ifneq "$(GccIsClang)" "YES"
@@ -25,10 +32,6 @@ SRC_CC_WARNING_OPTS += -Wno-unknown-pragmas
endif
-GhcStage1HcOpts += -fwarn-tabs
-GhcStage2HcOpts += -fwarn-tabs
-
-utils/hpc_dist-install_EXTRA_HC_OPTS += -fwarn-tabs
######################################################################
@@ -113,3 +116,26 @@ GhcBootLibExtraHcOpts += -fno-warn-deprecated-flags
#
GhcLibExtraHcOpts += -fno-warn-tabs
GhcBootLibExtraHcOpts += -fno-warn-tabs
+
+
+# Note [Order of warning flags]
+#
+# In distdir-way-opts, build flags are added in the following order (this
+# list is not exhaustive):
+#
+# * SRC_HC_OPTS(_STAGE$4)
+# * ghc-options from .cabal files ($1_$2_HC_OPTS)
+# * SRC_HC_WARNING_OPTS(_STAGE$4)
+#
+# Considerations:
+#
+# * Most .cabal files specify -Wall. But not all, and not all building we
+# do relies on .cabal files. So we have to add -Wall ourselves somewhere.
+#
+# * Some .cabal also specify warning supression flags. Because -Wall
+# overrides any warning supression flags that come before it, we have to
+# make sure -Wall comes before any warning supression flags. So we add it
+# to SRC_HC_OPTS.
+#
+# * Similarly, our own warning supression should come after the -Wall from
+# the .cabal files, so we do *not* add them to SRC_HC_OPTS.