Simon Hengel pushed to branch wip/sol/pp-set-ghc-version at Glasgow Haskell Compiler / GHC Commits: a80e04a1 by Simon Hengel at 2026-06-20T21:05:42+07:00 Set GHC_VERSION when calling custom pre-processors (see #25952) (so that pre-processors can emit backwards compatible code) - - - - - 2 changed files: - + changelog.d/pp-set-ghc-version - compiler/GHC/SysTools/Tasks.hs Changes: ===================================== changelog.d/pp-set-ghc-version ===================================== @@ -0,0 +1,7 @@ +section: compiler +synopsis: + Set the environment variable `GHC_VERSION` to the current GHC version when + invoking custom pre-processors, so that pre-processors can emit backwards + compatible code without relying on CPP. +issues: #25952 +mrs: !16224 ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -45,6 +45,7 @@ import GHC.ForeignSrcLang import GHC.CmmToLlvm.Version (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound) +import GHC.Version import GHC.Settings import GHC.SysTools.Process @@ -63,6 +64,7 @@ import Data.List (tails, isPrefixOf) import Data.Maybe (fromMaybe) import System.IO import System.Process +import System.Environment import GHC.Driver.Config.Diagnostic import GHC.Driver.Errors import GHC.Driver.Errors.Types (GhcMessage(..), DriverMessage (DriverNoConfiguredLLVMToolchain)) @@ -217,7 +219,8 @@ runPp :: Logger -> DynFlags -> [Option] -> IO () runPp logger dflags args = traceSystoolCommand logger "pp" $ do let prog = pgm_F dflags opts = map Option (getOpts dflags opt_F) - runSomething logger "Haskell pre-processor" prog (args ++ opts) + env <- (("GHC_VERSION", cProjectVersion) :) <$> getEnvironment + runSomethingFiltered logger id "Haskell pre-processor" prog (args ++ opts) Nothing (Just env) data CcConfig = CcConfig { ccProg :: String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a80e04a1c98b27c3046becaa26b7e427... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a80e04a1c98b27c3046becaa26b7e427... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Hengel (@sol)