# HG changeset patch # User Markus Mützel # Date 1643050937 -3600 # Mon Jan 24 20:02:17 2022 +0100 # Branch stable # Node ID 53b843176a19b1aa742901e2d47e9fcdbad46add # Parent 8c6486ffc1d9d98d6c4d5ae003ae055d17af9ed1 build: Check for compiler option to enable GNU extensions (bug #61841). * 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 8c6486ffc1d9 -r 53b843176a19 configure.ac --- a/configure.ac Wed Jan 19 09:28:18 2022 -0800 +++ b/configure.ac Mon Jan 24 20:02:17 2022 +0100 @@ -332,8 +332,47 @@ 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. + ## FIXME: Will it even be possible to compile if the compiler doesn't + ## support 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. + ## FIXME: Will it even be possible to compile if the compiler doesn't + ## support GNU extensions? + 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 +439,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.