summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-05-05 13:11:33 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-06 12:45:19 -0400
commit30f6923a834ccaca30c3622a0a82421fabcab119 (patch)
treeb0cee6f3aa869e652d409963bdf9bec005ade5d8 /hadrian
parent0281dae8b3fe3384939c415ae72ca2440b3cafb3 (diff)
downloadhaskell-30f6923a834ccaca30c3622a0a82421fabcab119.tar.gz
hadrian: Don't depend upon bash from PATH
Previously Hadrian depended implicitly upon whatever `bash` it found in `PATH`, offerring no way for the user to override. Fix this by detecting `sh` in `configure` and passing the result to Hadrian. Fixes #19797.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/cfg/system.config.in1
-rw-r--r--hadrian/src/Builder.hs5
-rw-r--r--hadrian/src/Hadrian/Oracles/Path.hs6
-rw-r--r--hadrian/src/Oracles/Setting.hs8
4 files changed, 13 insertions, 7 deletions
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 8a3fb9341f..4d9d1b752e 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -28,6 +28,7 @@ patch = @PatchCmd@
xelatex = @XELATEX@
makeindex = @MAKEINDEX@
makeinfo = @MAKEINFO@
+bourne-shell = @SH@
# Python 3 is required to run test driver.
# See: https://github.com/ghc/ghc/blob/master/testsuite/mk/boilerplate.mk#L220
diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs
index e8c72b794e..aac3b26370 100644
--- a/hadrian/src/Builder.hs
+++ b/hadrian/src/Builder.hs
@@ -27,6 +27,7 @@ import Hadrian.Builder.Tar
import Hadrian.Oracles.Path
import Hadrian.Oracles.TextFile
import Hadrian.Utilities
+import Oracles.Setting (bashPath)
import System.Exit
import System.IO (stderr)
@@ -254,7 +255,9 @@ instance H.Builder Builder where
Ar Unpack _ -> cmd' echo [Cwd output] [path] buildArgs
- Autoreconf dir -> cmd' echo [Cwd dir] ["sh", path] buildArgs
+ Autoreconf dir -> do
+ bash <- bashPath
+ cmd' echo [Cwd dir] [bash, path] buildArgs
Configure dir -> do
-- Inject /bin/bash into `libtool`, instead of /bin/sh,
diff --git a/hadrian/src/Hadrian/Oracles/Path.hs b/hadrian/src/Hadrian/Oracles/Path.hs
index 753ae74440..ba226f1313 100644
--- a/hadrian/src/Hadrian/Oracles/Path.hs
+++ b/hadrian/src/Hadrian/Oracles/Path.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.Path (
- lookupInPath, bashPath, fixAbsolutePathOnWindows, pathOracle
+ lookupInPath, fixAbsolutePathOnWindows, pathOracle
) where
import Control.Monad
@@ -20,10 +20,6 @@ lookupInPath name
| name == takeFileName name = askOracle $ LookupInPath name
| otherwise = return name
--- | Lookup the path to the @bash@ interpreter.
-bashPath :: Action FilePath
-bashPath = lookupInPath "bash"
-
-- | Fix an absolute path on Windows:
-- * "/c/" => "C:/"
-- * "/usr/bin/tar.exe" => "C:/msys/usr/bin/tar.exe"
diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs
index 8634e70b55..3713b2457a 100644
--- a/hadrian/src/Oracles/Setting.hs
+++ b/hadrian/src/Oracles/Setting.hs
@@ -7,7 +7,7 @@ module Oracles.Setting (
-- * Helpers
ghcCanonVersion, cmdLineLengthLimit, hostSupportsRPaths, topDirectory,
- libsuf, ghcVersionStage,
+ libsuf, ghcVersionStage, bashPath,
-- ** Target platform things
anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs,
@@ -76,6 +76,7 @@ data Setting = BuildArch
| TargetArchHaskell
| TargetOsHaskell
| TargetArmVersion
+ | BourneShell
-- TODO: Reduce the variety of similar flags (e.g. CPP and non-CPP versions).
-- | Each 'SettingList' comes from the file @hadrian/cfg/system.config@,
@@ -172,6 +173,7 @@ setting key = lookupValueOrError configFile $ case key of
TargetVendor -> "target-vendor"
TargetArchHaskell -> "target-arch-haskell"
TargetOsHaskell -> "target-os-haskell"
+ BourneShell -> "bourne-shell"
-- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the
-- result.
@@ -217,6 +219,10 @@ settingsFileSetting key = lookupValueOrError configFile $ case key of
getSetting :: Setting -> Expr c b String
getSetting = expr . setting
+-- | The path to a Bourne shell interpreter.
+bashPath :: Action FilePath
+bashPath = setting BourneShell
+
-- | An expression that looks up the value of a 'SettingList' in
-- @cfg/system.config@, tracking the result.
getSettingList :: SettingList -> Args c b