# HG changeset patch # User Markus Mützel # Date 1643050937 -3600 # Node ID 9c98df2035a3ea00660bb2c509d15eb9daffe7ec # Parent 7a9d358fb66d1c3ed5b7055567fef1d09eebf980 build: Check for compiler option to enable GNU extensions (bug #61812). * configure.ac: Check for compiler option to enable C++17 support if configured with --enable-std-pmr-polymorphic-allocator. Prefer compiler options that enable GNU extensions. diff -r 7a9d358fb66d -r 9c98df2035a3 configure.ac --- a/configure.ac Mon Jan 24 22:13:13 2022 +0100 +++ b/configure.ac Mon Jan 24 20:02:17 2022 +0100 @@ -332,8 +332,43 @@ AC_PROG_CXX AC_PROG_CXXCPP -## Ensure that the C++ compiler fully supports C++11. -AX_CXX_COMPILE_STDCXX(11, [], []) +ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no +AC_ARG_ENABLE(std-pmr-polymorphic-allocator, + [AS_HELP_STRING([--enable-std-pmr-polymorphic-allocator], + [build libraries requiring std::pmr::polymorphic_allocator if possible. This allows more efficient transfer of arrays at the .mex file interface. That also means that all libraries including Octave headers (e.g., .oct files) must be able to compile with that C++17 feature.])], + [case $enableval in + yes) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=yes ;; + no) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no ;; + *) AC_MSG_ERROR([bad value $enableval for --enable-std-pmr-polymorphic-allocator]) ;; + esac]) + +### Check compiler capabilities. + +if test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then + ## Test for flags to fully support C++17 (with GNU extensions). + AX_CXX_COMPILE_STDCXX(17, ext, []) + if test "$HAVE_CXX17" = 0; then + ## A compiler supporting C++17 with GNU extensions couldn't be found. + ## Try without forcing GNU extensions. + AX_CXX_COMPILE_STDCXX(17, [], []) + fi +else + HAVE_CXX17=0 +fi +if test "$HAVE_CXX17" = 0; then + ## Ensure that the C++ compiler fully supports C++11 preferably with GNU + ## extensions. + AX_CXX_COMPILE_STDCXX(11, ext, []) + if test "$HAVE_CXX11" = 0; then + ## A compiler supporting C++11 with GNU extensions couldn't be found. + ## Try without forcing GNU extensions. Fail if that's not the case. + AX_CXX_COMPILE_STDCXX(11, [], mandatory) + fi +fi + +if test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then + OCTAVE_CHECK_STD_PMR_POLYMORPHIC_ALLOCATOR +fi ### Determine which C compiler to use (we expect to find gcc). @@ -400,20 +435,6 @@ OCTAVE_CONFIGURE_WARNING([warn_stl_algo_h]) fi -ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no -AC_ARG_ENABLE(std-pmr-polymorphic-allocator, - [AS_HELP_STRING([--enable-std-pmr-polymorphic-allocator], - [build libraries requiring std::pmr::polymorphic_allocator if possible. This allows more efficient transfer of arrays at the .mex file interface. That also means that all libraries including Octave headers (e.g., .oct files) must be able to compile with that C++17 feature.])], - [case $enableval in - yes) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=yes ;; - no) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no ;; - *) AC_MSG_ERROR([bad value $enableval for --enable-std-pmr-polymorphic-allocator]) ;; - esac]) - -if test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then - OCTAVE_CHECK_STD_PMR_POLYMORPHIC_ALLOCATOR -fi - ### Check version number when using gcc. dnl It might be different from the g++ version number.