Skip to content

Commit e65d81c

Browse files
committed
build: improve detection and reporting of -std= flag detection
First, reintroduce testing $CXX without any -std flag. Second, abort configure if no usable combination was found. References: GXH-106
1 parent 15b1355 commit e65d81c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

configure.ac

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,34 @@ my_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
2424
my_CFLAGS="-Wall -Wmissing-declarations -Wwrite-strings"
2525
my_CXXFLAGS="-Wall -Wmissing-declarations"
2626
my_LDFLAGS=""
27-
AC_MSG_CHECKING([available C++ standard])
28-
cxxmode=""
29-
for i in "c++26" "c++2c" "c++23" "c++2b" "c++20"; do
27+
cxxmode="error"
28+
AC_MSG_CHECKING([for C++ standard availability])
29+
echo ""
30+
for i in "" "c++26" "c++2c" "c++23" "c++2b" "c++20"; do
3031
dnl cov-scan cannot take too high a standard
3132
AS_IF([test -n "$COVERITY" && test "$i" != "c++20"], [continue])
32-
CXXFLAGS="$saved_CXXFLAGS -std=$i"
33+
AC_MSG_CHECKING([if $CXX${i:+ -std=$i} works for our code])
34+
CXXFLAGS="$saved_CXXFLAGS${i:+ -std=$i}"
3335
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
3436
#include <span>
3537
#include <vector>
3638
int main() {
3739
std::vector<int> v{1,9};
3840
std::span s = v;
3941
}
40-
])], [cxxmode="$i"])
41-
AS_IF([test -n "$cxxmode"], [break])
42+
])], [
43+
AC_MSG_RESULT([yes])
44+
cxxmode="${i:+ -std=$i}"
45+
break
46+
], [
47+
AC_MSG_RESULT([no])
48+
])
4249
done
4350
CXXFLAGS="$saved_CXXFLAGS"
44-
AS_IF([test -n "$cxxmode"], [
45-
my_CXXFLAGS="$my_CXXFLAGS -std=$cxxmode"
46-
AC_MSG_RESULT([$cxxmode])
47-
], [
48-
AC_MSG_RESULT([none])
51+
AS_IF([test "$cxxmode" = error], [
52+
AC_MSG_ERROR([None of the -std= flags we tried led to successful compilation, but we need C++20 support.])
4953
])
54+
my_CXXFLAGS="$my_CXXFLAGS${cxxmode}"
5055

5156
AC_ARG_WITH([asan], AS_HELP_STRING([--with-asan], [Activate Address Sanitizer]),
5257
[

0 commit comments

Comments
 (0)