Skip to content
Snippets Groups Projects
Commit cdddeb0f authored by Rodrigo Mesquita's avatar Rodrigo Mesquita :seedling: Committed by Marge Bot
Browse files

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
parent 27020458
No related branches found
No related tags found
No related merge requests found
......@@ -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])
......
# 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"
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment