changeset 33162:5108f56fc8fc bytecode-interpreter

maint: merge default to bytecode-interpreter
author John W. Eaton <jwe@octave.org>
date Wed, 06 Mar 2024 22:55:27 -0500
parents 899647fde914 (current diff) e86c59dac135 (diff)
children 88a08496297a
files configure.ac
diffstat 4 files changed, 103 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Wed Mar 06 13:02:42 2024 -0500
+++ b/configure.ac	Wed Mar 06 22:55:27 2024 -0500
@@ -313,10 +313,14 @@
 AC_PROG_CXX
 AC_PROG_CXXCPP
 
-ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=yes
+## Ensure that the C++ compiler fully supports C++17.
+## Preferably with GNU extensions if flags are required.
+AX_CXX_COMPILE_STDCXX(17, [], mandatory)
+
+ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no
 AC_ARG_ENABLE(std-pmr-polymorphic-allocator,
   [AS_HELP_STRING([--disable-std-pmr-polymorphic-allocator],
-    [build libraries that do not require support for std::pmr::polymorphic_allocator.  This prevents more efficient transfer of arrays at the .mex file interface.  With enabled std::pmr::polymorphic_allocator, sources including Octave headers (e.g., for .oct files) must conform to C++17.])],
+    [build libraries that do not require support for std::pmr::polymorphic_allocator.  This prevents more efficient transfer of arrays at the .mex file interface.])],
   [case $enableval in
      yes) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=yes ;;
      no) ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR=no ;;
@@ -340,34 +344,6 @@
 
 ### Determine C++ compiler capabilities.
 
-if test "$QT_VERSIONS" = 6; then
-  ## If QT_VERSIONS is set to 6, require that the C++ compiler fully
-  ## supports C++17.  Preferably with GNU extensions if flags are required.
-  ## We could use "AX_CXX_COMPILE_STDCXX(17, [], mandatory)" in this case.
-  ## But prefer to emit a more helpful error message.
-  AX_CXX_COMPILE_STDCXX(17, [], [])
-  if test "$HAVE_CXX17" = 0; then
-    ## The user explicitly requested Qt6.  But the C++ compiler lacks
-    ## support for C++17.
-    AC_MSG_ERROR([Qt6 requires a compiler that supports C++17.  Configure with "--with-qt=5" or "--without-qt", or use a compiler that supports C++17.])
-  fi
-elif test -z "${QT_VERSIONS+x}" || test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then
-  ## If QT_VERSIONS is not explicitly set, check if the C++ compiler fully
-  ## supports C++17 (but don't require it).
-  ## The defaults for the Qt version will depend on the result of this check.
-  AX_CXX_COMPILE_STDCXX(17, [], [])
-else
-  ## Set HAVE_CXX17 to 0 because we don't require it (even if the used
-  ## C++ compiler might technically support C++17).
-  HAVE_CXX17=0
-fi
-
-if test "$HAVE_CXX17" = 0; then
-  ## Ensure that the C++ compiler fully supports C++11.
-  ## Preferably with GNU extensions if flags are required.
-  AX_CXX_COMPILE_STDCXX(11, [], mandatory)
-fi
-
 if test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then
   OCTAVE_CHECK_STD_PMR_POLYMORPHIC_ALLOCATOR
 fi
@@ -2349,32 +2325,20 @@
   LIBS="$save_LIBS"
 fi
 
