[Git][ghc/ghc][wip/ghc-toolchain-fixes] 4 commits: ghc-toolchain: Match CPP args with configure script

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Wed Jul 26 14:36:34 UTC 2023



Matthew Pickering pushed to branch wip/ghc-toolchain-fixes at Glasgow Haskell Compiler / GHC


Commits:
8e29fba4 by Matthew Pickering at 2023-07-26T15:02:21+01:00
ghc-toolchain: Match CPP args with configure script

At the moment we need ghc-toolchain to precisely match the output as
provided by the normal configure script. The normal configure script
(FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc
so we match that logic exactly in ghc-toolchain.

The old implementation (which checks if certain flags are supported) is
better but for now we have to match to catch any potential errors in the
configuration.

Ticket: #23720

- - - - -
ca2b4835 by Matthew Pickering at 2023-07-26T15:02:21+01:00
configure: Fix `-Wl,--no-as-needed` check

The check was failing because the args supplied by $$1 were quoted which
failed because then the C compiler thought they were an input file.

Fixes #23720

- - - - -
e7b92e83 by Matthew Pickering at 2023-07-26T15:02:21+01:00
configure: Add flag which turns ghc-toolchain check into error

We want to catch these errors in CI, but first we need to a flag which
turns this check into an error.

- - - - -
5480008f by Matthew Pickering at 2023-07-26T15:07:51+01:00
ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs

This will cause any CI job to fail if we have a mismatch between what
ghc-toolchain reports and what ./configure natively reports. Fixing
these kinds of issues is highest priority for 9.10 release.

- - - - -


6 changed files:

- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- configure.ac
- m4/fp_link_supports_no_as_needed.m4
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs


Changes:

=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -157,6 +157,7 @@ configureArgsStr bc = unwords $
   ++ ["--with-intree-gmp" | Just _ <- pure (crossTarget bc) ]
   ++ ["--with-system-libffi" | crossTarget bc == Just "wasm32-wasi" ]
   ++ ["--enable-ipe-data-compression" | withZstd bc ]
+  ++ ["--enable-strict-ghc-toolchain-check"]
 
 -- Compute the hadrian flavour from the BuildConfig
 mkJobFlavour :: BuildConfig -> Flavour


=====================================
.gitlab/jobs.yaml
=====================================
@@ -56,7 +56,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "11.0",
@@ -121,7 +121,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "aarch64-linux-deb10-validate"
     }
@@ -182,7 +182,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-i386-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "i386-linux-deb10-validate"
     }
@@ -243,7 +243,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "11.0",
@@ -309,7 +309,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "aarch64-linux-deb10-validate",
       "XZ_OPT": "-9"
@@ -371,7 +371,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-validate+llvm",
       "BUILD_FLAVOUR": "validate+llvm",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "aarch64-linux-deb10-validate+llvm",
       "XZ_OPT": "-9"
@@ -433,7 +433,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-i386-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "i386-linux-deb10-validate",
       "XZ_OPT": "-9"
@@ -495,7 +495,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "10.10",
@@ -564,7 +564,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate",
       "BUILD_FLAVOUR": "validate",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ",
+      "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "RUNTEST_ARGS": "",
@@ -629,7 +629,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-int_native-validate+fully_static",
       "BROKEN_TESTS": "ghcilink002  encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "RUNTEST_ARGS": "",
@@ -694,7 +694,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-validate",
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "RUNTEST_ARGS": "",
@@ -759,7 +759,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-validate+fully_static",
       "BROKEN_TESTS": "ghcilink002  encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "RUNTEST_ARGS": "",
@@ -823,7 +823,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -887,7 +887,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-int_native-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -951,7 +951,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-unreg-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -1015,7 +1015,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-centos7-validate",
@@ -1078,7 +1078,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-int_native-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-int_native-validate",
       "XZ_OPT": "-9"
@@ -1140,7 +1140,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-no_tntc-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--disable-tables-next-to-code",
+      "CONFIGURE_ARGS": "--disable-tables-next-to-code --enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-no_tntc-validate",
       "XZ_OPT": "-9"
@@ -1202,7 +1202,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-numa-slow-validate",
       "BUILD_FLAVOUR": "slow-validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "ENABLE_NUMA": "1",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-numa-slow-validate",
