Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FIXED at Glasgow Haskell Compiler / GHC
Commits:
-
10b83c06
by Sven Tennie at 2025-10-04T17:08:11+02:00
4 changed files:
- hadrian/src/Builder.hs
- hadrian/src/Hadrian/Builder.hs
- hadrian/src/Rules/Libffi.hs
- hadrian/src/Settings/Builders/Cabal.hs
Changes:
| ... | ... | @@ -8,7 +8,7 @@ module Builder ( |
| 8 | 8 | -- * Builder properties
|
| 9 | 9 | builderProvenance, systemBuilderPath, builderPath, isSpecified, needBuilders,
|
| 10 | 10 | runBuilder, runBuilderWith, runBuilderWithCmdOptions, getBuilderPath,
|
| 11 | - builderEnvironment
|
|
| 11 | + builderEnvironment, remBuilderEnvironment
|
|
| 12 | 12 | ) where
|
| 13 | 13 | |
| 14 | 14 | import Control.Exception.Extra (Partial)
|
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | module Hadrian.Builder (
|
| 15 | 15 | Builder (..), BuildInfo (..), needBuilders, runBuilder,
|
| 16 | 16 | runBuilderWithCmdOptions, build, buildWithResources, buildWithCmdOptions,
|
| 17 | - getBuilderPath, builderEnvironment, askWithResources
|
|
| 17 | + getBuilderPath, builderEnvironment, remBuilderEnvironment, askWithResources
|
|
| 18 | 18 | ) where
|
| 19 | 19 | |
| 20 | 20 | import Data.List
|
| ... | ... | @@ -162,3 +162,7 @@ builderEnvironment variable builder = do |
| 162 | 162 | needBuilders [builder]
|
| 163 | 163 | path <- builderPath builder
|
| 164 | 164 | return $ AddEnv variable path
|
| 165 | + |
|
| 166 | +remBuilderEnvironment :: String -> Action CmdOption
|
|
| 167 | +remBuilderEnvironment variable = do
|
|
| 168 | + return $ RemEnv variable |
| ... | ... | @@ -129,6 +129,25 @@ fixLibffiMakefile top = |
| 129 | 129 | |
| 130 | 130 | -- TODO: check code duplication w.r.t. ConfCcArgs
|
| 131 | 131 | configureEnvironment :: Stage -> Action [CmdOption]
|
| 132 | +configureEnvironment stage@Stage1 = do
|
|
| 133 | + -- TODO: This case should not exist: Strip and Objdump should be staged!
|
|
| 134 | + context <- libffiContext stage
|
|
| 135 | + cFlags <- interpretInContext context $ mconcat
|
|
| 136 | + [ cArgs
|
|
| 137 | + , getStagedCCFlags ]
|
|
| 138 | + ldFlags <- interpretInContext context ldArgs
|
|
| 139 | + sequence [ builderEnvironment "CC" $ Cc CompileC stage
|
|
| 140 | + , builderEnvironment "CXX" $ Cc CompileC stage
|
|
| 141 | + , builderEnvironment "AR" (Ar Unpack stage)
|
|
| 142 | + -- , builderEnvironment "LD" (Ld stage)
|
|
| 143 | + , builderEnvironment "NM" (Nm stage)
|
|
| 144 | + , builderEnvironment "RANLIB" (Ranlib stage)
|
|
| 145 | + , remBuilderEnvironment "OBJDUMP"
|
|
| 146 | + , remBuilderEnvironment "STRIP"
|
|
| 147 | + , remBuilderEnvironment "LD"
|
|
| 148 | + , return . AddEnv "CFLAGS" $ unwords cFlags ++ " -w"
|
|
| 149 | + , return . AddEnv "LDFLAGS" $ unwords ldFlags ++ " -w" ]
|
|
| 150 | + |
|
| 132 | 151 | configureEnvironment stage = do
|
| 133 | 152 | context <- libffiContext stage
|
| 134 | 153 | cFlags <- interpretInContext context $ mconcat
|
| ... | ... | @@ -140,6 +159,8 @@ configureEnvironment stage = do |
| 140 | 159 | , builderEnvironment "AR" (Ar Unpack stage)
|
| 141 | 160 | , builderEnvironment "NM" (Nm stage)
|
| 142 | 161 | , builderEnvironment "RANLIB" (Ranlib stage)
|
| 162 | + -- TODO: Staged LD for mingw is wrong. Uses clang instead of the provided $LD
|
|
| 163 | +-- , builderEnvironment "LD" (Ld stage)
|
|
| 143 | 164 | , return . AddEnv "CFLAGS" $ unwords cFlags ++ " -w"
|
| 144 | 165 | , return . AddEnv "LDFLAGS" $ unwords ldFlags ++ " -w" ]
|
| 145 | 166 |
| ... | ... | @@ -208,6 +208,7 @@ configureArgs cFlags' ldFlags' = do |
| 208 | 208 | , conf "--with-gmp-libraries" $ arg =<< staged (buildSetting GmpLibDir)
|
| 209 | 209 | , conf "--with-curses-libraries" $ arg =<< staged (buildSetting CursesLibDir)
|
| 210 | 210 | , conf "--host" $ arg =<< flip queryTarget targetPlatformTriple . predStage' =<< getStage
|
| 211 | + , conf "--target" $ arg =<< flip queryTarget targetPlatformTriple =<< getStage
|
|
| 211 | 212 | , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage
|
| 212 | 213 | , ghcVersionH
|
| 213 | 214 | ]
|