[commit: ghc] master: Make sure -fcmm-sink is passed to Parser properly (9e133b9)
git at git.haskell.org
git at git.haskell.org
Wed Sep 4 18:58:31 CEST 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/9e133b9dccec0553c6ec302d6ca0d3bc5eea06c4/ghc
>---------------------------------------------------------------
commit 9e133b9dccec0553c6ec302d6ca0d3bc5eea06c4
Author: Austin Seipp <aseipp at pobox.com>
Date: Wed Sep 4 11:23:03 2013 -0500
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 at pobox.com>
>---------------------------------------------------------------
9e133b9dccec0553c6ec302d6ca0d3bc5eea06c4
compiler/ghc.mk | 17 ++++++++++++++++-
compiler/parser/Parser.y.pp | 18 ------------------
configure.ac | 6 ++++++
mk/config.mk.in | 2 ++
4 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 2a7a8c4..1149fbd 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
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index 489b5af..634d3c7 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -24,24 +24,6 @@ to inline certain key external functions, so we instruct GHC not to
throw away inlinings as it would normally do in -O0 mode.
-}
--- CPP tricks because we want the directives in the output of the
--- first CPP pass.
---
--- Clang note, 6/17/2013 by aseipp: It is *extremely* important (for
--- some reason) that there be a line of whitespace between the two
--- definitions here, and the subsequent use of __IF_GHC_77__ - this
--- seems to be a bug in clang or something, where having the line of
--- whitespace will make the preprocessor correctly format the rendered
--- lines in the 'two step' CPP pass. No, this is not a joke.
-#define __IF_GHC_77__ #if __GLASGOW_HASKELL__ >= 707
-#define __ENDIF__ #endif
-
-__IF_GHC_77__
--- Required on x86 to avoid the register allocator running out of
--- stack slots when compiling this module with -fPIC -dynamic.
-{-# OPTIONS_GHC -fcmm-sink #-}
-__ENDIF__
-
module Parser ( parseModule, parseStmt, parseIdentifier, parseType,
parseHeader ) where
diff --git a/configure.ac b/configure.ac
index 8d8136f..b0ada24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,12 @@ FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.5],
GHC_PACKAGE_DB_FLAG=package-db)
AC_SUBST(GHC_PACKAGE_DB_FLAG)
+# GHC 7.7+ needs -fcmm-sink when compiling Parser.hs. See #8182
+FP_COMPARE_VERSIONS([$GhcVersion],[-gt],[7.7],
+ CMM_SINK_BOOTSTRAP_IS_NEEDED=YES,
+ CMM_SINK_BOOTSTRAP_IS_NEEDED=NO)
+AC_SUBST(CMM_SINK_BOOTSTRAP_IS_NEEDED)
+
# GHC is passed to Cabal, so we need a native path
if test "${WithGhc}" != ""
then
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 6402ac5..20bb1ed 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -471,6 +471,8 @@ endif
GHC_PACKAGE_DB_FLAG = @GHC_PACKAGE_DB_FLAG@
+CMM_SINK_BOOTSTRAP_IS_NEEDED = @CMM_SINK_BOOTSTRAP_IS_NEEDED@
+
#-----------------------------------------------------------------------------
# C compiler
#
More information about the ghc-commits
mailing list