-### Check for SUNDIALS core library and header.
-
-if test -n "$SUNDIALS_IDA_LIBS" && test -n "$SUNDIALS_NVECSERIAL_LIBS"; then
-
-  save_CPPFLAGS="$CPPFLAGS"
-  save_LDFLAGS="$LDFLAGS"
-  save_LIBS="$LIBS"
-  LIBS="$SUNDIALS_CORE_LIBS $LIBS"
-  LDFLAGS="$SUNDIALS_CORE_LDFLAGS $LDFLAGS"
-  CPPFLAGS="$SUNDIALS_CORE_CPPFLAGS $CPPFLAGS"
-  OCTAVE_CHECK_LIB(sundials_core, [SUNDIALS core],
-    [SUNDIALS core library not found.],
-    [sundials_core.h sundials/sundials_core.h], [SUNContext_Create],
-    [], [])
-  CPPFLAGS="$save_CPPFLAGS"
-  LDFLAGS="$save_LDFLAGS"
-  LIBS="$save_LIBS"
+if test -n "$SUNDIALS_IDA_LIBS" \
+    && test -n "$SUNDIALS_NVECSERIAL_LIBS"; then
+  octave_have_sundials_libs=yes
+else
+  octave_have_sundials_libs=no
 fi
 
 ### Check for SUNDIALS library features, some required, some optional.
 
-if test -n "$SUNDIALS_IDA_LIBS" && test -n "$SUNDIALS_NVECSERIAL_LIBS"; then
-
-  CPPFLAGS="$SUNDIALS_IDA_CPPFLAGS $SUNDIALS_NVECSERIAL_CPPFLAGS $SUNDIALS_CORE_CPPFLAGS $KLU_CPPFLAGS $BLAS_CPPFLAGS $CPPFLAGS"
-  LDFLAGS="$SUNDIALS_IDA_LDFLAGS $SUNDIALS_NVECSERIAL_LDFLAGS $SUNDIALS_CORE_LDFLAGS $KLU_LDFLAGS $BLAS_LDFLAGS $LDFLAGS"
-  LIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $SUNDIALS_CORE_LIBS $KLU_LIBS $BLAS_LIBS $FLIBS $LIBS"
+if test "x$octave_have_sundials_libs" == xyes; then
+
+  CPPFLAGS="$SUNDIALS_IDA_CPPFLAGS $SUNDIALS_NVECSERIAL_CPPFLAGS $KLU_CPPFLAGS $BLAS_CPPFLAGS $CPPFLAGS"
+  LDFLAGS="$SUNDIALS_IDA_LDFLAGS $SUNDIALS_NVECSERIAL_LDFLAGS $KLU_LDFLAGS $BLAS_LDFLAGS $LDFLAGS"
+  LIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $KLU_LIBS $BLAS_LIBS $FLIBS $LIBS"
   if test -z "$warn_sundials_nvecserial" && test -z "$warn_sundials_ida"; then
     dnl Any of the following tests could determine that SUNDIALS is
     dnl incompatible and should be disabled.  In that event, they all populate
@@ -2410,7 +2374,7 @@
 dnl How can we do a better job here?  Do we need to disable sundials
 dnl any tests fail, or can we fix __ode15__.cc so that it still partially
 dnl works when some things are missing (for example, KLU)?
-if test -n "$SUNDIALS_IDA_LIBS" && test -n "$SUNDIALS_NVECSERIAL_LIBS"; then
+if test "x$octave_have_sundials_libs" == xyes; then
   if test "x$octave_cv_sundials_sunlinsol_dense" = xyes \
       && test "x$octave_cv_sundials_realtype_is_double" = xyes \
       && test "x$octave_have_sundials_compatible_api" = xyes; then
--- a/etc/NEWS.10.md	Wed Mar 06 13:02:42 2024 -0500
+++ b/etc/NEWS.10.md	Wed Mar 06 22:55:27 2024 -0500
@@ -88,6 +88,11 @@
         shift                  | circshift
         sparse_auto_mutate     | none (see below)
 
+### Build system
+
+- Octave now requires a C++ compiler that is compliant with C++17 (preferably
+with GNU extensions).
+
 
 Summary of bugs fixed for version 10.1.0 (yyyy-mm-dd):
 ----------------------------------------------------
--- a/m4/acinclude.m4	Wed Mar 06 13:02:42 2024 -0500
+++ b/m4/acinclude.m4	Wed Mar 06 22:55:27 2024 -0500
@@ -1999,15 +1999,6 @@
   warn_qt_abstract_item_model=""
   warn_qt_opengl=""
 
