Skip to content

Commit 5eae20f

Browse files
8323672: Suppress unwanted autoconf added flags in CC and CXX
Reviewed-by: ihse
1 parent 6ed6dff commit 5eae20f

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

make/autoconf/toolchain.m4

+1-5
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
307307
[
308308
# Restore old path, except for the microsoft toolchain, which requires the
309309
# toolchain path to remain in place. Otherwise the compiler will not work in
310-
# some siutations in later configure checks.
310+
# some situations in later configure checks.
311311
if test "x$TOOLCHAIN_TYPE" != "xmicrosoft"; then
312312
PATH="$OLD_PATH"
313313
fi
@@ -316,10 +316,6 @@ AC_DEFUN_ONCE([TOOLCHAIN_POST_DETECTION],
316316
# This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
317317
CFLAGS="$ORG_CFLAGS"
318318
CXXFLAGS="$ORG_CXXFLAGS"
319-
320-
# filter out some unwanted additions autoconf may add to CXX; we saw this on macOS with autoconf 2.72
321-
UTIL_GET_NON_MATCHING_VALUES(cxx_filtered, $CXX, -std=c++11 -std=gnu++11)
322-
CXX="$cxx_filtered"
323319
])
324320

325321
# Check if a compiler is of the toolchain type we expect, and save the version

make/autoconf/util.m4

+64
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,70 @@
2525

2626
m4_include([util_paths.m4])
2727

28+
###############################################################################
29+
# Overwrite the existing version of AC_PROG_CC with our own custom variant.
30+
# Unlike the regular AC_PROG_CC, the compiler list must always be passed.
31+
AC_DEFUN([AC_PROG_CC],
32+
[
33+
AC_LANG_PUSH(C)
34+
AC_ARG_VAR([CC], [C compiler command])
35+
AC_ARG_VAR([CFLAGS], [C compiler flags])
36+
37+
_AC_ARG_VAR_LDFLAGS()
38+
_AC_ARG_VAR_LIBS()
39+
_AC_ARG_VAR_CPPFLAGS()
40+
41+
AC_CHECK_TOOLS(CC, [$1])
42+
43+
test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
44+
45+
# Provide some information about the compiler.
46+
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
47+
set X $ac_compile
48+
ac_compiler=$[2]
49+
for ac_option in --version -v -V -qversion -version; do
50+
_AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
51+
done
52+
53+
m4_expand_once([_AC_COMPILER_EXEEXT])
54+
m4_expand_once([_AC_COMPILER_OBJEXT])
55+
56+
_AC_PROG_CC_G
57+
58+
AC_LANG_POP(C)
59+
])
60+
61+
###############################################################################
62+
# Overwrite the existing version of AC_PROG_CXX with our own custom variant.
63+
# Unlike the regular AC_PROG_CXX, the compiler list must always be passed.
64+
AC_DEFUN([AC_PROG_CXX],
65+
[
66+
AC_LANG_PUSH(C++)
67+
AC_ARG_VAR([CXX], [C++ compiler command])
68+
AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
69+
70+
_AC_ARG_VAR_LDFLAGS()
71+
_AC_ARG_VAR_LIBS()
72+
_AC_ARG_VAR_CPPFLAGS()
73+
74+
AC_CHECK_TOOLS(CXX, [$1])
75+
76+
# Provide some information about the compiler.
77+
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
78+
set X $ac_compile
79+
ac_compiler=$[2]
80+
for ac_option in --version -v -V -qversion; do
81+
_AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
82+
done
83+
84+
m4_expand_once([_AC_COMPILER_EXEEXT])
85+
m4_expand_once([_AC_COMPILER_OBJEXT])
86+
87+
_AC_PROG_CXX_G
88+
89+
AC_LANG_POP(C++)
90+
])
91+
2892
################################################################################
2993
# Create a function/macro that takes a series of named arguments. The call is
3094
# similar to AC_DEFUN, but the setup of the function looks like this:

0 commit comments

Comments
 (0)