@@ -1265,7 +1265,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-unreg-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--enable-unregisterised",
+      "CONFIGURE_ARGS": "--enable-unregisterised --enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-unreg-validate",
       "XZ_OPT": "-9"
@@ -1327,7 +1327,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate",
       "XZ_OPT": "-9"
@@ -1389,7 +1389,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+debug_info",
       "BUILD_FLAVOUR": "validate+debug_info",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+debug_info",
       "XZ_OPT": "-9"
@@ -1451,7 +1451,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
       "BUILD_FLAVOUR": "validate+llvm",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+llvm",
       "XZ_OPT": "-9"
@@ -1513,7 +1513,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
       "BUILD_FLAVOUR": "validate+thread_sanitizer",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
@@ -1577,7 +1577,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp",
+      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
       "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
       "CROSS_TARGET": "aarch64-linux-gnu",
       "RUNTEST_ARGS": "",
@@ -1641,7 +1641,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp",
+      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
       "CONFIGURE_WRAPPER": "emconfigure",
       "CROSS_EMULATOR": "js-emulator",
       "CROSS_TARGET": "javascript-unknown-ghcjs",
@@ -1706,7 +1706,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb11-validate",
       "XZ_OPT": "-9"
@@ -1768,7 +1768,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
       "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
       "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc",
       "XZ_OPT": "-9"
@@ -1830,7 +1830,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb9-validate",
       "XZ_OPT": "-9"
@@ -1892,7 +1892,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "LLC": "/bin/false",
       "OPT": "/bin/false",
       "RUNTEST_ARGS": "",
@@ -1956,7 +1956,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--haddock-base-url",
       "LLC": "/bin/false",
       "OPT": "/bin/false",
@@ -2021,7 +2021,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-validate+debug_info",
       "BUILD_FLAVOUR": "validate+debug_info",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "LLC": "/bin/false",
       "OPT": "/bin/false",
       "RUNTEST_ARGS": "",
@@ -2085,7 +2085,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-rocky8-validate",
@@ -2148,7 +2148,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-ubuntu18_04-validate",
       "XZ_OPT": "-9"
@@ -2210,7 +2210,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-ubuntu20_04-validate",
       "XZ_OPT": "-9"
@@ -2268,7 +2268,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate",
       "BUILD_FLAVOUR": "validate",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
@@ -2330,7 +2330,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-windows-validate",
       "BUILD_FLAVOUR": "validate",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
@@ -2396,7 +2396,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-darwin-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
@@ -2463,7 +2463,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections",
       "BUILD_FLAVOUR": "release+no_split_sections",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -2527,7 +2527,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-i386-linux-deb10-release+no_split_sections",
       "BUILD_FLAVOUR": "release+no_split_sections",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -2591,7 +2591,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-darwin-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
@@ -2662,7 +2662,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-int_native-release+fully_static",
       "BROKEN_TESTS": "ghcilink002  encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
@@ -2728,7 +2728,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
       "BROKEN_TESTS": "ghcilink002  encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+fully_static+no_split_sections",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
@@ -2794,7 +2794,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+no_split_sections",
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+no_split_sections",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
@@ -2859,7 +2859,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections",
       "BUILD_FLAVOUR": "release+no_split_sections",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -2923,7 +2923,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -2987,7 +2987,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-release+debug_info",
       "BUILD_FLAVOUR": "release+debug_info",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3051,7 +3051,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3115,7 +3115,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-release+boot_nonmoving_gc",
       "BUILD_FLAVOUR": "release+boot_nonmoving_gc",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
@@ -3179,7 +3179,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections",
       "BUILD_FLAVOUR": "release+no_split_sections",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3243,7 +3243,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "LLC": "/bin/false",
@@ -3309,7 +3309,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release+debug_info",
       "BUILD_FLAVOUR": "release+debug_info",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "LLC": "/bin/false",
@@ -3375,7 +3375,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "LLC": "/bin/false",
@@ -3441,7 +3441,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3505,7 +3505,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3569,7 +3569,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
@@ -3629,7 +3629,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release",
       "BUILD_FLAVOUR": "release",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
@@ -3692,7 +3692,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-windows-release",
       "BUILD_FLAVOUR": "release",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
@@ -3759,7 +3759,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "10.10",
@@ -3827,7 +3827,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-freebsd13-validate",
       "BUILD_FLAVOUR": "validate",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ",
