[Git][ghc/ghc][wip/romes/24324] Work around autotools setting C11 standard in CC/CXX

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Thu Feb 1 07:35:40 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/24324 at Glasgow Haskell Compiler / GHC


Commits:
dab53ea1 by Rodrigo Mesquita at 2024-02-01T07:35:29+00:00
Work around autotools setting C11 standard in CC/CXX

In autoconf >=2.70, C11 is set by default for $CC and $CXX via the
-std=...11 flag. In this patch, we split the "-std" flag out of the $CC
and $CXX variables, which we traditionally assume to be just the
executable name/path, and move it to $CFLAGS/$CXXFLAGS instead.

Fixes #24324

- - - - -


2 changed files:

- configure.ac
- + m4/fp_prog_move_to_flags.m4


Changes:

=====================================
configure.ac
=====================================
@@ -417,6 +417,9 @@ dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
 dnl later CC is copied to CC_STAGE{1,2,3}
 AC_PROG_CC([cc gcc clang])
 AC_PROG_CXX([g++ clang++ c++])
+# Work around #24324
+MOVE_TO_FLAGS([CC],[CFLAGS])
+MOVE_TO_FLAGS([CXX],[CXXFLAGS])
 
 MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
 


=====================================
m4/fp_prog_move_to_flags.m4
=====================================
@@ -0,0 +1,19 @@
+# MOVE_TO_FLAGS
+# --------------------------------
+# Split off flags from $1 (the compiler) to $2 (the flags).
+# This works around autoconf setting $CC and $CXX to be a program plus the C11
+# `-std=...11` flag (#24324), starting from autotools 2.70.
+AC_DEFUN([MOVE_TO_FLAGS],[
+
+dnl Use IFS=' ' to split off the command from the arguments in $1.
+dnl By expanding $$1, set accounts for quoting correctly, such that splitting
+dnl e.g. '"A B/C" D' results in "A B/C" and "D".
+tmp_IFS="$IFS"
+IFS=' '
+eval set -- $$1
+IFS="$tmp_IFS"
+
+$1="[$]1"
+shift
+$2="[$]@ $$2"
+])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dab53ea1188e04fc3e75b7cc7df73f0323aa8d9f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dab53ea1188e04fc3e75b7cc7df73f0323aa8d9f
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/20240201/b3a846f6/attachment-0001.html>


More information about the ghc-commits mailing list