From 53835355b0e51fbea8b8338882e147f3133a8984 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 22 Jan 2023 09:44:50 -0500 Subject: [PATCH] Add CFG_CXXFLAGS_STD so CFG_CXXFLAGS_STD_NEWEST can still exist (#3881) --- configure.ac | 16 +++++++++------- include/verilated.mk.in | 6 ++++-- test_regress/Makefile_obj | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 4a7eaa9df..95234386e 100644 --- a/configure.ac +++ b/configure.ac @@ -532,21 +532,22 @@ AC_DEFUN([_MY_CXX_CHECK_CXX_VER], [_my_result=no]) ]) -# Add $CFG_CXXFLAGS_STD_NEWEST 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. +CFG_CXXFLAGS_STD=$CFG_CXXFLAGS_STD_NEWEST AC_MSG_CHECKING(whether $CXX supports C++11) _MY_CXX_CHECK_CXX_VER() AC_MSG_RESULT($_my_result) if test "$_my_result" = "no" ; then - CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_STD_NEWEST" - CFG_CXX_FLAGS_CMAKE="$CFG_CXX_FLAGS_CMAKE $CFG_CXXFLAGS_STD_NEWEST" - AC_MSG_CHECKING(whether $CXX supports C++11 with $CFG_CXXFLAGS_STD_NEWEST) + CXXFLAGS="$CXXFLAGS $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) _MY_CXX_CHECK_CXX_VER() AC_MSG_RESULT($_my_result) else - # CFG_CXXFLAGS_STD_NEWEST is also propagated to include/verilated.mk.in - # make sure we use the same std flag while compiling verilator and verilated design - CFG_CXXFLAGS_STD_NEWEST="" + # CFG_CXXFLAGS_STD is also propagated to include/verilated.mk.in + # make sure we use the same std flag while compiling verilator and verilated design + CFG_CXXFLAGS_STD="" fi if test "$_my_result" = "no" ; then AC_MSG_NOTICE([[]]) @@ -555,6 +556,7 @@ if test "$_my_result" = "no" ; then Verilator requires a C++11 or newer compiler.]]) fi +AC_SUBST(CFG_CXXFLAGS_STD) # Checks for library functions. AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec], diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 60d6f726f..8e040cd79 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -21,7 +21,9 @@ CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@ # Compiler flags to enable profiling CFG_CXXFLAGS_PROFILE = @CFG_CXXFLAGS_PROFILE@ -# Select newest language +# Select language required to compile (often empty) +CFG_CXXFLAGS_STD = @CFG_CXXFLAGS_STD@ +# Select newest language (unused by this Makefile, for some test's Makefiles) CFG_CXXFLAGS_STD_NEWEST = @CFG_CXXFLAGS_STD_NEWEST@ # Compiler flags to use to turn off unused and generated code warnings, such as -Wno-div-by-zero CFG_CXXFLAGS_NO_UNUSED = @CFG_CXXFLAGS_NO_UNUSED@ @@ -140,7 +142,7 @@ endif ####################################################################### ##### Threaded builds -CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST) +CPPFLAGS += $(CFG_CXXFLAGS_STD) LDLIBS += $(CFG_LDLIBS_THREADS) ifneq ($(VM_TIMING),0) diff --git a/test_regress/Makefile_obj b/test_regress/Makefile_obj index 82962f1b3..237ab1224 100644 --- a/test_regress/Makefile_obj +++ b/test_regress/Makefile_obj @@ -41,7 +41,7 @@ CPPFLAGS += $(CPPFLAGS_ADD) ifeq ($(CFG_WITH_LONGTESTS),yes) ifeq ($(DRIVER_STD),newest) - CPPFLAGS += $(CFG_CXXFLAGS_STD_NEWEST) + CPPFLAGS += $(CFG_CXXFLAGS_STD) endif endif