summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-08-05 15:13:31 -0400
committerBen Gamari <ben@smart-cactus.org>2022-08-07 05:08:52 -0400
commitb9bb45d7368ceeb874ded7e55e603327c103ce9f (patch)
treeb51657f63f60d12cd3e487adde5c3638df050c97
parentafa584a327ce9aaf560c6ff09781c6e810c23a60 (diff)
downloadhaskell-b9bb45d7368ceeb874ded7e55e603327c103ce9f.tar.gz
hadrian: Fix naming of cross-compiler wrapperswip/cross-bindist
-rw-r--r--hadrian/src/Packages.hs13
-rw-r--r--hadrian/src/Rules/BinaryDist.hs25
2 files changed, 22 insertions, 16 deletions
diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs
index d1b49c35b1..2cba0d2118 100644
--- a/hadrian/src/Packages.hs
+++ b/hadrian/src/Packages.hs
@@ -14,7 +14,7 @@ module Packages (
ghcPackages, isGhcPackage,
-- * Package information
- programName, nonHsMainPackage, autogenPath, programPath, timeoutPath,
+ crossPrefix, programName, nonHsMainPackage, autogenPath, programPath, timeoutPath,
rtsContext, rtsBuildPath, libffiBuildPath,
ensureConfigured
) where
@@ -154,15 +154,20 @@ linter name = program name ("linters" -/- name)
setPath :: Package -> FilePath -> Package
setPath pkg path = pkg { pkgPath = path }
+-- | Target prefix to prepend to executable names.
+crossPrefix :: Action String
+crossPrefix = do
+ cross <- flag CrossCompiling
+ targetPlatform <- setting TargetPlatformFull
+ return $ if cross then targetPlatform ++ "-" else ""
+
-- | Given a 'Context', compute the name of the program that is built in it
-- assuming that the corresponding package's type is 'Program'. For example, GHC
-- built in 'Stage0' is called @ghc-stage1@. If the given package is a
-- 'Library', the function simply returns its name.
programName :: Context -> Action String
programName Context {..} = do
- cross <- flag CrossCompiling
- targetPlatform <- setting TargetPlatformFull
- let prefix = if cross then targetPlatform ++ "-" else ""
+ prefix <- crossPrefix
-- TODO: Can we extract this information from Cabal files?
-- Alp: We could, but then the iserv package would have to
-- use Cabal conditionals + a 'profiling' flag
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index 7315f7f8bf..c83df35d8d 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE TupleSections, MultiWayIf #-}
module Rules.BinaryDist where
import Hadrian.Haskell.Cabal
@@ -373,19 +373,20 @@ useGhcPrefix pkg
| pkg == ghciWrapper = False
| otherwise = True
-
-- | Which wrappers point to a specific package
pkgToWrappers :: Package -> Action [String]
-pkgToWrappers pkg
- -- ghc also has the ghci script wrapper
- | pkg == ghc = pure ["ghc", "ghci"]
- | pkg == runGhc = pure ["runghc", "runhaskell"]
- -- These are the packages which we want to expose to the user and hence
- -- there are wrappers installed in the bindist.
- | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg]
- = (:[]) <$> (programName =<< programContext Stage1 pkg)
- | otherwise = pure []
-
+pkgToWrappers pkg = do
+ prefix <- crossPrefix
+ if -- ghc also has the ghci script wrapper
+ -- N.B. programName would add the crossPrefix therefore we must do the
+ -- same here.
+ | pkg == ghc -> pure $ map (prefix++) ["ghc", "ghci"]
+ | pkg == runGhc -> pure $ map (prefix++) ["runghc", "runhaskell"]
+ -- These are the packages which we want to expose to the user and hence
+ -- there are wrappers installed in the bindist.
+ | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg]
+ -> (:[]) <$> (programName =<< programContext Stage1 pkg)
+ | otherwise -> pure []
wrapper :: FilePath -> Action String
wrapper "ghc" = ghcWrapper