+      "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "RUNTEST_ARGS": "",
@@ -3891,7 +3891,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-validate+fully_static",
       "BROKEN_TESTS": "ghcilink002  encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
-      "CONFIGURE_ARGS": "--disable-ld-override ",
+      "CONFIGURE_ARGS": "--disable-ld-override --enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "RUNTEST_ARGS": "",
@@ -3954,7 +3954,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -4018,7 +4018,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-int_native-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -4082,7 +4082,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_17-wasm-unreg-cross_wasm32-wasi-release+fully_static",
       "BUILD_FLAVOUR": "release+fully_static",
-      "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi",
+      "CONFIGURE_ARGS": "--enable-unregisterised --with-intree-gmp --with-system-libffi --enable-strict-ghc-toolchain-check",
       "CROSS_TARGET": "wasm32-wasi",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
@@ -4145,7 +4145,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-int_native-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-int_native-validate"
     }
@@ -4207,7 +4207,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-no_tntc-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--disable-tables-next-to-code",
+      "CONFIGURE_ARGS": "--disable-tables-next-to-code --enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-no_tntc-validate"
     }
@@ -4268,7 +4268,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-numa-slow-validate",
       "BUILD_FLAVOUR": "slow-validate",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "ENABLE_NUMA": "1",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-numa-slow-validate"
@@ -4330,7 +4330,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-unreg-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--enable-unregisterised",
+      "CONFIGURE_ARGS": "--enable-unregisterised --enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-unreg-validate"
     }
@@ -4391,7 +4391,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--enable-ipe-data-compression",
+      "CONFIGURE_ARGS": "--enable-ipe-data-compression --enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate"
     }
@@ -4452,7 +4452,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+debug_info",
       "BUILD_FLAVOUR": "validate+debug_info",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+debug_info"
     }
@@ -4513,7 +4513,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+llvm",
       "BUILD_FLAVOUR": "validate+llvm",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+llvm"
     }
@@ -4575,7 +4575,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb10-validate+thread_sanitizer",
       "BUILD_FLAVOUR": "validate+thread_sanitizer",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "HADRIAN_ARGS": "--docs=none",
       "RUNTEST_ARGS": "",
       "TEST_ENV": "x86_64-linux-deb10-validate+thread_sanitizer",
@@ -4638,7 +4638,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp",
+      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
       "CROSS_EMULATOR": "qemu-aarch64 -L /usr/aarch64-linux-gnu",
       "CROSS_TARGET": "aarch64-linux-gnu",
       "RUNTEST_ARGS": "",
@@ -4701,7 +4701,7 @@
       "BIGNUM_BACKEND": "native",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate",
       "BUILD_FLAVOUR": "validate",
-      "CONFIGURE_ARGS": "--with-intree-gmp",
+      "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
       "CONFIGURE_WRAPPER": "emconfigure",
       "CROSS_EMULATOR": "js-emulator",
       "CROSS_TARGET": "javascript-unknown-ghcjs",
@@ -4765,7 +4765,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-validate+boot_nonmoving_gc",
       "BUILD_FLAVOUR": "validate+boot_nonmoving_gc",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
       "TEST_ENV": "x86_64-linux-deb11-validate+boot_nonmoving_gc"
     }
@@ -4826,7 +4826,7 @@
       "BIGNUM_BACKEND": "gmp",
       "BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
       "BUILD_FLAVOUR": "release",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "LLC": "/bin/false",
       "OPT": "/bin/false",
       "RUNTEST_ARGS": "",
@@ -4885,7 +4885,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-windows-validate",
       "BUILD_FLAVOUR": "validate",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
-      "CONFIGURE_ARGS": "",
+      "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
       "GHC_VERSION": "9.4.3",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "LANG": "en_US.UTF-8",


=====================================
configure.ac
=====================================
@@ -171,6 +171,14 @@ AC_ARG_ENABLE(ghc-toolchain,
 )
 AC_SUBST([EnableGhcToolchain])
 
+AC_ARG_ENABLE(strict-ghc-toolchain-check,
+[AS_HELP_STRING([--enable-strict-ghc-toolchain-check],
+                [Whether to raise an error if the output of ghc-toolchain differs from configure])],
+  [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableStrictGhcToolchainCheck])],
+  [EnableStrictGhcToolchainCheck=NO]
+)
+AC_SUBST([EnableStrictGhcToolchainCheck])
+
 dnl CC_STAGE0, LD_STAGE0, AR_STAGE0 are like the "previous" variable
 dnl CC, LD, AR (inherited by CC_STAGE[123], etc.)
 dnl but instead used by stage0 for bootstrapping stage1


