[Git][ghc/ghc][wip/romes/24324] Work around autotools setting C11 standard in CC/CXX
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Fri Jan 19 09:48:29 UTC 2024
Rodrigo Mesquita pushed to branch wip/romes/24324 at Glasgow Haskell Compiler / GHC
Commits:
2b76e4fc by Rodrigo Mesquita at 2024-01-19T09:48:17+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_std_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_STD_TO_FLAGS([CC],[CFLAGS])
+MOVE_STD_TO_FLAGS([CXX],[CXXFLAGS])
MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
=====================================
m4/fp_prog_move_std_to_flags.m4
=====================================
@@ -0,0 +1,16 @@
+# MOVE_STD_TO_FLAGS
+# --------------------------------
+# Split -std=... off of $1, and move it into $2.
+# This works around autoconf setting $CC and $CXX to be a program + the -std
+# flag to C2011 (#24324) starting from autotools 2.70.
+AC_DEFUN([MOVE_STD_TO_FLAGS],[
+tmp_$1="$$1"
+$1="${tmp_$1%% -std=*}"
+tmp_STD="${tmp_$1##* -std=}"
+
+dnl Add the tmp_STD to $2, if it was set.
+dnl If there was no -std flag, tmp_STD will be set to $1
+if ! test "$tmp_STD" = "$tmp_$1"; then
+ $2="-std=$tmp_STD $$2"
+fi
+])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b76e4fce1522a0aaa70a9f3db593494e96cc957
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b76e4fce1522a0aaa70a9f3db593494e96cc957
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/20240119/ae4565f4/attachment-0001.html>
More information about the ghc-commits
mailing list