diff --git a/ChangeLog.md b/ChangeLog.md index b30ae31d7d..6755b002d4 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,8 @@ Other enhancements: Bug fixes: +* GHC source builds work properly for recent GHC versions again. See + [#5528](https://github.com/commercialhaskell/stack/issues/5528) ## v2.7.1 diff --git a/doc/yaml_configuration.md b/doc/yaml_configuration.md index f73b2f01bc..898f5c777d 100644 --- a/doc/yaml_configuration.md +++ b/doc/yaml_configuration.md @@ -531,7 +531,7 @@ extra-deps: #### Bootstrapping compiler Building GHC from source requires a working GHC (known as the bootstrap -compiler). As we use a Stack based version of Hadrian (`hadrian/build.stack.sh` in +compiler). As we use a Stack based version of Hadrian (`hadrian/build-stack` in GHC sources), the bootstrap compiler is configured into `hadrian/stack.yaml` and fully managed by Stack. diff --git a/src/Stack/Constants.hs b/src/Stack/Constants.hs index ba979bc39f..594528bcfb 100644 --- a/src/Stack/Constants.hs +++ b/src/Stack/Constants.hs @@ -115,8 +115,8 @@ module Stack.Constants ,relFileStackDotTmpDotExe ,relFileStackDotTmp ,ghcShowOptionsOutput - ,hadrianCmdWindows - ,hadrianCmdPosix + ,hadrianScriptsWindows + ,hadrianScriptsPosix ,usrLibDirs ,testGhcEnvRelFile ,relFileBuildLock @@ -533,13 +533,15 @@ ghcShowOptionsOutput :: [String] ghcShowOptionsOutput = $(TH.runIO (readProcess "ghc" ["--show-options"] "") >>= TH.lift . lines) --- | Relative path inside a GHC repo to the Hadrian build batch script -hadrianCmdWindows :: Path Rel File -hadrianCmdWindows = $(mkRelFile "hadrian/build.stack.bat") +-- | Relative paths inside a GHC repo to the Hadrian build batch script. +-- The second path is maintained for compatibility with older GHC versions. +hadrianScriptsWindows :: [Path Rel File] +hadrianScriptsWindows = [$(mkRelFile "hadrian/build-stack.bat"), $(mkRelFile "hadrian/build.stack.bat")] --- | Relative path inside a GHC repo to the Hadrian build shell script -hadrianCmdPosix :: Path Rel File -hadrianCmdPosix = $(mkRelFile "hadrian/build.stack.sh") +-- | Relative paths inside a GHC repo to the Hadrian build shell script +-- The second path is maintained for compatibility with older GHC versions. +hadrianScriptsPosix :: [Path Rel File] +hadrianScriptsPosix = [$(mkRelFile "hadrian/build-stack"), $(mkRelFile "hadrian/build.stack.sh")] -- | Used in Stack.Setup for detecting libtinfo, see comments at use site usrLibDirs :: [Path Abs Dir] diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index 583b99a18d..27de0ddda7 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -836,9 +836,12 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla , "--flavour=" <> flavour -- selected flavour , "binary-dist" ] - hadrianCmd - | osIsWindows = hadrianCmdWindows - | otherwise = hadrianCmdPosix + hadrianScripts + | osIsWindows = hadrianScriptsWindows + | otherwise = hadrianScriptsPosix + + foundHadrianPaths <- filterM doesFileExist $ (cwd ) <$> hadrianScripts + hadrianPath <- maybe (throwString "No Hadrian build script found") pure $ listToMaybe foundHadrianPaths logSticky $ "Building GHC from source with `" <> RIO.display flavour @@ -847,7 +850,7 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla -- We need to provide an absolute path to the script since -- the process package only sets working directory _after_ -- discovering the executable - proc (toFilePath (cwd hadrianCmd)) hadrianArgs runProcess_ + proc (toFilePath hadrianPath) hadrianArgs runProcess_ -- find the bindist and install it bindistPath <- parseRelDir "_build/bindist"