[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL] Build early stages with minimal settings
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: e54c74df by Sven at 2026-03-09T15:24:50+00:00 Build early stages with minimal settings - - - - - 4 changed files: - hadrian/README.md - hadrian/src/Hadrian/Oracles/TextFile.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Settings/Default.hs Changes: ===================================== hadrian/README.md ===================================== @@ -329,15 +329,17 @@ workflow, for now. Note: On windows you need to use the `reloc-binary-dist` target. -#### Cross Compiling +#### Staged `system.config.*` configuration -If you are cross compiling then all the settings specified to ./configure are -for the target system. For example, if you specify `--with-ffi-includes` then -this is specifically for the target. +There are three `system.config.*` configuration files with different roles: -If your host system needs additional configuration in order to build a stage1 compiler, -then at the moment you need to manually edit the "cfg/system.config.host.in" file to -specify these options in the right place. +- `system.config`: Contains general settings that are valid for all stages. +- `system.config.host`: Contains system settings for the initial stages. +- `system.config.target`: Contains system settings for the final stages. + +The flags of the `./configure` script refer to `system.config.target`. +`system.config.host` contains only a minimal vanilla configuration. This may +change if it turns out that specific options are required for the early stages. #### Relocatable Binary Distribution ===================================== hadrian/src/Hadrian/Oracles/TextFile.hs ===================================== @@ -1,6 +1,6 @@ {-# OPTIONS_GHC -Wno-orphans #-} -- Orphan instances for Toolchain.Target {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE StandaloneDeriving #-} + ----------------------------------------------------------------------------- -- | -- Module : Hadrian.Oracles.TextFile @@ -14,7 +14,7 @@ ----------------------------------------------------------------------------- module Hadrian.Oracles.TextFile ( lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig, - lookupHostBuildConfig, lookupTargetBuildConfig, lookupStageBuildConfig, + lookupStageBuildConfig, lookupValues, lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, textFileOracle, getBuildTarget, getHostTarget, getTargetTarget, @@ -54,29 +54,31 @@ lookupSystemConfig = lookupValueOrError (Just configError) configFile where configError = "Perhaps you need to rerun ./configure" -lookupHostBuildConfig :: String -> Action String -lookupHostBuildConfig key = do - cross <- (== "YES") <$> lookupSystemConfig "cross-compiling" - -- If we are not cross compiling, then build the host compiler like the target. - let cfgFile = if cross then buildConfigFileHost else buildConfigFileTarget - lookupValueOrError (Just configError) cfgFile key +lookupStageBuildConfig :: String -> Stage -> Action String +lookupStageBuildConfig key stage = case stage of + Stage0 {} -> lookupHostBuildConfig key + Stage1 -> lookupHostBuildConfig' key + Stage2 -> lookupTargetBuildConfig key + Stage3 -> lookupTargetBuildConfig key where - configError = "Perhaps you need to rerun ./configure" + lookupHostBuildConfig :: String -> Action String + lookupHostBuildConfig = + lookupValueOrError (Just configError) buildConfigFileHost + + lookupHostBuildConfig' :: String -> Action String + lookupHostBuildConfig' k = do + isCross <- (== "YES") <$> lookupSystemConfig "cross-compiling" + if isCross then + lookupValueOrError (Just configError) buildConfigFileHost k + else + lookupTargetBuildConfig k + + lookupTargetBuildConfig :: String -> Action String + lookupTargetBuildConfig = + lookupValueOrError (Just configError) buildConfigFileTarget -lookupTargetBuildConfig :: String -> Action String -lookupTargetBuildConfig key = - lookupValueOrError (Just configError) buildConfigFileTarget key - where configError = "Perhaps you need to rerun ./configure" -lookupStageBuildConfig :: String -> Stage -> Action String -lookupStageBuildConfig key st = tgtConfig st key - where - tgtConfig Stage0 {} = lookupHostBuildConfig - tgtConfig Stage1 = lookupHostBuildConfig - tgtConfig Stage2 = lookupTargetBuildConfig - tgtConfig Stage3 = lookupTargetBuildConfig - -- | Lookup a list of values in a text file, tracking the result. Each line of -- the file is expected to have @key value1 value2 ...@ format. lookupValues :: FilePath -> String -> Action (Maybe [String]) ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -107,7 +107,7 @@ setting key = lookupSystemConfig $ case key of EmsdkVersion -> "emsdk-version" buildSetting :: BuildSetting -> Stage -> Action String -buildSetting key stage = tgtConfig stage $ case key of +buildSetting key stage = flip lookupStageBuildConfig stage $ case key of CursesIncludeDir -> "curses-include-dir" CursesLibDir -> "curses-lib-dir" DynamicExtension -> "dynamic-extension" @@ -121,11 +121,6 @@ buildSetting key stage = tgtConfig stage $ case key of LibnumaLibDir -> "libnuma-lib-dir" LibZstdIncludeDir -> "libzstd-include-dir" LibZstdLibDir -> "libzstd-lib-dir" - where - tgtConfig Stage0 {} = lookupHostBuildConfig - tgtConfig Stage1 = lookupHostBuildConfig - tgtConfig Stage2 = lookupTargetBuildConfig - tgtConfig Stage3 = lookupTargetBuildConfig -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@, -- tracking the result. ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -77,8 +77,7 @@ stageBootPackages = return -- | Packages built in 'Stage0' by default. You can change this in "UserSettings". stage0Packages :: Action [Package] -stage0Packages = do - cross <- flag CrossCompiling +stage0Packages = return $ [ cabalSyntax , cabal , compiler @@ -117,11 +116,6 @@ stage0Packages = do -- that confused Hadrian, so we must make those a stage0 package as well. -- Once we drop `Win32`/`unix` it should be possible to drop those too. ] - -- Currently, we have no way to provide paths to [n]curses libs for - -- both - build and target - in cross builds. Thus, we only build it - -- for upper stages. As we only use stage0 to build upper stages, - -- this should be fine. - ++ [ terminfo | not windowsHost, not cross ] ++ [ timeout | windowsHost ] -- | Packages built in 'Stage1' by default. You can change this in "UserSettings". @@ -142,7 +136,7 @@ stagedPackages stage = do cross <- flag CrossCompiling winTarget <- isWinTarget stage jsTarget <- isJsTarget stage - haveCurses <- any (/= "") <$> traverse (flip buildSetting stage) [ CursesIncludeDir, CursesLibDir ] + haveCurses <- any (/= "") <$> traverse (`buildSetting` stage) [ CursesIncludeDir, CursesLibDir ] useSystemFfi <- buildFlag UseSystemFfi stage let when c xs = if c then xs else mempty @@ -190,7 +184,7 @@ stagedPackages stage = do [ -- See Note [Hadrian's ghci-wrapper package] ghciWrapper ] - , when (cross && haveCurses) + , when haveCurses [ terminfo ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e54c74df04b675d5d76d763dfdd3e912... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e54c74df04b675d5d76d763dfdd3e912... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)