diff --git a/configure b/configure index c6afcd7494..5f84299339 100755 --- a/configure +++ b/configure @@ -976,6 +976,12 @@ add_objcflags(){ append OBJCFLAGS $($objcflags_filter "$@") } +add_allcflags(){ + add_cflags "$@" + add_cxxflags "$@" + add_objcflags "$@" +} + add_asflags(){ append ASFLAGS $($asflags_filter "$@") } @@ -1036,6 +1042,14 @@ cc_o(){ eval printf '%s\\n' $CC_O } +cxx_e(){ + eval printf '%s\\n' $CXX_E +} + +cxx_o(){ + eval printf '%s\\n' $CXX_O +} + as_o(){ eval printf '%s\\n' $AS_O } @@ -1071,14 +1085,14 @@ test_cxx(){ log test_cxx "$@" cat > $TMPCPP log_file $TMPCPP - test_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP + test_cmd $cxx $CPPFLAGS $CXXFLAGS "$@" $CXX_C $(cxx_o $TMPO) $TMPCPP } test_objcc(){ log test_objcc "$@" cat > $TMPM log_file $TMPM - test_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM + test_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM } test_nvcc(){ @@ -1288,14 +1302,19 @@ check_cflags(){ test_cflags "$@" && add_cflags "$@" } -check_cxxflags(){ - log check_cxxflags "$@" +test_cxxflags(){ + log test_cxxflags "$@" set -- $($cflags_filter "$@") - test_cxx "$@" <&1 | grep -q '^GNU assembler'; then @@ -5207,7 +5234,9 @@ probe_cc(){ else _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' fi - _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' + _DEPFLAGS='$(CPPFLAGS) -showIncludes -Zs' + _DEPCCFLAGS='$(CFLAGS)' + _DEPCXXFLAGS='$(CXXFLAGS)' _cflags_speed="-O2" _cflags_size="-O1" _cflags_noopt="-O1" @@ -5223,6 +5252,7 @@ probe_cc(){ _ld_lib='%.lib' _ld_path='-libpath:' _flags='-nologo' + _cxxflags='-Zc:__cplusplus -EHsc' disable stripping elif $_cc --version 2>/dev/null | grep -q ^cparser; then _type=cparser @@ -5243,11 +5273,11 @@ set_ccvars(){ eval ${1}_O=\${_cc_o-\${${1}_O}} if [ -n "$_depflags" ]; then - eval ${1}_DEPFLAGS=\$_depflags + eval "${1}_DEPFLAGS=\"\$_depflags\"" else - eval ${1}DEP=\${_DEPCMD:-\$DEPCMD} - eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS} - eval DEP${1}FLAGS=\$_flags + eval "${1}DEP=\"\${_DEPCMD:-\$DEPCMD}\"" + eval "${1}DEP_FLAGS=\"\${_DEPFLAGS:-\$DEPFLAGS} \${_DEP${1}FLAGS:-\$DEP${1}FLAGS}\"" + eval "DEP${1}FLAGS=\"\$_flags\"" fi } @@ -5257,6 +5287,7 @@ cflags_speed=$_cflags_speed cflags_size=$_cflags_size cflags_noopt=$_cflags_noopt add_cflags $_flags $_cflags +add_cxxflags $_flags $_cxxflags cc_ldflags=$_ldflags set_ccvars CC set_ccvars CXX @@ -5303,8 +5334,11 @@ HOSTLD_O=${_ld_o-$HOSTLD_O} if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then probe_cc depcc "$dep_cc" CCDEP=${_DEPCMD:-$DEPCMD} + CXXDEP=${CCDEP} CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS} - DEPCCFLAGS=$_flags + CXXDEP_FLAGS=${CCDEP_FLAGS} + DEPCCFLAGS=$_flags $_cflags + DEPCXXFLAGS=$_flags $_cxxflags fi if VSLANG=1033 $ar 2>&1 | grep -q ^Microsoft; then @@ -5502,7 +5536,7 @@ elif enabled arm; then ;; esac - test_cflags -mfp16-format=ieee && add_cflags -mfp16-format=ieee + check_allcflags -mfp16-format=ieee elif enabled loongarch; then @@ -5737,7 +5771,7 @@ else fi if [ "$cpu" != generic ]; then - add_cflags $cpuflags + add_allcflags $cpuflags add_asflags $cpuflags test "$cc_type" = "$ld_type" && add_ldflags $cpuflags fi @@ -5760,6 +5794,8 @@ add_cxxflags -D__STDC_CONSTANT_MACROS check_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 201103L" || { check_cxxflags -std=c++11 && stdcxx="c++11" || { check_cxxflags -std=c++0x && stdcxx="c++0x"; }; } +test_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 201703L" && enable cxx17 + # some compilers silently accept -std=c11, so we also need to check that the # version macro is defined properly check_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" || @@ -5854,7 +5890,7 @@ case $target_os in android) disable symver enable section_data_rel_ro - add_cflags -fPIE + add_allcflags -fPIE add_ldexeflags -fPIE -pie SLIB_INSTALL_NAME='$(SLIBNAME)' SLIB_INSTALL_LINKS= @@ -5935,7 +5971,7 @@ case $target_os in # Workaround for Xcode 11 -fstack-check bug if enabled clang; then clang_version=$($cc -dumpversion) - test ${clang_version%%.*} -eq 11 && add_cflags -fno-stack-check + test ${clang_version%%.*} -eq 11 && add_allcflags -fno-stack-check fi # Xcode Clang doesn't default to -fno-common while upstream llvm.org @@ -6154,15 +6190,17 @@ probe_libc(){ # MinGW headers can be installed on Cygwin, so check for newlib first. elif test_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then eval ${pfx}libc_type=newlib - add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600 + add_${pfx}cflags -U__STRICT_ANSI__ + add_${pfx}cppflags -D_XOPEN_SOURCE=600 # MinGW64 is backwards compatible with MinGW32, so check for it first. elif test_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then eval ${pfx}libc_type=mingw64 if test_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then add_compat msvcrt/snprintf.o - add_cflags "-include $source_path/compat/msvcrt/snprintf.h" + add_allcflags "-include $source_path/compat/msvcrt/snprintf.h" fi - add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 + add_${pfx}cflags -U__STRICT_ANSI__ + add_${pfx}cppflags -D__USE_MINGW_ANSI_STDIO=1 eval test \$${pfx_no_}cc_type = "gcc" && add_${pfx}cppflags -D__printf__=__gnu_printf__ test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" && @@ -6174,7 +6212,8 @@ probe_libc(){ test_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \ (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW32 runtime version must be >= 3.15." - add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 + add_${pfx}cflags -U__STRICT_ANSI__ + add_${pfx}cppflags -D__USE_MINGW_ANSI_STDIO=1 test_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" && add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700 test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" && @@ -6215,8 +6254,8 @@ probe_libc(){ #endif EOF if [ "$pfx" = "" ]; then - check_func strtoll || add_cflags -Dstrtoll=_strtoi64 - check_func strtoull || add_cflags -Dstrtoull=_strtoui64 + check_func strtoll || add_allcflags -Dstrtoll=_strtoi64 + check_func strtoull || add_allcflags -Dstrtoull=_strtoui64 fi elif test_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then eval ${pfx}libc_type=klibc @@ -6228,7 +6267,7 @@ EOF elif test_${pfx}cpp_condition sys/version.h "defined __DJGPP__"; then eval ${pfx}libc_type=djgpp add_cppflags -U__STRICT_ANSI__ - add_cflags "-include $source_path/compat/djgpp/math.h" + add_allcflags "-include $source_path/compat/djgpp/math.h" add_compat djgpp/math.o fi test_${pfx}cc <