[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL] 2 commits: Add a config flag for LibDir and derived values
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: a366bebe by Sven Tennie at 2026-02-25T17:11:18+00:00 Add a config flag for LibDir and derived values For cross-compilers, we have to refer to the libs of the succeeding stage. This also affects other files previously relying on top_dir in GHC. - - - - - 6c99ca77 by Sven Tennie at 2026-02-25T17:13:24+00:00 Remove prior hack to provide WASM and GHCJS deps This can now be found in the succeeding stage. - - - - - 7 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Test.hs Changes: ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -60,7 +60,7 @@ module GHC.Driver.DynFlags ( -- ** System tool settings and locations programName, projectVersion, - ghcUsagePath, ghciUsagePath, topDir, toolDir, + ghcUsagePath, ghciUsagePath, topDir, libTopDir, toolDir, versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, @@ -1506,6 +1506,8 @@ ghciUsagePath :: DynFlags -> FilePath ghciUsagePath dflags = fileSettings_ghciUsagePath $ fileSettings dflags topDir :: DynFlags -> FilePath topDir dflags = fileSettings_topDir $ fileSettings dflags +libTopDir :: DynFlags -> FilePath +libTopDir dflags = fileSettings_libTopDir $ fileSettings dflags toolDir :: DynFlags -> Maybe FilePath toolDir dflags = fileSettings_toolDir $ fileSettings dflags extraGccViaCFlags :: DynFlags -> [String] ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3647,7 +3647,7 @@ compilerInfo dflags -- Whether or not GHC was compiled using -prof ("GHC Profiled", showBool hostIsProfiled), ("Debug on", showBool debugIsOn), - ("LibDir", topDir dflags), + ("LibDir", libTopDir dflags), -- This is always an absolute path, unlike "Relative Global Package DB" which is -- in the settings file. ("Global Package DB", globalPackageDatabasePath dflags) ===================================== compiler/GHC/Settings.hs ===================================== @@ -184,6 +184,7 @@ data FileSettings = FileSettings , fileSettings_toolDir :: Maybe FilePath -- ditto , fileSettings_topDir :: FilePath -- ditto , fileSettings_globalPackageDatabase :: FilePath + , fileSettings_libTopDir :: FilePath } ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -148,6 +148,8 @@ initSettings top_dir = do baseUnitId <- getSetting_raw "base unit-id" + lib_top_dir <- getSetting "Lib TopDir" + return $ Settings { sGhcNameVersion = GhcNameVersion { ghcNameVersion_programName = "ghc" @@ -159,6 +161,7 @@ initSettings top_dir = do , fileSettings_ghciUsagePath = ghci_usage_msg_path , fileSettings_toolDir = mtool_dir , fileSettings_topDir = top_dir + , fileSettings_libTopDir = lib_top_dir , fileSettings_globalPackageDatabase = globalpkgdb_path } ===================================== hadrian/bindist/Makefile ===================================== @@ -90,6 +90,7 @@ lib/settings : config.mk @echo ',("RTS ways", "$(GhcRTSWays)")' >> $@ @echo ',("Relative Global Package DB", "package.conf.d")' >> $@ @echo ',("base unit-id", "$(BaseUnitId)")' >> $@ + @echo ',("Lib TopDir", "$$topdir/")' >> $@ @echo "]" >> $@ lib/targets/default.target : config.mk default.target ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -26,6 +26,7 @@ import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp)) import GHC.Platform.ArchOS import qualified Data.Set as Set import UserSettings (finalStage) +import Hadrian.Oracles.Path -- | Track this file to rebuild generated files whenever it changes. trackGenerateHs :: Expr () @@ -468,6 +469,7 @@ generateSettings :: FilePath -> Expr String generateSettings settingsFile = do ctx <- getContext stage <- getStage + isCrossStage <- expr $ crossStage stage package_db_path <- expr $ do let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final) @@ -487,7 +489,13 @@ generateSettings settingsFile = do Stage2 -> pkgUnitId Stage1 base Stage3 -> pkgUnitId Stage2 base + rel_lib_topDir :: FilePath <- expr $ buildRoot <&> (-/- stageString (if isCrossStage then stage else predStage stage) -/- "lib") let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path + make_absolute rel_path = do + abs_path <- liftIO (makeAbsolute rel_path) + fixAbsolutePathOnWindows abs_path + + lib_topDir :: FilePath <- expr $ make_absolute rel_lib_topDir settings <- traverse sequence $ [ ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit, Context.stage = predStage stage }))) @@ -498,6 +506,7 @@ generateSettings settingsFile = do , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays) , ("Relative Global Package DB", pure rel_pkg_db) , ("base unit-id", pure base_unit_id) + , ("Lib TopDir", pure lib_topDir) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -328,19 +328,7 @@ needTestsuitePackages stg = do -- Unfortunately, we still need the liba let pkgs = filter (\(_,p) -> not $ (pkgName p `elem` ["ghc", "Cabal"]) && isStage0 stg) (libpkgs ++ exepkgs ++ [ (stg,timeout) | windowsHost ]) - need =<< mapM (uncurry pkgFile) pkgs - when isCross $ do - jsTarget <- isJsTarget (succStage stg) - wasmTarget <- isWasmTarget (succStage stg) - libPath <- stageLibPath stg - let jsDeps - | jsTarget = ["ghc-interp.js"] - | otherwise = [] - wasmDeps - | wasmTarget = ["dyld.mjs", "post-link.mjs", "prelude.mjs"] - | otherwise = [] - need $ map (libPath -/-) (jsDeps ++ wasmDeps) -- stage 1 ghc lives under stage0/bin, -- stage 2 ghc lives under stage1/bin, etc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc30c2356eb75c729997ff6cdeee834... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc30c2356eb75c729997ff6cdeee834... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)