Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
50a58757 by Cheng Shao at 2026-01-07T10:29:20-05:00
hadrian: only install js files to libdir for wasm/js targets
There are certain js files required for wasm/js targets to work, and
previously hadrian would install those js files to libdir
unconditionally on other targets as well. This could be a minor
annoyance for packagers especially when the unused js files contain
shebangs that interfere with the packaging process. This patch makes
hadrian only selectively install the right js files for the right
targets.
Co-authored-by: Codex
- - - - -
3 changed files:
- hadrian/src/Base.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/Register.hs
Changes:
=====================================
hadrian/src/Base.hs
=====================================
@@ -149,14 +149,10 @@ ghcLibDeps stage iplace = do
ps <- mapM (\f -> stageLibPath stage <&> (-/- f))
[ "llvm-targets"
, "llvm-passes"
- , "ghc-interp.js"
, "settings"
, "targets" -/- "default.target"
, "ghc-usage.txt"
, "ghci-usage.txt"
- , "dyld.mjs"
- , "post-link.mjs"
- , "prelude.mjs"
]
cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace)
return (cxxStdLib : ps)
=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -9,7 +9,7 @@ module Oracles.Setting (
-- ** Target platform things
anyTargetOs, anyTargetArch, anyHostOs,
- isElfTarget, isOsxTarget, isWinTarget, isJsTarget, isArmTarget,
+ isElfTarget, isOsxTarget, isWinTarget, isJsTarget, isWasmTarget, isArmTarget,
isWinHost,
targetArmVersion
) where
@@ -128,6 +128,9 @@ isWinTarget = anyTargetOs [OSMinGW32]
isJsTarget :: Action Bool
isJsTarget = anyTargetArch [ArchJavaScript]
+isWasmTarget :: Action Bool
+isWasmTarget = anyTargetArch [ArchWasm32]
+
isOsxTarget :: Action Bool
isOsxTarget = anyTargetOs [OSDarwin]
=====================================
hadrian/src/Rules/Register.hs
=====================================
@@ -118,7 +118,18 @@ registerPackageRules rs stage iplace = do
pkgName <- getPackageNameFromConfFile conf
let pkg = unsafeFindPackageByName pkgName
- when (pkg == compiler) $ need =<< ghcLibDeps stage iplace
+ when (pkg == compiler) $ do
+ baseDeps <- ghcLibDeps stage iplace
+ jsTarget <- isJsTarget
+ wasmTarget <- isWasmTarget
+ libPath <- stageLibPath stage
+ let jsDeps
+ | jsTarget = ["ghc-interp.js"]
+ | otherwise = []
+ wasmDeps
+ | wasmTarget = ["dyld.mjs", "post-link.mjs", "prelude.mjs"]
+ | otherwise = []
+ need (baseDeps ++ map (libPath -/-) (jsDeps ++ wasmDeps))
-- Only used in guard when Stage0 {} but can be GlobalLibs or InTreeLibs
isBoot <- (pkg `notElem`) <$> stagePackages stage
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50a5875763d8dc38e880ca8e67e635e2...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50a5875763d8dc38e880ca8e67e635e2...
You're receiving this email because of your account on gitlab.haskell.org.