=====================================
m4/fp_link_supports_no_as_needed.m4
=====================================
@@ -8,9 +8,9 @@ AC_DEFUN([FP_LINK_SUPPORTS_NO_AS_NEEDED],
     AC_MSG_CHECKING([whether Cc linker supports -Wl,--no-as-needed])
     echo 'int f(int a) {return 2*a;}' > conftest.a.c
     echo 'int f(int a); int main(int argc, char **argv) {return f(0);}' > conftest.b.c
-    $CC -c -o conftest.a.o conftest.a.c > /dev/null 2>&1
-    $CC -c -o conftest.b.o conftest.b.c > /dev/null 2>&1
-    if "$CC" "$$1" -Wl,--no-as-needed -o conftest conftest.a.o conftest.b.o > /dev/null 2>&1
+    $CC -c -o conftest.a.o conftest.a.c  2>&1
+    $CC -c -o conftest.b.o conftest.b.c  2>&1
+    if "$CC" ${$1:+$$1} -Wl,--no-as-needed -o conftest conftest.a.o conftest.b.o 2>&1
     then
         $1="$$1 -Wl,--no-as-needed"
         AC_MSG_RESULT([yes])


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -151,6 +151,11 @@ AC_DEFUN([VALIDATE_GHC_TOOLCHAIN],[
           In light of it, if you've spotted this difference, please report a GHC bug at
                 https://www.haskell.org/ghc/reportabug
       ])
+
+    case "$EnableStrictGhcToolchainCheck" in
+        YES)
+      AC_MSG_ERROR([Failing due to --enable-strict-ghc-toolchain-check])
+    esac
     fi
 ])
 


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
=====================================
@@ -4,6 +4,7 @@ module GHC.Toolchain.Tools.Cpp (HsCpp(..), findHsCpp, Cpp(..), findCpp) where
 
 import Control.Monad
 import System.FilePath
+import Data.List(isInfixOf)
 
 import GHC.Toolchain.Prelude
 import GHC.Toolchain.Program
@@ -39,10 +40,29 @@ findHsCpp progOpt cc = checking "for Haskell C preprocessor" $ do
 -- Haskell source.
 findHsCppArgs :: Program -> M [String]
 findHsCppArgs cpp = withTempDir $ \dir -> do
+
+  (_, stdout0, stderr0) <- readProgram cpp ["-x", "c", "/dev/null", "-dM", "-E"]
+
+  if "__clang__" `isInfixOf` stdout0 || "__clang__" `isInfixOf` stderr0
+     then return ["-undef", "-traditional", "-Wno-invalid-pp-token", "-Wno-unicode", "-Wno-trigraphs"]
+     else do
+        (_, stdout1, stderr1) <- readProgram cpp ["-v"]
+        if "gcc" `isInfixOf` stdout1 || "gcc" `isInfixOf` stderr1
+          then return ["-undef", "-traditional"]
+          else do
+            logDebug "Can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly"
+            return []
+
+
+{- TODO: We want to just check which flags are accepted rather than branching on which compiler
+         we are using but this does not match what ./configure does (#23720)
+
+         When we retire configure then this more precise logic can be reinstated.
+
   let tmp_h = dir </> "tmp.h"
 
       -- Werror to ensure that unrecognized warnings result in an error
-      checkFlag flag =
+  let checkFlag flag =
           checking ("for "++flag++" support") $ callProgram cpp ["-Werror", flag, tmp_h]
 
       tryFlag flag =
@@ -56,6 +76,7 @@ findHsCppArgs cpp = withTempDir $ \dir -> do
       , tryFlag "-Wno-unicode"
       , tryFlag "-Wno-trigraphs"
       ]
+      -}
 
 ----- C preprocessor -----
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb7d9791d1a4968da5c63ee063bcc9dcf7d93079...5480008f170067a9106f37b887492a8771601f80

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb7d9791d1a4968da5c63ee063bcc9dcf7d93079...5480008f170067a9106f37b887492a8771601f80
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230726/638dbd00/attachment-0001.html>


More information about the ghc-commits mailing list