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
4 changed files:
- hadrian/README.md
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Settings/Default.hs
Changes:
| ... | ... | @@ -329,15 +329,17 @@ workflow, for now. |
| 329 | 329 | |
| 330 | 330 | Note: On windows you need to use the `reloc-binary-dist` target.
|
| 331 | 331 | |
| 332 | -#### Cross Compiling
|
|
| 332 | +#### Staged `system.config.*` configuration
|
|
| 333 | 333 | |
| 334 | -If you are cross compiling then all the settings specified to ./configure are
|
|
| 335 | -for the target system. For example, if you specify `--with-ffi-includes` then
|
|
| 336 | -this is specifically for the target.
|
|
| 334 | +There are three `system.config.*` configuration files with different roles:
|
|
| 337 | 335 | |
| 338 | -If your host system needs additional configuration in order to build a stage1 compiler,
|
|
| 339 | -then at the moment you need to manually edit the "cfg/system.config.host.in" file to
|
|
| 340 | -specify these options in the right place.
|
|
| 336 | +- `system.config`: Contains general settings that are valid for all stages.
|
|
| 337 | +- `system.config.host`: Contains system settings for the initial stages.
|
|
| 338 | +- `system.config.target`: Contains system settings for the final stages.
|
|
| 339 | + |
|
| 340 | +The flags of the `./configure` script refer to `system.config.target`.
|
|
| 341 | +`system.config.host` contains only a minimal vanilla configuration. This may
|
|
| 342 | +change if it turns out that specific options are required for the early stages.
|
|
| 341 | 343 | |
| 342 | 344 | #### Relocatable Binary Distribution
|
| 343 | 345 |
| 1 | 1 | {-# OPTIONS_GHC -Wno-orphans #-} -- Orphan instances for Toolchain.Target
|
| 2 | 2 | {-# LANGUAGE TypeFamilies #-}
|
| 3 | -{-# LANGUAGE StandaloneDeriving #-}
|
|
| 3 | + |
|
| 4 | 4 | -----------------------------------------------------------------------------
|
| 5 | 5 | -- |
|
| 6 | 6 | -- Module : Hadrian.Oracles.TextFile
|
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | -----------------------------------------------------------------------------
|
| 15 | 15 | module Hadrian.Oracles.TextFile (
|
| 16 | 16 | lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupSystemConfig,
|
| 17 | - lookupHostBuildConfig, lookupTargetBuildConfig, lookupStageBuildConfig,
|
|
| 17 | + lookupStageBuildConfig,
|
|
| 18 | 18 | lookupValues,
|
| 19 | 19 | lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, textFileOracle,
|
| 20 | 20 | getBuildTarget, getHostTarget, getTargetTarget,
|
| ... | ... | @@ -54,29 +54,31 @@ lookupSystemConfig = lookupValueOrError (Just configError) configFile |
| 54 | 54 | where
|
| 55 | 55 | configError = "Perhaps you need to rerun ./configure"
|
| 56 | 56 | |
| 57 | -lookupHostBuildConfig :: String -> Action String
|
|
| 58 | -lookupHostBuildConfig key = do
|
|
| 59 | - cross <- (== "YES") <$> lookupSystemConfig "cross-compiling"
|
|
| 60 | - -- If we are not cross compiling, then build the host compiler like the target.
|
|
| 61 | - let cfgFile = if cross then buildConfigFileHost else buildConfigFileTarget
|
|
| 62 | - lookupValueOrError (Just configError) cfgFile key
|
|
| 57 | +lookupStageBuildConfig :: String -> Stage -> Action String
|
|
| 58 | +lookupStageBuildConfig key stage = case stage of
|
|
| 59 | + Stage0 {} -> lookupHostBuildConfig key
|
|
| 60 | + Stage1 -> lookupHostBuildConfig' key
|
|
| 61 | + Stage2 -> lookupTargetBuildConfig key
|
|
| 62 | + Stage3 -> lookupTargetBuildConfig key
|
|
| 63 | 63 | where
|
| 64 | - configError = "Perhaps you need to rerun ./configure"
|
|
| 64 | + lookupHostBuildConfig :: String -> Action String
|
|
| 65 | + lookupHostBuildConfig =
|
|
| 66 | + lookupValueOrError (Just configError) buildConfigFileHost
|
|
| 67 | + |
|
| 68 | + lookupHostBuildConfig' :: String -> Action String
|
|
| 69 | + lookupHostBuildConfig' k = do
|
|
| 70 | + isCross <- (== "YES") <$> lookupSystemConfig "cross-compiling"
|
|
| 71 | + if isCross then
|
|
| 72 | + lookupValueOrError (Just configError) buildConfigFileHost k
|
|
| 73 | + else
|
|
| 74 | + lookupTargetBuildConfig k
|
|
| 75 | + |
|
| 76 | + lookupTargetBuildConfig :: String -> Action String
|
|
| 77 | + lookupTargetBuildConfig =
|
|
| 78 | + lookupValueOrError (Just configError) buildConfigFileTarget
|
|
| 65 | 79 | |
| 66 | -lookupTargetBuildConfig :: String -> Action String
|
|
| 67 | -lookupTargetBuildConfig key =
|
|
| 68 | - lookupValueOrError (Just configError) buildConfigFileTarget key
|
|
| 69 | - where
|
|
| 70 | 80 | configError = "Perhaps you need to rerun ./configure"
|
| 71 | 81 | |
| 72 | -lookupStageBuildConfig :: String -> Stage -> Action String
|
|
| 73 | -lookupStageBuildConfig key st = tgtConfig st key
|
|
| 74 | - where
|
|
| 75 | - tgtConfig Stage0 {} = lookupHostBuildConfig
|
|
| 76 | - tgtConfig Stage1 = lookupHostBuildConfig
|
|
| 77 | - tgtConfig Stage2 = lookupTargetBuildConfig
|
|
| 78 | - tgtConfig Stage3 = lookupTargetBuildConfig
|
|
| 79 | - |
|
| 80 | 82 | -- | Lookup a list of values in a text file, tracking the result. Each line of
|
| 81 | 83 | -- the file is expected to have @key value1 value2 ...@ format.
|
| 82 | 84 | lookupValues :: FilePath -> String -> Action (Maybe [String])
|
| ... | ... | @@ -107,7 +107,7 @@ setting key = lookupSystemConfig $ case key of |
| 107 | 107 | EmsdkVersion -> "emsdk-version"
|
| 108 | 108 | |
| 109 | 109 | buildSetting :: BuildSetting -> Stage -> Action String
|
| 110 | -buildSetting key stage = tgtConfig stage $ case key of
|
|
| 110 | +buildSetting key stage = flip lookupStageBuildConfig stage $ case key of
|
|
| 111 | 111 | CursesIncludeDir -> "curses-include-dir"
|
| 112 | 112 | CursesLibDir -> "curses-lib-dir"
|
| 113 | 113 | DynamicExtension -> "dynamic-extension"
|
| ... | ... | @@ -121,11 +121,6 @@ buildSetting key stage = tgtConfig stage $ case key of |
| 121 | 121 | LibnumaLibDir -> "libnuma-lib-dir"
|
| 122 | 122 | LibZstdIncludeDir -> "libzstd-include-dir"
|
| 123 | 123 | LibZstdLibDir -> "libzstd-lib-dir"
|
| 124 | - where
|
|
| 125 | - tgtConfig Stage0 {} = lookupHostBuildConfig
|
|
| 126 | - tgtConfig Stage1 = lookupHostBuildConfig
|
|
| 127 | - tgtConfig Stage2 = lookupTargetBuildConfig
|
|
| 128 | - tgtConfig Stage3 = lookupTargetBuildConfig
|
|
| 129 | 124 | |
| 130 | 125 | -- | An expression that looks up the value of a 'Setting' in @cfg/system.config@,
|
| 131 | 126 | -- tracking the result.
|
| ... | ... | @@ -77,8 +77,7 @@ stageBootPackages = return |
| 77 | 77 | |
| 78 | 78 | -- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
|
| 79 | 79 | stage0Packages :: Action [Package]
|
| 80 | -stage0Packages = do
|
|
| 81 | - cross <- flag CrossCompiling
|
|
| 80 | +stage0Packages =
|
|
| 82 | 81 | return $ [ cabalSyntax
|
| 83 | 82 | , cabal
|
| 84 | 83 | , compiler
|
| ... | ... | @@ -117,11 +116,6 @@ stage0Packages = do |
| 117 | 116 | -- that confused Hadrian, so we must make those a stage0 package as well.
|
| 118 | 117 | -- Once we drop `Win32`/`unix` it should be possible to drop those too.
|
| 119 | 118 | ]
|
| 120 | - -- Currently, we have no way to provide paths to [n]curses libs for
|
|
| 121 | - -- both - build and target - in cross builds. Thus, we only build it
|
|
| 122 | - -- for upper stages. As we only use stage0 to build upper stages,
|
|
| 123 | - -- this should be fine.
|
|
| 124 | - ++ [ terminfo | not windowsHost, not cross ]
|
|
| 125 | 119 | ++ [ timeout | windowsHost ]
|
| 126 | 120 | |
| 127 | 121 | -- | Packages built in 'Stage1' by default. You can change this in "UserSettings".
|
| ... | ... | @@ -142,7 +136,7 @@ stagedPackages stage = do |
| 142 | 136 | cross <- flag CrossCompiling
|
| 143 | 137 | winTarget <- isWinTarget stage
|
| 144 | 138 | jsTarget <- isJsTarget stage
|
| 145 | - haveCurses <- any (/= "") <$> traverse (flip buildSetting stage) [ CursesIncludeDir, CursesLibDir ]
|
|
| 139 | + haveCurses <- any (/= "") <$> traverse (`buildSetting` stage) [ CursesIncludeDir, CursesLibDir ]
|
|
| 146 | 140 | useSystemFfi <- buildFlag UseSystemFfi stage
|
| 147 | 141 | |
| 148 | 142 | let when c xs = if c then xs else mempty
|
| ... | ... | @@ -190,7 +184,7 @@ stagedPackages stage = do |
| 190 | 184 | [ -- See Note [Hadrian's ghci-wrapper package]
|
| 191 | 185 | ghciWrapper
|
| 192 | 186 | ]
|
| 193 | - , when (cross && haveCurses)
|
|
| 187 | + , when haveCurses
|
|
| 194 | 188 | [
|
| 195 | 189 | terminfo
|
| 196 | 190 | ]
|