[Git][ghc/ghc][wip/fix-ghci-wrapper] hadrian: fix bindist executable wrapper logic for cross targets

Cheng Shao (@TerrorJack) gitlab at gitlab.haskell.org
Sun Oct 20 18:47:15 UTC 2024



Cheng Shao pushed to branch wip/fix-ghci-wrapper at Glasgow Haskell Compiler / GHC


Commits:
464c0738 by Cheng Shao at 2024-10-20T18:46:50+00:00
hadrian: fix bindist executable wrapper logic for cross targets

This commit fixes an oversight of hadrian wrapper generation logic:
when doing cross compilation, `wrapper` is called on executable names
with cross prefix, therefore we must use `isSuffixOf` when matching to
take the cross prefix into account. Also add missing cross prefix to
ghci wrapper content.

- - - - -


1 changed file:

- hadrian/src/Rules/BinaryDist.hs


Changes:

=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -437,13 +437,14 @@ pkgToWrappers pkg = do
       | otherwise     -> pure []
 
 wrapper :: FilePath -> Action String
-wrapper "ghc"         = ghcWrapper
-wrapper "ghc-pkg"     = ghcPkgWrapper
-wrapper "ghci" = ghciScriptWrapper
-wrapper "haddock"     = haddockWrapper
-wrapper "hsc2hs"      = hsc2hsWrapper
-wrapper "runghc"      = runGhcWrapper
-wrapper "runhaskell"  = runGhcWrapper
+wrapper wrapper_name
+  | "runghc"     `isSuffixOf` wrapper_name = runGhcWrapper
+  | "ghc"        `isSuffixOf` wrapper_name = ghcWrapper
+  | "ghc-pkg"    `isSuffixOf` wrapper_name = ghcPkgWrapper
+  | "ghci"       `isSuffixOf` wrapper_name = ghciScriptWrapper
+  | "haddock"    `isSuffixOf` wrapper_name = haddockWrapper
+  | "hsc2hs"     `isSuffixOf` wrapper_name = hsc2hsWrapper
+  | "runhaskell" `isSuffixOf` wrapper_name = runGhcWrapper
 wrapper _             = commonWrapper
 
 -- | Wrapper scripts for different programs. Common is default wrapper.
@@ -473,9 +474,10 @@ runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\
 -- | --interactive flag.
 ghciScriptWrapper :: Action String
 ghciScriptWrapper = do
+  prefix <- crossPrefix
   version <- setting ProjectVersion
   pure $ unlines
-    [ "executable=\"$bindir/ghc-" ++ version ++ "\""
+    [ "executable=\"$bindir/" ++ prefix ++ "ghc-" ++ version ++ "\""
     , "exec $executable --interactive \"$@\"" ]
 
 -- | When not on Windows, we want to ship the 3 flavours of the iserv program
@@ -548,4 +550,3 @@ createGhcii outDir = do
       [ "#!/bin/sh"
       , "exec \"$(dirname \"$0\")\"/ghc --interactive \"$@\""
       ]
-



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/464c0738317a3854bebec467683653307f8f8450

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/464c0738317a3854bebec467683653307f8f8450
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241020/3125e68f/attachment-0001.html>


More information about the ghc-commits mailing list