Sven Tennie pushed to branch wip/supersven/correctly_propagate_host-build-target at Glasgow Haskell Compiler / GHC
Commits:
-
449962e7
by Sven Tennie at 2026-03-25T07:27:44+01:00
-
e60c93b6
by Sven Tennie at 2026-03-25T07:32:17+01:00
3 changed files:
- distrib/configure.ac.in
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
Changes:
| ... | ... | @@ -159,6 +159,13 @@ AC_PROG_CXX([c++ g++ clang++]) |
| 159 | 159 | MOVE_TO_FLAGS([CC],[CFLAGS])
|
| 160 | 160 | MOVE_TO_FLAGS([CXX],[CXXFLAGS])
|
| 161 | 161 | |
| 162 | +dnl Initialize CONF_* variables with user-provided environment variables
|
|
| 163 | +dnl so that subsequent configure checks modify them and both autoconf and
|
|
| 164 | +dnl ghc-toolchain see the same values
|
|
| 165 | +CONF_CC_OPTS_STAGE2="$CFLAGS"
|
|
| 166 | +CONF_CXX_OPTS_STAGE2="$CXXFLAGS"
|
|
| 167 | +CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS"
|
|
| 168 | + |
|
| 162 | 169 | dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
|
| 163 | 170 | AC_PROG_CPP
|
| 164 | 171 | |
| ... | ... | @@ -424,6 +431,11 @@ checkMake380() { |
| 424 | 431 | checkMake380 make
|
| 425 | 432 | checkMake380 gmake
|
| 426 | 433 | |
| 434 | +# Respect user provided values
|
|
| 435 | +USER_CONF_CC_OPTS_STAGE2="$CFLAGS"
|
|
| 436 | +USER_CONF_CXX_OPTS_STAGE2="$CXXFLAGS"
|
|
| 437 | +USER_CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS"
|
|
| 438 | + |
|
| 427 | 439 | # Toolchain target files
|
| 428 | 440 | FIND_GHC_TOOLCHAIN_BIN([YES])
|
| 429 | 441 | PREP_TARGET_FILE
|
| ... | ... | @@ -61,7 +61,7 @@ findHsCpp progOpt cc = checking "for Haskell C preprocessor" $ do |
| 61 | 61 | let rawHsCppProgram = addFlagIfNew "-E" foundHsCppProg
|
| 62 | 62 | -- Always try to add the Haskell-specific CPP flags, regardless of the user options
|
| 63 | 63 | hppArgs <- findHsCppArgs rawHsCppProgram
|
| 64 | - let hsCppProgram = over _prgFlags (++hppArgs) rawHsCppProgram
|
|
| 64 | + let hsCppProgram = foldr addFlagIfNew rawHsCppProgram (reverse hppArgs)
|
|
| 65 | 65 | return HsCpp{hsCppProgram}
|
| 66 | 66 | |
| 67 | 67 | -- | Given a C preprocessor, figure out how it should be invoked to preprocess
|
| ... | ... | @@ -393,7 +393,7 @@ addNoAsNeeded archOs cc ccLink |
| 393 | 393 | | os <- archOS_OS archOs
|
| 394 | 394 | , osElfTarget os
|
| 395 | 395 | = checking "that --no-as-needed works" $ do
|
| 396 | - let ccLink' = over _prgFlags (++["-Wl,--no-as-needed"]) ccLink
|
|
| 396 | + let ccLink' = addFlagIfNew "-Wl,--no-as-needed" ccLink
|
|
| 397 | 397 | checkLinkWorks cc ccLink'
|
| 398 | 398 | return ccLink'
|
| 399 | 399 | | otherwise = return ccLink
|