[Git][ghc/ghc][master] Work around autotools setting C11 standard in CC/CXX
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sat Feb 3 06:54:37 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05: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/cdddeb0f1280b40cc194028bbaef36e127175c4c
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdddeb0f1280b40cc194028bbaef36e127175c4c
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/20240203/b20ba5a7/attachment-0001.html>
More information about the ghc-commits
mailing list