Skip to content

Commit

Permalink
build: improve detection and reporting of -std= flag detection
Browse files Browse the repository at this point in the history
First, reintroduce testing $CXX without any -std flag.
Second, abort configure if no usable combination was found.

References: GXH-106
  • Loading branch information
jengelh committed Oct 8, 2024
1 parent 15b1355 commit e65d81c
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,34 @@ my_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
my_CFLAGS="-Wall -Wmissing-declarations -Wwrite-strings"
my_CXXFLAGS="-Wall -Wmissing-declarations"
my_LDFLAGS=""
AC_MSG_CHECKING([available C++ standard])
cxxmode=""
for i in "c++26" "c++2c" "c++23" "c++2b" "c++20"; do
cxxmode="error"
AC_MSG_CHECKING([for C++ standard availability])
echo ""
for i in "" "c++26" "c++2c" "c++23" "c++2b" "c++20"; do
dnl cov-scan cannot take too high a standard
AS_IF([test -n "$COVERITY" && test "$i" != "c++20"], [continue])
CXXFLAGS="$saved_CXXFLAGS -std=$i"
AC_MSG_CHECKING([if $CXX${i:+ -std=$i} works for our code])
CXXFLAGS="$saved_CXXFLAGS${i:+ -std=$i}"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <span>
#include <vector>
int main() {
std::vector<int> v{1,9};
std::span s = v;
}
])], [cxxmode="$i"])
AS_IF([test -n "$cxxmode"], [break])
])], [
AC_MSG_RESULT([yes])
cxxmode="${i:+ -std=$i}"
break
], [
AC_MSG_RESULT([no])
])
done
CXXFLAGS="$saved_CXXFLAGS"
AS_IF([test -n "$cxxmode"], [
my_CXXFLAGS="$my_CXXFLAGS -std=$cxxmode"
AC_MSG_RESULT([$cxxmode])
], [
AC_MSG_RESULT([none])
AS_IF([test "$cxxmode" = error], [
AC_MSG_ERROR([None of the -std= flags we tried led to successful compilation, but we need C++20 support.])
])
my_CXXFLAGS="$my_CXXFLAGS${cxxmode}"

AC_ARG_WITH([asan], AS_HELP_STRING([--with-asan], [Activate Address Sanitizer]),
[
Expand Down

0 comments on commit e65d81c

Please sign in to comment.