Define GHC_STAGE in headers instead of command-line
authorBen Gamari <ben@smart-cactus.org>
Fri, 4 Oct 2019 00:41:44 +0000 (20:41 -0400)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Wed, 9 Oct 2019 20:21:14 +0000 (16:21 -0400)
compiler/ghc.mk
hadrian/src/Rules/Generate.hs
hadrian/src/Settings/Packages.hs
includes/ghc.mk

index 8703e24..de14a01 100644 (file)
@@ -93,7 +93,7 @@ compiler/stage$1/build/Config.hs : mk/config.mk mk/project.mk | $$$$(dir $$$$@)/
        @echo 'cBooterVersion        = "$(GhcVersion)"'                     >> $$@
        @echo                                                               >> $$@
        @echo 'cStage                :: String'                             >> $$@
-       @echo 'cStage                = show (GHC_STAGE :: Int)'             >> $$@
+       @echo 'cStage                = show ($1 :: Int)'                    >> $$@
        @echo done.
 endef
 
@@ -270,11 +270,6 @@ endif
 
 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
 
-compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DGHC_STAGE=1
-compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHC_STAGE=2
-compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DGHC_STAGE=3
-compiler_stage2_HADDOCK_OPTS += --optghc=-DGHC_STAGE=2
-
 compiler/stage1/package-data.mk : compiler/ghc.mk
 compiler/stage2/package-data.mk : compiler/ghc.mk
 compiler/stage3/package-data.mk : compiler/ghc.mk
index 3e48152..3faafba 100644 (file)
@@ -239,6 +239,8 @@ generateGhcPlatformH = do
         [ "#if !defined(__GHCPLATFORM_H__)"
         , "#define __GHCPLATFORM_H__"
         , ""
+        , "#define GHC_STAGE " ++ show (fromEnum stage + 1)
+        , ""
         , "#define BuildPlatform_TYPE  " ++ cppify buildPlatform
         , "#define HostPlatform_TYPE   " ++ cppify hostPlatform
         , ""
@@ -369,7 +371,7 @@ generateConfigHs = do
         , "cBooterVersion        = " ++ show cBooterVersion
         , ""
         , "cStage                :: String"
-        , "cStage                = show (GHC_STAGE :: Int)"
+        , "cStage                = show (" ++ show (fromEnum stage + 1) ++ " :: Int)"
         ]
 
 -- | Generate @ghcautoconf.h@ header.
index 6c6b000..94a5864 100644 (file)
@@ -58,8 +58,7 @@ packageArgs = do
               pure ["-O0"] ]
 
           , builder (Cabal Setup) ? mconcat
-            [ arg $ "--ghc-option=-DGHC_STAGE=" ++ show (fromEnum stage + 1)
-            , arg "--disable-library-for-ghci"
+            [ arg "--disable-library-for-ghci"
             , anyTargetOs ["openbsd"] ? arg "--ld-options=-E"
             , flag GhcUnregisterised ? arg "--ghc-option=-DNO_REGS"
             , notM ghcWithSMP ? arg "--ghc-option=-DNOSMP"
index a19e610..eee7212 100644 (file)
@@ -179,6 +179,8 @@ $$(includes_$1_H_PLATFORM) : includes/ghc.mk includes/Makefile | $$$$(dir $$$$@)
        @echo "#if !defined(__GHCPLATFORM_H__)"                      > $$@
        @echo "#define __GHCPLATFORM_H__"                           >> $$@
        @echo                                                       >> $$@
+       @echo "#define GHC_STAGE $1"                                >> $$@
+       @echo                                                       >> $$@
        @echo "#define BuildPlatform_TYPE  $(BuildPlatform_$1_CPP)" >> $$@
        @echo "#define HostPlatform_TYPE   $(HostPlatform_$1_CPP)"  >> $$@
        @echo                                                       >> $$@