diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-05-05 13:11:33 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-06 12:45:19 -0400 |
commit | 30f6923a834ccaca30c3622a0a82421fabcab119 (patch) | |
tree | b0cee6f3aa869e652d409963bdf9bec005ade5d8 | |
parent | 0281dae8b3fe3384939c415ae72ca2440b3cafb3 (diff) | |
download | haskell-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.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 1 | ||||
-rw-r--r-- | hadrian/src/Builder.hs | 5 | ||||
-rw-r--r-- | hadrian/src/Hadrian/Oracles/Path.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 8 | ||||
-rw-r--r-- | m4/fp_prog_sh.m4 | 15 |
6 files changed, 30 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index 5582c9fb2f..e3763055ec 100644 --- a/configure.ac +++ b/configure.ac @@ -255,6 +255,8 @@ AC_CANONICAL_TARGET FPTOOLS_SET_PLATFORM_VARS +FP_PROG_SH + # Verify that the installed (bootstrap) GHC is capable of generating # code for the requested build platform. if test "$BuildPlatform" != "$bootstrap_target" 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 diff --git a/m4/fp_prog_sh.m4 b/m4/fp_prog_sh.m4 new file mode 100644 index 0000000000..f7c2c49fe8 --- /dev/null +++ b/m4/fp_prog_sh.m4 @@ -0,0 +1,15 @@ +# FP_PROG_SH +# ------------ +# Find a functional Bourne shell +AC_DEFUN([FP_PROG_SH], +[ + AC_REQUIRE([FPTOOLS_SET_PLATFORM_VARS]) dnl for $windows + AC_ARG_VAR(SH,[Use as the full path to a Bourne shell. [default=autodetect]]) + AC_PATH_PROGS([SH], [sh bash]) + if test "$windows" = "YES"; then + dnl use mixed (-m) mode to get C:/mingw64/... with forward slashes. + dnl windows (-w) mode will give us C:\... and mess with escaping. + SH=`cygpath -m "$SH"` + fi + AC_SUBST([SH])[]dnl +])# FP_PROG_SH |