configure: get real version for clang(++)

`clang++ -dumpversion` always outputs 4.2.1 as it was designed to be
compatible with `g++` in that version. So parse `clang++ --version`
for `clang++` instead.
This commit is contained in:
Moritz Bunkus 2017-11-17 21:32:10 +01:00
parent e8f2b6a69d
commit de093c2913
6 changed files with 16 additions and 10 deletions

View File

@ -25,10 +25,10 @@ else
WNO_MAYBE_UNINITIALIZED="-Wno-maybe-uninitialized"
FSTACK_PROTECTOR="-fstack-protector"
if check_version 4.9.0 $ac_cv_gcc_version ; then
if check_version 4.9.0 $ac_cv_compiler_version ; then
FSTACK_PROTECTOR="-fstack-protector-strong"
elif check_version 4.8.0 $ac_cv_gcc_version ; then
elif check_version 4.8.0 $ac_cv_compiler_version ; then
WLOGICAL_OP="-Wlogical-op"
fi
fi

10
ac/compiler_version.m4 Normal file
View File

@ -0,0 +1,10 @@
AC_CACHE_CHECK(
[compiler version],
[ac_cv_compiler_version],
[
if test x"$ac_cv_compiler_is_clang" = xyes; then
ac_cv_compiler_version=`LC_ALL=C $CXX --version | sed -e 's/^[[^0-9]]*//' -e 's/[[^0-9.]].*//' -e '1q'`
else
ac_cv_compiler_version=`$CXX -dumpversion`
fi
])

View File

@ -38,7 +38,7 @@ if test x"$enable_optimization" = xyes; then
opt_features_no="$opt_features_no\n * full optimization: due to bug 11962 in LLVM/clang only -O1 will be used for optimization"
OPTIMIZATION_CFLAGS="-O1"
elif test "x$ac_cv_mingw32" = "xyes" -a "x$MINGW_PROCESSOR_ARCH" = "xx86" && check_version 5.1.0 $ac_cv_gcc_version; then
elif test "x$ac_cv_mingw32" = "xyes" -a "x$MINGW_PROCESSOR_ARCH" = "xx86" && check_version 5.1.0 $ac_cv_compiler_version; then
OPTIMIZATION_CFLAGS="-O2 -fno-ipa-icf"
opt_features_no="$opt_features_no\n * full optimization: due to an issue in mingw g++ full optimization cannot be used"

View File

@ -1,4 +0,0 @@
AC_CACHE_CHECK(
[gcc version],
[ac_cv_gcc_version],
[ac_cv_gcc_version=`$CXX -dumpversion | sed -e 's/[[^0-9\.]].*//g'`])

View File

@ -8,7 +8,7 @@ AC_ARG_ENABLE([precompiled_headers],
[enable_precompiled_headers=auto])
if test x"$enable_precompiled_headers" = x"auto"; then
if ! check_version 4.1.0 $ac_cv_gcc_version ; then
if ! check_version 4.1.0 $ac_cv_compiler_version ; then
enable_precompiled_headers=no
else
enable_precompiled_headers=yes

View File

@ -11,9 +11,9 @@ m4_include(ac/other_features.m4)
m4_include(ac/pkg.m4)
m4_include(ac/initialization.m4)
m4_include(ac/check_version.m4)
m4_include(ac/gcc_version.m4)
m4_include(ac/c++-features.m4)
m4_include(ac/clang.m4)
m4_include(ac/compiler_version.m4)
m4_include(ac/c++-features.m4)
m4_include(ac/compiler_flags.m4)
m4_include(ac/endianess.m4)
m4_include(ac/mingw.m4)