-  if test $build_qt_gui = yes && test "$qt_version" -eq 6; then
-    ## Ensure that the C++ compiler fully supports C++17.
-    ## Preferably with GNU extensions if flags are required.
-    if test $HAVE_CXX17 -eq 0; then
-      build_qt_gui=no
-      warn_qt_cxx17="compiler doesn't support C++17; disabling Qt GUI"
-    fi
-  fi
-
   if test $build_qt_gui = yes; then
     ## Check for Qt libraries
     case "$qt_version" in
@@ -2293,6 +2284,40 @@
   ])
 ])
 dnl
+dnl Check for library that exports SUNContext_Create.
+dnl
+AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNCONTEXT_CREATE], [
+  save_LIBS=$LIBS
+  LIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $LIBS"
+  dnl Check for SUNContext_Create without linking to libsundials_core.
+  dnl That should succeed for SUNDIALS version 6.
+  AC_CHECK_FUNC([SUNContext_Create])
+  LIBS="$save_LIBS"
+  if test "x$ac_cv_func_SUNContext_Create" != xyes; then
+    ## SUNDIALS version 7 exports SUNContext_Create from libsundials_core
+    save_CPPFLAGS="$CPPFLAGS"
+    save_LDFLAGS="$LDFLAGS"
+    save_LIBS="$LIBS"
+    LIBS="$SUNDIALS_CORE_LIBS $LIBS"
+    LDFLAGS="$SUNDIALS_CORE_LDFLAGS $LDFLAGS"
+    CPPFLAGS="$SUNDIALS_CORE_CPPFLAGS $CPPFLAGS"
+    ## Unset cache variable from previous check
+    unset ac_cv_func_SUNContext_Create
+    OCTAVE_CHECK_LIB(sundials_core, [SUNDIALS core], [],
+      [sundials_core.h sundials/sundials_core.h], [SUNContext_Create],
+      [], [])
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+  fi
+  if test "x$ac_cv_func_SUNContext_Create" = xyes \
+    || test "x$octave_cv_lib_sundials_core" = xyes; then
+    ## SUNDIALS prior to version 6 does not need SUNContext_Create
+    AC_DEFINE(HAVE_SUNDIALS_SUNCONTEXT, 1,
+      [Define to 1 if SUNDIALS API uses a SUNContext object.])
+  fi
+])
+dnl
 dnl Check whether SUNDIALS libraries provide a compatible interface.
 dnl The current recommended interface was introduced in SUNDIALS version 4.
 dnl The deprecated interface that Octave currently works to be compatible with
@@ -2302,7 +2327,7 @@
   ac_octave_save_LIBS=$LIBS
   LIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $LIBS"
   dnl Current API functions present in SUNDIALS version 4
-  AC_CHECK_FUNCS([IDASetJacFn IDASetLinearSolver SUNLinSol_Dense SUNSparseMatrix_Reallocate SUNContext_Create])
+  AC_CHECK_FUNCS([IDASetJacFn IDASetLinearSolver SUNLinSol_Dense SUNSparseMatrix_Reallocate])
   dnl FIXME: The purpose of the following tests is to detect the deprecated
   dnl API from SUNDIALS version 3, which should only be used if the current
   dnl API tests above failed. For now, always test for ida_direct.h.
@@ -2323,10 +2348,6 @@
     octave_have_sundials_compatible_api=no
   fi
   AC_MSG_RESULT([$octave_have_sundials_compatible_api])
-  if test "x$ac_cv_func_SUNContext_Create" = xyes; then
-    AC_DEFINE(HAVE_SUNDIALS_SUNCONTEXT, 1,
-      [Define to 1 if SUNDIALS' API is using a SUNContext object.])
-  fi
   if test $octave_have_sundials_compatible_api = no; then
     warn_sundials_disabled="SUNDIALS libraries do not provide an API that is compatible with Octave.  The solvers ode15i and ode15s will be disabled."
     OCTAVE_CONFIGURE_WARNING([warn_sundials_disabled])
@@ -2418,7 +2439,15 @@
      #  include <ufsparse/klu.h>
      #endif
     ])
