diff --git a/.gitignore b/.gitignore index c860ecd9cbc5ebfb52686fc9d854ced31a90179a..46fb24d4a995c14922ae1378cf1bcbd5f4438938 100644 --- a/.gitignore +++ b/.gitignore @@ -108,6 +108,7 @@ _darcs/ /compiler/FunTypes.h /compiler/MachDeps.h /compiler/MachRegs.h +/compiler/ghc-llvm-version.h /compiler/ghc.cabal /compiler/ghc.cabal.old /distrib/configure.ac diff --git a/compiler/GHC/CmmToLlvm/Base.hs b/compiler/GHC/CmmToLlvm/Base.hs index 2095e3d606a491388cfee54fd68257321f8b5583..33798acf72f55c462bca0ad08c3e0059053988f2 100644 --- a/compiler/GHC/CmmToLlvm/Base.hs +++ b/compiler/GHC/CmmToLlvm/Base.hs @@ -39,7 +39,7 @@ module GHC.CmmToLlvm.Base ( aliasify, llvmDefLabel ) where -#include "ghcautoconf.h" +#include "ghc-llvm-version.h" import GHC.Prelude import GHC.Utils.Panic diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs index 262ddd3ada9dbf6190ca58734baba318877a4272..1b2f21c4154c3c18a0273b713783bf31f2a63036 100644 --- a/compiler/GHC/Data/FastString.hs +++ b/compiler/GHC/Data/FastString.hs @@ -111,9 +111,6 @@ module GHC.Data.FastString lengthPS ) where --- For GHC_STAGE -#include "ghcplatform.h" - import GHC.Prelude as Prelude import GHC.Utils.Encoding @@ -143,7 +140,7 @@ import Data.Semigroup as Semi import Foreign -#if GHC_STAGE >= 2 +#if MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) import GHC.Conc.Sync (sharedCAF) #endif @@ -384,13 +381,14 @@ stringTable = unsafePerformIO $ do -- use the support wired into the RTS to share this CAF among all images of -- libHSghc -#if GHC_STAGE < 2 +#if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) return tab #else sharedCAF tab getOrSetLibHSghcFastStringTable --- from the RTS; thus we cannot use this mechanism when GHC_STAGE<2; the previous --- RTS might not have this symbol +-- from the 9.3 RTS; the previouss RTS before might not have this symbol. The +-- right way to do this however would be to define some HAVE_FAST_STRING_TABLE +-- or similar rather than use (odd parity) development versions. foreign import ccall unsafe "getOrSetLibHSghcFastStringTable" getOrSetLibHSghcFastStringTable :: Ptr a -> IO (Ptr a) #endif diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs index 55b6a2897055dd0bbfcfe67793f825d02e9e324e..53bf0333fb30288a6278ea801ea2ae8db39ef85f 100644 --- a/compiler/GHC/Driver/Pipeline.hs +++ b/compiler/GHC/Driver/Pipeline.hs @@ -48,7 +48,6 @@ module GHC.Driver.Pipeline ( ) where -#include "ghcplatform.h" import GHC.Prelude import GHC.Platform diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 25aac65d8535ce824d9b9846d6eba3923ed8d7e2..08a63c01252ffef62ef1d0d1ecb2b5e84b615e82 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -5,7 +5,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GADTs #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -#include "ghcplatform.h" +#include <ghcplatform.h> {- Functions for providing the default interpretation of the 'TPhase' actions -} diff --git a/compiler/GHC/Utils/GlobalVars.hs b/compiler/GHC/Utils/GlobalVars.hs index 19496d5d8213f8871b04f776a1d609e297e71d05..ad02bc45b1bcaa2fd6292ff03649a47416bfdb06 100644 --- a/compiler/GHC/Utils/GlobalVars.hs +++ b/compiler/GHC/Utils/GlobalVars.hs @@ -22,9 +22,6 @@ module GHC.Utils.GlobalVars ) where --- For GHC_STAGE -#include "ghcplatform.h" - import GHC.Prelude import GHC.Conc.Sync ( sharedCAF ) @@ -60,7 +57,7 @@ foreign import ccall unsafe saccessor \ -#if GHC_STAGE < 2 +#if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) GLOBAL_VAR(v_unsafeHasPprDebug, False, Bool) GLOBAL_VAR(v_unsafeHasNoDebugOutput, False, Bool) diff --git a/compiler/cbits/genSym.c b/compiler/cbits/genSym.c index 19697de25e819b298a242cd3ecc4cbb7545417b7..9bdadc5a990dfe9fa04808a1ddc610e50321fdd9 100644 --- a/compiler/cbits/genSym.c +++ b/compiler/cbits/genSym.c @@ -1,11 +1,14 @@ #include <Rts.h> #include <assert.h> #include "Unique.h" -#include "ghcversion.h" +#include <ghcversion.h> // These global variables have been moved into the RTS. It allows them to be // shared with plugins even if two different instances of the GHC library are // loaded at the same time (#19940) +// +// The CPP is thus about the RTS version GHC is linked against, and not the +// version of the GHC being built. #if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) HsInt ghc_unique_counter = 0; HsInt ghc_unique_inc = 1; diff --git a/compiler/ghc-llvm-version.h.in b/compiler/ghc-llvm-version.h.in new file mode 100644 index 0000000000000000000000000000000000000000..241ce53e32a75a629bd7ae077698b78e9fe6e548 --- /dev/null +++ b/compiler/ghc-llvm-version.h.in @@ -0,0 +1,12 @@ +#if !defined(__GHC_LLVM_VERSION_H__) +#define __GHC_LLVM_VERSION_H__ + +/* The maximum supported LLVM version number */ +#undef sUPPORTED_LLVM_VERSION_MAX + +/* The minimum supported LLVM version number */ +#undef sUPPORTED_LLVM_VERSION_MIN + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +#undef size_t +#endif /* __GHC_LLVM_VERSION_H__ */ diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index 0fed86620bb9598bf7eda34b5a499c5cc9f37b09..19ade29336a26bc1096a0ba28ce30fc7ff8cbc84 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -78,6 +78,7 @@ Library -- MachRegs.h -- hits #error, skip -- target sensative, should not be used MachDeps.h + ghc-llvm-version.h Build-Depends: base >= 4.11 && < 4.17, deepseq >= 1.4 && < 1.5, diff --git a/configure.ac b/configure.ac index 634210b15129a4111b90cca7a266ac114afb60d4..bb0ab606ccdd370899083255d6f67d944a7a8219 100644 --- a/configure.ac +++ b/configure.ac @@ -71,8 +71,11 @@ AC_PREREQ([2.69]) # ------------------------------------------------------------------------- # Prepare to generate the following header files # -# + +# This one is autogenerated by autoheader. AC_CONFIG_HEADER(mk/config.h) +# This one is manually maintained. +AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 5247c8b4ae527fbda29271131a268a28ce89740f..782ae63803e371951ad1d1685c479d47b0c0e2b8 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -254,8 +254,6 @@ 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 , "" diff --git a/libraries/ghc-boot/GHC/Data/ShortText.hs b/libraries/ghc-boot/GHC/Data/ShortText.hs index 108b5a43cd1e3bde48644b6ce34f3d292d6f564e..815c3edb6432b120f2fa18240d65fa8cbf9a5907 100644 --- a/libraries/ghc-boot/GHC/Data/ShortText.hs +++ b/libraries/ghc-boot/GHC/Data/ShortText.hs @@ -14,7 +14,7 @@ -- -- This can be removed when we exit the boot compiler window. Thus once we drop GHC-9.2 as boot compiler, -- we can drop this code as well. -#if GHC_STAGE < 1 +#if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) {-# OPTIONS_GHC -fignore-interface-pragmas #-} #endif -- | diff --git a/rts/include/ghc.mk b/rts/include/ghc.mk index 7c26499ce4c36de4e3700e862b30575928d2c26e..a04d5dbc1c0d746c5c9333d642b7a3570b9c7935 100644 --- a/rts/include/ghc.mk +++ b/rts/include/ghc.mk @@ -179,8 +179,6 @@ $$(includes_$1_H_PLATFORM) : rts/include/ghc.mk rts/include/Makefile | $$$$(dir @echo "#if !defined(__GHCPLATFORM_H__)" > $$@ @echo "#define __GHCPLATFORM_H__" >> $$@ @echo >> $$@ - @echo "#define GHC_STAGE ($1 + 1)" >> $$@ - @echo >> $$@ @echo "#define BuildPlatform_TYPE $(BuildPlatform_$1_CPP)" >> $$@ @echo "#define HostPlatform_TYPE $(HostPlatform_$1_CPP)" >> $$@ @echo >> $$@ diff --git a/utils/iserv/cbits/iservmain.c b/utils/iserv/cbits/iservmain.c index d88d14e0d63a6f69f8225965f173d8828519cb35..b182f9f54955b96f7156a0ecf91e89b1d61f9a05 100644 --- a/utils/iserv/cbits/iservmain.c +++ b/utils/iserv/cbits/iservmain.c @@ -1,4 +1,5 @@ -#if GHC_STAGE > 1 +#include <ghcversion.h> +#if MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) # include <rts/PosixSource.h> #else // PosixSource.h not yet exposed, hacky inline for now. # include <ghcplatform.h>