Skip to content

Commit 9c69ea3

Browse files
authored
Merge pull request #5529 from fwcd/fix-hadrian-script-path
Fix path to Hadrian build script for GHC source builds
2 parents 9910918 + e93a03a commit 9c69ea3

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Other enhancements:
1515

1616
Bug fixes:
1717

18+
* GHC source builds work properly for recent GHC versions again. See
19+
[#5528](https://github.com/commercialhaskell/stack/issues/5528)
1820

1921
## v2.7.1
2022

doc/yaml_configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ extra-deps:
531531
#### Bootstrapping compiler
532532

533533
Building GHC from source requires a working GHC (known as the bootstrap
534-
compiler). As we use a Stack based version of Hadrian (`hadrian/build.stack.sh` in
534+
compiler). As we use a Stack based version of Hadrian (`hadrian/build-stack` in
535535
GHC sources), the bootstrap compiler is configured into `hadrian/stack.yaml` and
536536
fully managed by Stack.
537537

src/Stack/Constants.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ module Stack.Constants
115115
,relFileStackDotTmpDotExe
116116
,relFileStackDotTmp
117117
,ghcShowOptionsOutput
118-
,hadrianCmdWindows
119-
,hadrianCmdPosix
118+
,hadrianScriptsWindows
119+
,hadrianScriptsPosix
120120
,usrLibDirs
121121
,testGhcEnvRelFile
122122
,relFileBuildLock
@@ -533,13 +533,15 @@ ghcShowOptionsOutput :: [String]
533533
ghcShowOptionsOutput =
534534
$(TH.runIO (readProcess "ghc" ["--show-options"] "") >>= TH.lift . lines)
535535

536-
-- | Relative path inside a GHC repo to the Hadrian build batch script
537-
hadrianCmdWindows :: Path Rel File
538-
hadrianCmdWindows = $(mkRelFile "hadrian/build.stack.bat")
536+
-- | Relative paths inside a GHC repo to the Hadrian build batch script.
537+
-- The second path is maintained for compatibility with older GHC versions.
538+
hadrianScriptsWindows :: [Path Rel File]
539+
hadrianScriptsWindows = [$(mkRelFile "hadrian/build-stack.bat"), $(mkRelFile "hadrian/build.stack.bat")]
539540

540-
-- | Relative path inside a GHC repo to the Hadrian build shell script
541-
hadrianCmdPosix :: Path Rel File
542-
hadrianCmdPosix = $(mkRelFile "hadrian/build.stack.sh")
541+
-- | Relative paths inside a GHC repo to the Hadrian build shell script
542+
-- The second path is maintained for compatibility with older GHC versions.
543+
hadrianScriptsPosix :: [Path Rel File]
544+
hadrianScriptsPosix = [$(mkRelFile "hadrian/build-stack"), $(mkRelFile "hadrian/build.stack.sh")]
543545

544546
-- | Used in Stack.Setup for detecting libtinfo, see comments at use site
545547
usrLibDirs :: [Path Abs Dir]

src/Stack/Setup.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,12 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla
836836
, "--flavour=" <> flavour -- selected flavour
837837
, "binary-dist"
838838
]
839-
hadrianCmd
840-
| osIsWindows = hadrianCmdWindows
841-
| otherwise = hadrianCmdPosix
839+
hadrianScripts
840+
| osIsWindows = hadrianScriptsWindows
841+
| otherwise = hadrianScriptsPosix
842+
843+
foundHadrianPaths <- filterM doesFileExist $ (cwd </>) <$> hadrianScripts
844+
hadrianPath <- maybe (throwString "No Hadrian build script found") pure $ listToMaybe foundHadrianPaths
842845

843846
logSticky $ "Building GHC from source with `"
844847
<> RIO.display flavour
@@ -847,7 +850,7 @@ buildGhcFromSource getSetupInfo' installed (CompilerRepository url) commitId fla
847850
-- We need to provide an absolute path to the script since
848851
-- the process package only sets working directory _after_
849852
-- discovering the executable
850-
proc (toFilePath (cwd </> hadrianCmd)) hadrianArgs runProcess_
853+
proc (toFilePath hadrianPath) hadrianArgs runProcess_
851854

852855
-- find the bindist and install it
853856
bindistPath <- parseRelDir "_build/bindist"

0 commit comments

Comments
 (0)