Require C++14 or newer (#4784) (#4786)

This commit is contained in:
Rasfunk 2023-12-29 16:39:00 +01:00 committed by GitHub
parent f3a97841bd
commit 2d7e8b58e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 22 deletions

View File

@ -354,7 +354,7 @@ AC_SUBST(CFG_CXXFLAGS_PROFILE)
# Macros work such that first option that passes is the one we take # Macros work such that first option that passes is the one we take
# Currently enable c++17/c++14 due to packaged SystemC dependency # Currently enable c++17/c++14 due to packaged SystemC dependency
# c++17 is the newest that Verilator is regularly tested to support # c++17 is the newest that Verilator is regularly tested to support
# c++11 is the oldest that Verilator supports # c++14 is the oldest that Verilator supports
# gnu is required for Cygwin to compile verilated.h successfully # gnu is required for Cygwin to compile verilated.h successfully
#_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++20) #_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++20)
#_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20) #_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20)
@ -362,8 +362,6 @@ _MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++17)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++17) _MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++17)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++14) _MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++14)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++14) _MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++14)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++11)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++11)
AC_SUBST(CFG_CXXFLAGS_STD_NEWEST) AC_SUBST(CFG_CXXFLAGS_STD_NEWEST)
# Flags for compiling Verilator internals including parser, and Verilated files # Flags for compiling Verilator internals including parser, and Verilated files
@ -521,14 +519,14 @@ _MY_LDLIBS_CHECK_IFELSE(
fi]) fi])
AC_SUBST(CFG_LIBS) AC_SUBST(CFG_LIBS)
# Need C++11 at least # Need C++14 at least
#Alternative: AX_CXX_COMPILE_STDCXX([11]) #Alternative: AX_CXX_COMPILE_STDCXX([14])
AC_DEFUN([_MY_CXX_CHECK_CXX_VER], AC_DEFUN([_MY_CXX_CHECK_CXX_VER],
[# _MY_CXX_CHECK_CXX_VER(flag) -- Check if compiler runs C++11 [# _MY_CXX_CHECK_CXX_VER(flag) -- Check if compiler runs C++14
# Set $_my_result # Set $_my_result
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <thread> [AC_LANG_PROGRAM([#include <thread>
#if (__cplusplus < 201103L) #if (__cplusplus < 201402L)
# error "Too old" # error "Too old"
#endif #endif
], [[ ]])], ], [[ ]])],
@ -544,13 +542,13 @@ AC_DEFUN([_MY_CXX_CHECK_CXX_VER],
# Add $CFG_CXXFLAGS_STD only if can't compile correctly otherwise, # Add $CFG_CXXFLAGS_STD only if can't compile correctly otherwise,
# as adding std= when not needed can cause errors with the C++ std library. # as adding std= when not needed can cause errors with the C++ std library.
CFG_CXXFLAGS_STD=$CFG_CXXFLAGS_STD_NEWEST CFG_CXXFLAGS_STD=$CFG_CXXFLAGS_STD_NEWEST
AC_MSG_CHECKING(whether $CXX supports C++11) AC_MSG_CHECKING(whether $CXX supports C++14)
_MY_CXX_CHECK_CXX_VER() _MY_CXX_CHECK_CXX_VER()
AC_MSG_RESULT($_my_result) AC_MSG_RESULT($_my_result)
if test "$_my_result" = "no" ; then if test "$_my_result" = "no" ; then
CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_STD" CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_STD"
CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE $CFG_CXXFLAGS_STD" CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE $CFG_CXXFLAGS_STD"
AC_MSG_CHECKING(whether $CXX supports C++11 with $CFG_CXXFLAGS_STD) AC_MSG_CHECKING(whether $CXX supports C++14 with $CFG_CXXFLAGS_STD)
_MY_CXX_CHECK_CXX_VER() _MY_CXX_CHECK_CXX_VER()
AC_MSG_RESULT($_my_result) AC_MSG_RESULT($_my_result)
else else
@ -560,9 +558,9 @@ else
fi fi
if test "$_my_result" = "no" ; then if test "$_my_result" = "no" ; then
AC_MSG_NOTICE([[]]) AC_MSG_NOTICE([[]])
AC_MSG_ERROR([[the $CXX compiler appears to not support C++11. AC_MSG_ERROR([[the $CXX compiler appears to not support C++14.
Verilator requires a C++11 or newer compiler.]]) Verilator requires a C++14 or newer compiler.]])
fi fi
AC_SUBST(CFG_CXXFLAGS_STD) AC_SUBST(CFG_CXXFLAGS_STD)

View File

@ -144,6 +144,7 @@ Piotr Binkowski
Qingyao Sun Qingyao Sun
Quentin Corradi Quentin Corradi
Rafal Kapuscik Rafal Kapuscik
Rasfunk
Raynard Qiao Raynard Qiao
Richard Myers Richard Myers
Risto Pejašinović Risto Pejašinović

View File

@ -8,11 +8,8 @@ The following deprecated items are scheduled for future removal:
C++11 compiler support C++11 compiler support
Verilator currently requires a C++20 or newer compiler for timing, and a Verilator currently requires a C++20 or newer compiler for timing, and a
C++11 or newer compiler for no-timing. C++14 or newer compiler for both compiling Verilator and compiling
Verilated models with --no-timing.
Verilator will require C++14 or newer compilers for both compiling
Verilator and compiling Verilated models with --no-timing no sooner than
January 2023.
Verilator will require C++20 or newer compilers for both compiling Verilator will require C++20 or newer compilers for both compiling
Verilator and compiling all Verilated models no sooner than January 2025. Verilator and compiling all Verilated models no sooner than January 2025.

View File

@ -1035,11 +1035,11 @@ Coding Conventions
================== ==================
Compiler Version and C++11 Compiler Version and C++14
-------------------------- --------------------------
Verilator requires C11. Verilator does not require any newer versions, but Verilator requires C14. Verilator does not require any newer versions, but
is maintained to build successfully with C14/C17/C20. is maintained to build successfully with C17/C20.
Indentation and Naming Style Indentation and Naming Style

View File

@ -258,11 +258,11 @@
#endif #endif
//========================================================================= //=========================================================================
// C++-2011 // C++-2014
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(VL_CPPCHECK) || defined(_MSC_VER) #if __cplusplus >= 201402L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(VL_CPPCHECK) || defined(_MSC_VER)
#else #else
# error "Verilator requires a C++11 or newer compiler" # error "Verilator requires a C++14 or newer compiler"
#endif #endif
#ifndef VL_NO_LEGACY #ifndef VL_NO_LEGACY