Rodrigo Mesquita pushed to branch wip/romes/24985 at Glasgow Haskell Compiler / GHC
Commits:
-
670f28fb
by Rodrigo Mesquita at 2025-09-19T10:23:26+01:00
-
0b6d63ea
by Rodrigo Mesquita at 2025-09-19T10:24:10+01:00
5 changed files:
- configure.ac
- m4/fp_setup_windows_toolchain.m4
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Link.hs
Changes:
... | ... | @@ -43,12 +43,6 @@ dnl interprets build/host/target and how this interacts with $CC tests |
43 | 43 | test -n "$target_alias" && ac_tool_prefix=$target_alias-
|
44 | 44 | |
45 | 45 | dnl ----------------------------------------------------------
|
46 | -dnl ** Store USER specified environment variables to pass them on to
|
|
47 | -dnl ** ghc-toolchain (in m4/ghc-toolchain.m4)
|
|
48 | -USER_CFLAGS="$CFLAGS"
|
|
49 | -USER_LDFLAGS="$LDFLAGS"
|
|
50 | -USER_LIBS="$LIBS"
|
|
51 | -USER_CXXFLAGS="$CXXFLAGS"
|
|
52 | 46 | dnl The lower-level/not user-facing environment variables that may still be set
|
53 | 47 | dnl by developers such as in ghc-wasm-meta
|
54 | 48 | USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
|
... | ... | @@ -146,11 +146,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ |
146 | 146 | dnl We override the USER_* flags here since the user delegated
|
147 | 147 | dnl configuration to the bundled windows toolchain, and these are the
|
148 | 148 | dnl options required by the bundled windows toolchain.
|
149 | - USER_CFLAGS="$CFLAGS"
|
|
150 | 149 | USER_CPP_ARGS="$CONF_CPP_OPTS_STAGE2"
|
151 | - USER_CXXFLAGS="$CXXFLAGS"
|
|
152 | 150 | USER_HS_CPP_ARGS="$HaskellCPPArgs"
|
153 | - USER_LDFLAGS="$CONF_GCC_LINKER_OPTS_STAGE2"
|
|
151 | + USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2"
|
|
152 | + USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2"
|
|
153 | + USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2"
|
|
154 | 154 | USER_JS_CPP_ARGS="$JavaScriptCPPArgs"
|
155 | 155 | USER_CMM_CPP_ARGS="$CmmCPPArgs"
|
156 | 156 | ]) |
... | ... | @@ -8,18 +8,6 @@ AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG], |
8 | 8 | done
|
9 | 9 | ])
|
10 | 10 | |
11 | -dnl $1 argument name
|
|
12 | -dnl $2 first variable to try
|
|
13 | -dnl $3 variable to add if the first variable is empty
|
|
14 | -AC_DEFUN([ADD_GHC_TOOLCHAIN_ARG_CHOOSE],
|
|
15 | -[
|
|
16 | - if test -z "$2"; then
|
|
17 | - ADD_GHC_TOOLCHAIN_ARG([$1],[$3])
|
|
18 | - else
|
|
19 | - ADD_GHC_TOOLCHAIN_ARG([$1],[$2])
|
|
20 | - fi
|
|
21 | -])
|
|
22 | - |
|
23 | 11 | AC_DEFUN([ENABLE_GHC_TOOLCHAIN_ARG],
|
24 | 12 | [
|
25 | 13 | if test "$2" = "YES"; then
|
... | ... | @@ -123,10 +111,9 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN], |
123 | 111 | ENABLE_GHC_TOOLCHAIN_ARG([dwarf-unwind], [$enable_dwarf_unwind])
|
124 | 112 | |
125 | 113 | dnl We store USER_* variants of all user-specified flags to pass them over to ghc-toolchain.
|
126 | - ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-opt], [$USER_CONF_CC_OPTS_STAGE2], [$USER_CFLAGS])
|
|
127 | - ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2], [$USER_LDFLAGS])
|
|
128 | - ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_LIBS])
|
|
129 | - ADD_GHC_TOOLCHAIN_ARG_CHOOSE([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2], [$USER_CXXFLAGS])
|
|
114 | + ADD_GHC_TOOLCHAIN_ARG([cc-opt], [$USER_CONF_CC_OPTS_STAGE2])
|
|
115 | + ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$USER_CONF_GCC_LINKER_OPTS_STAGE2])
|
|
116 | + ADD_GHC_TOOLCHAIN_ARG([cxx-opt], [$USER_CONF_CXX_OPTS_STAGE2])
|
|
130 | 117 | ADD_GHC_TOOLCHAIN_ARG([cpp-opt], [$USER_CPP_ARGS])
|
131 | 118 | ADD_GHC_TOOLCHAIN_ARG([hs-cpp-opt], [$USER_HS_CPP_ARGS])
|
132 | 119 | ADD_GHC_TOOLCHAIN_ARG([js-cpp-opt], [$USER_JS_CPP_ARGS])
|
... | ... | @@ -428,17 +428,21 @@ archHasNativeAdjustors = \case |
428 | 428 | ArchJavaScript -> True
|
429 | 429 | _ -> False
|
430 | 430 | |
431 | - |
|
432 | --- | The platforms which we attempt to override ld
|
|
431 | +-- | The platforms which we attempt to override ld:
|
|
432 | +-- Should we attempt to find a more efficient linker on this platform?
|
|
433 | 433 | ldOverrideWhitelist :: ArchOS -> Bool
|
434 | 434 | ldOverrideWhitelist a =
|
435 | 435 | case archOS_OS a of
|
436 | + -- N.B. On Darwin it is quite important that we use the system linker
|
|
437 | + -- unchanged as it is very easy to run into broken setups (e.g. unholy mixtures
|
|
438 | + -- of Homebrew and the Apple toolchain).
|
|
439 | + --
|
|
440 | + -- See #21712.
|
|
441 | + OSDarwin -> False
|
|
436 | 442 | OSLinux -> True
|
437 | 443 | OSMinGW32 -> True
|
438 | 444 | _ -> False
|
439 | 445 | |
440 | - |
|
441 | - |
|
442 | 446 | mkTarget :: Opts -> M Target
|
443 | 447 | mkTarget opts = do
|
444 | 448 | normalised_triple <- normaliseTriple (fromMaybe (error "missing --triple") (optTriple opts))
|
... | ... | @@ -459,7 +463,8 @@ mkTarget opts = do |
459 | 463 | cmmCpp <- findCmmCpp (optCmmCpp opts) cc0
|
460 | 464 | cc <- addPlatformDepCcFlags archOs cc0
|
461 | 465 | readelf <- optional $ findReadelf (optReadelf opts)
|
462 | - ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts) (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf
|
|
466 | + ccLink <- findCcLink tgtLlvmTarget (optLd opts) (optCcLink opts)
|
|
467 | + (ldOverrideWhitelist archOs && fromMaybe True (optLdOverride opts)) archOs cc readelf
|
|
463 | 468 | |
464 | 469 | ar <- findAr tgtVendor (optAr opts)
|
465 | 470 | -- TODO: We could have
|
... | ... | @@ -83,7 +83,7 @@ findCcLink target ld progOpt ldOverride archOs cc readelf = checking "for C comp |
83 | 83 | -- | Try to convince @cc@ to use a more efficient linker than @bfd.ld@
|
84 | 84 | findLinkFlags :: Bool -> Cc -> Program -> M Program
|
85 | 85 | findLinkFlags enableOverride cc ccLink
|
86 | - | enableOverride && doLinkerSearch =
|
|
86 | + | enableOverride =
|
|
87 | 87 | oneOf "this can't happen"
|
88 | 88 | [ -- Annoyingly, gcc silently falls back to vanilla ld (typically bfd
|
89 | 89 | -- ld) if @-fuse-ld@ is given with a non-existent linker.
|
... | ... | @@ -105,20 +105,6 @@ linkSupportsTarget archOs cc target link = |
105 | 105 | checking "whether cc linker supports --target" $
|
106 | 106 | supportsTarget archOs (Lens id const) (checkLinkWorks cc) target link
|
107 | 107 | |
108 | --- | Should we attempt to find a more efficient linker on this platform?
|
|
109 | ---
|
|
110 | --- N.B. On Darwin it is quite important that we use the system linker
|
|
111 | --- unchanged as it is very easy to run into broken setups (e.g. unholy mixtures
|
|
112 | --- of Homebrew and the Apple toolchain).
|
|
113 | ---
|
|
114 | --- See #21712.
|
|
115 | -doLinkerSearch :: Bool
|
|
116 | -#if defined(linux_HOST_OS)
|
|
117 | -doLinkerSearch = True
|
|
118 | -#else
|
|
119 | -doLinkerSearch = False
|
|
120 | -#endif
|
|
121 | - |
|
122 | 108 | -- | See Note [No PIE when linking] in GHC.Driver.Session
|
123 | 109 | checkSupportsNoPie :: Cc -> Program -> M Bool
|
124 | 110 | checkSupportsNoPie cc ccLink = checking "whether the cc linker supports -no-pie" $
|