diff options
-rw-r--r-- | compiler/ghc.mk | 17 | ||||
-rw-r--r-- | compiler/parser/Parser.y.pp | 18 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | mk/config.mk.in | 2 |
4 files changed, 24 insertions, 19 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 diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 489b5affa4..634d3c76f0 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 8d8136f756..b0ada24240 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 6402ac5680..20bb1ed4fe 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 # |