+  ## Check for library that exports SUNContext_Create
+  OCTAVE_CHECK_SUNDIALS_SUNCONTEXT_CREATE
   ## Check for current KLU function name first.
+  save_CPPFLAGS="$CPPFLAGS"
+  save_LDFLAGS="$LDFLAGS"
+  save_LIBS="$LIBS"
+  CPPFLAGS="$SUNDIALS_CORE_CPPFLAGS $CPPFLAGS"
+  LDFLAGS="$SUNDIALS_CORE_LDFLAGS $LDFLAGS"
+  LIBS="$SUNDIALS_CORE_LIBS $LIBS"
   OCTAVE_CHECK_LIB(sundials_sunlinsolklu, SUNLINSOL_KLU, [],
     [], [SUNLinSol_KLU], [],
     [don't use SUNDIALS SUNLINSOL_KLU library, disable ode15i and ode15s sparse Jacobian],
@@ -2445,9 +2474,12 @@
          #include <sunlinsol/sunlinsol_klu.h>
          #endif
          ]], [[
-         #if defined (HAVE_SUNCONTEXT_CREATE)
+         #if defined (HAVE_SUNDIALS_SUNCONTEXT)
+         #  if ! defined (SUN_COMM_NULL)
+         #    define SUN_COMM_NULL NULL
+         #  endif
            SUNContext *sunContext;
-           if (SUNContext_Create (NULL, sunContext) < 0)
+           if (SUNContext_Create (SUN_COMM_NULL, sunContext) < 0)
              1/0;  // provoke an error
            SUNLinSol_KLU (0, 0, *sunContext);
            SUNContext_Free (sunContext);
@@ -2464,7 +2496,7 @@
       [], [SUNKLU], [],
       [don't use SUNDIALS SUNLINSOL_KLU library, disable ode15i and ode15s sparse Jacobian],
       [AC_CHECK_FUNCS([SUNKLU])
-       AC_CACHE_CHECK([whether compiling a program that calls SUNLinSol_KLU works],
+       AC_CACHE_CHECK([whether compiling a program that calls SUNKLU works],
         [octave_cv_sundials_sunlinsol_klu],
         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
            #if defined (HAVE_IDA_IDA_H)
@@ -2500,6 +2532,9 @@
     warn_sundials_sunlinsol_klu="SUNDIALS IDA library not configured with SUNLINSOL_KLU or sunlinsol_klu.h is not usable.  The solvers ode15i and ode15s will not support the sparse Jacobian feature."
     OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_klu])
   fi
+  CPPFLAGS="$save_CPPFLAGS"
+  LDFLAGS="$save_LDFLAGS"
+  LIBS="$save_LIBS"
 ])
 dnl
 dnl Like AC_CONFIG_FILES, but don't touch the output file if it already
--- a/oct-conf-post-public.in.h	Wed Mar 06 13:02:42 2024 -0500
+++ b/oct-conf-post-public.in.h	Wed Mar 06 22:55:27 2024 -0500
@@ -32,54 +32,32 @@
 #define OCTAVE_BEGIN_NAMESPACE(name) namespace name {
 #define OCTAVE_END_NAMESPACE(name) }
 
-/* We require C++17 now so it should be possible to use
-   [[deprecated(message)]], [[noreturn]], and [[unused]] unconditionally
-   but for now we'll keep the macros in case there is an issue.  Even if
-   we decide to use the C++ standard attributes directly in the Octave
-   sources without the macros, OCTAVE_DEPRECATED will still be useful to
-   provide consistent formatting of the version number.  */
+/* The C++ standard is evolving to allow attribute hints in a
+   compiler-independent manner.  In C++ 2011 support for noreturn was
+   added.  In C++ 2014 support for deprecated was added.  The Octave
+   code base has been future-proofed by using macros of the form
+   OCTAVE_ATTRIBUTE_NAME in place of vendor specific attribute
+   mechanisms.  As compilers evolve, the underlying implementation can
+   be changed with the macro definitions below.  FIXME: Update macros
+   to use C++ standard attribute syntax when Octave moves to C++ 2014
+   standard.  */
 
 #if defined (__GNUC__)
-
-#  if !defined (OCTAVE_DEPRECATED)
-#    if defined (__cplusplus)
-#      define OCTAVE_DEPRECATED(ver, msg) [[deprecated ("[" #ver "]: " msg)]]
-#    else
-#      define OCTAVE_DEPRECATED(ver, msg) __attribute__ ((__deprecated__ ("[" #ver "]: " msg)))
-#    endif
+   /* The following attributes are used with gcc and clang compilers.  */
+#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#    define OCTAVE_DEPRECATED(ver, msg) __attribute__ ((__deprecated__ ("[" #ver "]: " msg)))
+#  else
+#    define OCTAVE_DEPRECATED(ver, msg) __attribute__ ((__deprecated__))
 #  endif
 #  define HAVE_OCTAVE_DEPRECATED_ATTR 1
 
-#  if !defined (OCTAVE_FALLTHROUGH)
-#    if defined (__cplusplus)
-#      define OCTAVE_FALLTHROUGH [[fallthrough]]
-#    else
-#      define OCTAVE_FALLTHROUGH __attribute__ ((__fallthrough__))
-#    endif
-#    define HAVE_OCTAVE_FALLTHROUGH_ATTR 1
-#  endif
+#  define OCTAVE_NORETURN __attribute__ ((__noreturn__))
+#  define HAVE_OCTAVE_NORETURN_ATTR 1
 
-#  if !defined (OCTAVE_NORETURN)
-#    if defined (__cplusplus)
-#      define OCTAVE_NORETURN [[noreturn]]
-#    else
-#      define OCTAVE_NORETURN __attribute__ ((__noreturn__))
-#    endif
-#    define HAVE_OCTAVE_NORETURN_ATTR 1
-#  endif
-
-#  if !defined (OCTAVE_UNUSED)
-#    if defined (__cplusplus)
-#      define OCTAVE_UNUSED [[maybe_unused]]
-#    else
-#      define OCTAVE_UNUSED __attribute__ ((__unused__))
-#    endif
-#    define HAVE_OCTAVE_UNUSED_ATTR 1
-#  endif
-
+#  define OCTAVE_UNUSED __attribute__ ((__unused__))
+#  define HAVE_OCTAVE_UNUSED_ATTR 1
 #else
 #  define OCTAVE_DEPRECATED(ver, msg)
-#  define OCTAVE_FALLTHROUGH ((void) 0)
 #  define OCTAVE_NORETURN
 #  define OCTAVE_UNUSED
 
@@ -89,10 +67,7 @@
 #endif
 
 /* Branch hint macros for use in if condititions.
-   Returns logical value of x.
-
-   FIXME: With C++20, can we use [[likely]] and [[unlikely]]?  If so,
-   what is the purpose of the argument X in the macros below?  */
+   Returns logical value of x. */
 #if defined (__GNUC__)
 #  define OCTAVE_LIKELY(x) __builtin_expect (!!(x), 1)
 #  define OCTAVE_UNLIKELY(x) __builtin_expect (!!(x), 0)
@@ -129,6 +104,16 @@
 /* #  undef HAVE_OCTAVE_FORMAT_PRINTF_ATTR */
 #endif
 
+#if ! defined (OCTAVE_FALLTHROUGH)
+#  if defined (__cplusplus) && __cplusplus > 201402L
+#    define OCTAVE_FALLTHROUGH [[fallthrough]]
+#  elif defined (__GNUC__) && __GNUC__ < 7
+#    define OCTAVE_FALLTHROUGH ((void) 0)
+#  else
+#    define OCTAVE_FALLTHROUGH __attribute__ ((__fallthrough__))
+#  endif
+#endif
+
 #if defined (__cplusplus)
 template <typename T>
 static inline void