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
-
6c99ca77
by Sven Tennie at 2026-02-25T17:13:24+00:00
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:
| ... | ... | @@ -60,7 +60,7 @@ module GHC.Driver.DynFlags ( |
| 60 | 60 | |
| 61 | 61 | -- ** System tool settings and locations
|
| 62 | 62 | programName, projectVersion,
|
| 63 | - ghcUsagePath, ghciUsagePath, topDir, toolDir,
|
|
| 63 | + ghcUsagePath, ghciUsagePath, topDir, libTopDir, toolDir,
|
|
| 64 | 64 | versionedAppDir, versionedFilePath,
|
| 65 | 65 | extraGccViaCFlags, globalPackageDatabasePath,
|
| 66 | 66 | |
| ... | ... | @@ -1506,6 +1506,8 @@ ghciUsagePath :: DynFlags -> FilePath |
| 1506 | 1506 | ghciUsagePath dflags = fileSettings_ghciUsagePath $ fileSettings dflags
|
| 1507 | 1507 | topDir :: DynFlags -> FilePath
|
| 1508 | 1508 | topDir dflags = fileSettings_topDir $ fileSettings dflags
|
| 1509 | +libTopDir :: DynFlags -> FilePath
|
|
| 1510 | +libTopDir dflags = fileSettings_libTopDir $ fileSettings dflags
|
|
| 1509 | 1511 | toolDir :: DynFlags -> Maybe FilePath
|
| 1510 | 1512 | toolDir dflags = fileSettings_toolDir $ fileSettings dflags
|
| 1511 | 1513 | extraGccViaCFlags :: DynFlags -> [String]
|
| ... | ... | @@ -3647,7 +3647,7 @@ compilerInfo dflags |
| 3647 | 3647 | -- Whether or not GHC was compiled using -prof
|
| 3648 | 3648 | ("GHC Profiled", showBool hostIsProfiled),
|
| 3649 | 3649 | ("Debug on", showBool debugIsOn),
|
| 3650 | - ("LibDir", topDir dflags),
|
|
| 3650 | + ("LibDir", libTopDir dflags),
|
|
| 3651 | 3651 | -- This is always an absolute path, unlike "Relative Global Package DB" which is
|
| 3652 | 3652 | -- in the settings file.
|
| 3653 | 3653 | ("Global Package DB", globalPackageDatabasePath dflags)
|
| ... | ... | @@ -184,6 +184,7 @@ data FileSettings = FileSettings |
| 184 | 184 | , fileSettings_toolDir :: Maybe FilePath -- ditto
|
| 185 | 185 | , fileSettings_topDir :: FilePath -- ditto
|
| 186 | 186 | , fileSettings_globalPackageDatabase :: FilePath
|
| 187 | + , fileSettings_libTopDir :: FilePath
|
|
| 187 | 188 | }
|
| 188 | 189 | |
| 189 | 190 |
| ... | ... | @@ -148,6 +148,8 @@ initSettings top_dir = do |
| 148 | 148 | |
| 149 | 149 | baseUnitId <- getSetting_raw "base unit-id"
|
| 150 | 150 | |
| 151 | + lib_top_dir <- getSetting "Lib TopDir"
|
|
| 152 | + |
|
| 151 | 153 | return $ Settings
|
| 152 | 154 | { sGhcNameVersion = GhcNameVersion
|
| 153 | 155 | { ghcNameVersion_programName = "ghc"
|
| ... | ... | @@ -159,6 +161,7 @@ initSettings top_dir = do |
| 159 | 161 | , fileSettings_ghciUsagePath = ghci_usage_msg_path
|
| 160 | 162 | , fileSettings_toolDir = mtool_dir
|
| 161 | 163 | , fileSettings_topDir = top_dir
|
| 164 | + , fileSettings_libTopDir = lib_top_dir
|
|
| 162 | 165 | , fileSettings_globalPackageDatabase = globalpkgdb_path
|
| 163 | 166 | }
|
| 164 | 167 |
| ... | ... | @@ -90,6 +90,7 @@ lib/settings : config.mk |
| 90 | 90 | @echo ',("RTS ways", "$(GhcRTSWays)")' >> $@
|
| 91 | 91 | @echo ',("Relative Global Package DB", "package.conf.d")' >> $@
|
| 92 | 92 | @echo ',("base unit-id", "$(BaseUnitId)")' >> $@
|
| 93 | + @echo ',("Lib TopDir", "$$topdir/")' >> $@
|
|
| 93 | 94 | @echo "]" >> $@
|
| 94 | 95 | |
| 95 | 96 | lib/targets/default.target : config.mk default.target
|
| ... | ... | @@ -26,6 +26,7 @@ import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp)) |
| 26 | 26 | import GHC.Platform.ArchOS
|
| 27 | 27 | import qualified Data.Set as Set
|
| 28 | 28 | import UserSettings (finalStage)
|
| 29 | +import Hadrian.Oracles.Path
|
|
| 29 | 30 | |
| 30 | 31 | -- | Track this file to rebuild generated files whenever it changes.
|
| 31 | 32 | trackGenerateHs :: Expr ()
|
| ... | ... | @@ -468,6 +469,7 @@ generateSettings :: FilePath -> Expr String |
| 468 | 469 | generateSettings settingsFile = do
|
| 469 | 470 | ctx <- getContext
|
| 470 | 471 | stage <- getStage
|
| 472 | + isCrossStage <- expr $ crossStage stage
|
|
| 471 | 473 | |
| 472 | 474 | package_db_path <- expr $ do
|
| 473 | 475 | let get_pkg_db stg = packageDbPath (PackageDbLoc stg Final)
|
| ... | ... | @@ -487,7 +489,13 @@ generateSettings settingsFile = do |
| 487 | 489 | Stage2 -> pkgUnitId Stage1 base
|
| 488 | 490 | Stage3 -> pkgUnitId Stage2 base
|
| 489 | 491 | |
| 492 | + rel_lib_topDir :: FilePath <- expr $ buildRoot <&> (-/- stageString (if isCrossStage then stage else predStage stage) -/- "lib")
|
|
| 490 | 493 | let rel_pkg_db = makeRelativeNoSysLink (dropFileName settingsFile) package_db_path
|
| 494 | + make_absolute rel_path = do
|
|
| 495 | + abs_path <- liftIO (makeAbsolute rel_path)
|
|
| 496 | + fixAbsolutePathOnWindows abs_path
|
|
| 497 | + |
|
| 498 | + lib_topDir :: FilePath <- expr $ make_absolute rel_lib_topDir
|
|
| 491 | 499 | |
| 492 | 500 | settings <- traverse sequence $
|
| 493 | 501 | [ ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit, Context.stage = predStage stage })))
|
| ... | ... | @@ -498,6 +506,7 @@ generateSettings settingsFile = do |
| 498 | 506 | , ("RTS ways", unwords . map show . Set.toList <$> getRtsWays)
|
| 499 | 507 | , ("Relative Global Package DB", pure rel_pkg_db)
|
| 500 | 508 | , ("base unit-id", pure base_unit_id)
|
| 509 | + , ("Lib TopDir", pure lib_topDir)
|
|
| 501 | 510 | ]
|
| 502 | 511 | let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")"
|
| 503 | 512 | pure $ case settings of
|
| ... | ... | @@ -328,19 +328,7 @@ needTestsuitePackages stg = do |
| 328 | 328 | -- Unfortunately, we still need the liba
|
| 329 | 329 | let pkgs = filter (\(_,p) -> not $ (pkgName p `elem` ["ghc", "Cabal"]) && isStage0 stg)
|
| 330 | 330 | (libpkgs ++ exepkgs ++ [ (stg,timeout) | windowsHost ])
|
| 331 | - |
|
| 332 | 331 | need =<< mapM (uncurry pkgFile) pkgs
|
| 333 | - when isCross $ do
|
|
| 334 | - jsTarget <- isJsTarget (succStage stg)
|
|
| 335 | - wasmTarget <- isWasmTarget (succStage stg)
|
|
| 336 | - libPath <- stageLibPath stg
|
|
| 337 | - let jsDeps
|
|
| 338 | - | jsTarget = ["ghc-interp.js"]
|
|
| 339 | - | otherwise = []
|
|
| 340 | - wasmDeps
|
|
| 341 | - | wasmTarget = ["dyld.mjs", "post-link.mjs", "prelude.mjs"]
|
|
| 342 | - | otherwise = []
|
|
| 343 | - need $ map (libPath -/-) (jsDeps ++ wasmDeps)
|
|
| 344 | 332 | |
| 345 | 333 | -- stage 1 ghc lives under stage0/bin,
|
| 346 | 334 | -- stage 2 ghc lives under stage1/bin, etc
|