summaryrefslogtreecommitdiff
path: root/compiler/ghc.mk
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2013-09-04 11:23:03 -0500
committerAustin Seipp <aseipp@pobox.com>2013-09-04 11:57:51 -0500
commit9e133b9dccec0553c6ec302d6ca0d3bc5eea06c4 (patch)
treee23214db5b114639689db8a36f61b8035fc8e128 /compiler/ghc.mk
parentba576e55f88043cda639ac2d848e1162d43ffdbe (diff)
downloadhaskell-9e133b9dccec0553c6ec302d6ca0d3bc5eea06c4.tar.gz
Make sure -fcmm-sink is passed to Parser properly
Parser.hs needs to be compiled with -fcmm-sink on x86 platforms, so the register allocator doesn't run out of stack slots. Previously, we had to do some CPP hacks in order to emit an #ifdef into the file - this is because we preprocess it once up front, and run the preprocessor again when we compile it. There's two cases: the boostrap compiler is > 7.8, and the stage1 parser needs the flag, or the stage1 compiler is compiling the stage2 Parser.hs, and needs the flag.. The previous approach was super fragile with Clang. The more principled fix is to instead do this through the build system. This fixes #8182. Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'compiler/ghc.mk')
-rw-r--r--compiler/ghc.mk17
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 2a7a8c4b87..1149fbdf1e 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -341,8 +341,23 @@ else
compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
endif
-ifeq "$(GhcProfiled)" "YES"
+# If we're bootstrapping the compiler during stage2, or we're being
+# built by a GHC whose version is > 7.8, we need -fcmm-sink to be
+# passed to the compiler. This is required on x86 to avoid the
+# register allocator running out of stack slots when compiling this
+# module with -fPIC -dynamic.
+ifeq "$(CMM_SINK_BOOTSTRAP_IS_NEEDED)" "YES"
+compiler/stage1/build/Parser_HC_OPTS += -fcmm-sink
+endif
+# However, we may be using e.g. 7.6, and thus the bootstrap compiler
+# does not need to pass -fcmm-sink, but stage1+ does!
+# We pass -fcmm-sink to every stage != 1
+# See #8182 for all the details
+compiler/stage2/build/Parser_HC_OPTS += -fcmm-sink
+compiler/stage3/build/Parser_HC_OPTS += -fcmm-sink
+
+ifeq "$(GhcProfiled)" "YES"
# If we're profiling GHC then we want SCCs. However, adding -auto-all
# everywhere tends to give a hard-to-read profile, and adds lots of
# overhead. A better approach is to proceed top-down; identify the