Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 10 additions & 8 deletions src/Stack/Constants.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ module Stack.Constants
,relFileStackDotTmpDotExe
,relFileStackDotTmp
,ghcShowOptionsOutput
,hadrianCmdWindows
,hadrianCmdPosix
,hadrianScriptsWindows
,hadrianScriptsPosix
,usrLibDirs
,testGhcEnvRelFile
,relFileBuildLock
Expand Down Expand Up @@ -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]
Expand Down
11 changes: 7 additions & 4 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down