From 7a207da5a81866fc1c1c01c0ae463d8c0dde55c3 Mon Sep 17 00:00:00 2001 From: Hong Chen Date: Fri, 15 Nov 2024 09:52:20 -0600 Subject: [PATCH] To support ubuntu24, clang 18+, and gcc13. --- autoconf/configure.ac | 28 ++-- configure | 178 ++++++++++++++++--------- libexec/trick/pm/parse_s_define.pm | 11 +- share/trick/makefiles/config_Linux.mk | 6 +- test/SIM_mc_generation/S_overrides.mk | 3 +- test/SIM_stls/S_overrides.mk | 4 +- test/SIM_stls/models/STLCheckpoint.cpp | 1 + test/SIM_test_sched/S_overrides.mk | 2 +- 8 files changed, 153 insertions(+), 80 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 141dec7a..beeae363 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -209,7 +209,23 @@ AC_PATH_PROG(CLANG, clang, noclang, "$LLVM_BIN_DIR:/bin:/usr/bin:/usr/local/bin: AS_IF([test "$ac_cv_path_CLANG" = "noclang"],AC_MSG_ERROR([could not find clang]),[]) AC_SUBST([LLVM_HOME]) -OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic" +TR_CLANG_VERSION +dnl if llvm/clang, test for version >= 3.4.2 +AS_IF([test "x$CLANG_VERSION" = "x"],[], + [AC_MSG_CHECKING([clang version >= 3.4.2]) + AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[3.4.2], [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Trick requires llvm/clang version >= 3.4.2]) + ]) +]) + +AS_IF([test "x$CLANG_VERSION" = "x"],[], + [AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[18.0.0], + [OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangASTMatchers -lclangAPINotes -lclangLex -lclangBasic"], + [OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic"] + )] +) + NEW_CLANG_LIBS="-lclang-cpp" AC_CHECK_FILE([$LLVM_LIB_DIR/libclangFrontend.a], [ @@ -237,16 +253,6 @@ AC_CHECK_FILE([$LLVM_LIB_DIR/libclangSupport.a],[ICG_CLANGLIBS="$ICG_CLANGLIBS - AC_SUBST([ICG_CLANGLIBS]) -TR_CLANG_VERSION -dnl if llvm/clang, test for version >= 3.4.2 -AS_IF([test "x$CLANG_VERSION" = "x"],[], - [AC_MSG_CHECKING([clang version >= 3.4.2]) - AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[3.4.2], [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_ERROR([Trick requires llvm/clang version >= 3.4.2]) - ]) -]) - AX_CHECK_ZLIB([],AC_MSG_ERROR([could not find zlib])) dnl look for udunits in /usr/include and /usr/include/udunits2 diff --git a/configure b/configure index a315a156..44b6f85e 100755 --- a/configure +++ b/configure @@ -630,8 +630,8 @@ UDUNITS_EXCLUDE UDUNITS_LDFLAGS UDUNITS_INCLUDES UDUNITS_HOME -CLANG_VERSION ICG_CLANGLIBS +CLANG_VERSION LLVM_HOME CLANG LLVM_CONFIG @@ -717,6 +717,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -810,6 +811,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1062,6 +1064,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1199,7 +1210,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1352,6 +1363,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -7337,7 +7349,108 @@ if test "$ac_cv_path_CLANG" = "noclang"; then : fi -OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic" + + CLANG_VERSION="" + ax_cv_clang_version="`$CLANG --version | grep "version" | sed "s/.*version \(0-9*\.0-9*\.0-9*\).*/\1/"`" + if test "x$ax_cv_clang_version" = "x"; then : + + ax_cv_clang_version="" + +fi + CLANG_VERSION=$ax_cv_clang_version + + +if test "x$CLANG_VERSION" = "x"; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking clang version >= 3.4.2" >&5 +$as_echo_n "checking clang version >= 3.4.2... " >&6; } + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$CLANG_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "3.4.2" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Trick requires llvm/clang version >= 3.4.2" "$LINENO" 5 + + fi + + +fi + +if test "x$CLANG_VERSION" = "x"; then : + +else + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$CLANG_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "18.0.0" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangASTMatchers -lclangAPINotes -lclangLex -lclangBasic" + else OLD_CLANG_LIBS="-lclangFrontend -lclangDriver -lclangSerialization -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic" + + fi + + +fi + NEW_CLANG_LIBS="-lclang-cpp" as_ac_File=`$as_echo "ac_cv_file_$LLVM_LIB_DIR/libclangFrontend.a" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LLVM_LIB_DIR/libclangFrontend.a" >&5 @@ -7465,65 +7578,6 @@ fi - - CLANG_VERSION="" - ax_cv_clang_version="`$CLANG --version | grep "version" | sed "s/.*version \(0-9*\.0-9*\.0-9*\).*/\1/"`" - if test "x$ax_cv_clang_version" = "x"; then : - - ax_cv_clang_version="" - -fi - CLANG_VERSION=$ax_cv_clang_version - - -if test "x$CLANG_VERSION" = "x"; then : - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking clang version >= 3.4.2" >&5 -$as_echo_n "checking clang version >= 3.4.2... " >&6; } - - - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - - ax_compare_version_A=`echo "$CLANG_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version_B=`echo "3.4.2" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version=`echo "x$ax_compare_version_A -x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` - - - - if test "$ax_compare_version" = "true" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "Trick requires llvm/clang version >= 3.4.2" "$LINENO" 5 - - fi - - -fi - # # Handle user hints # diff --git a/libexec/trick/pm/parse_s_define.pm b/libexec/trick/pm/parse_s_define.pm index 5c179ed4..a229c1a7 100644 --- a/libexec/trick/pm/parse_s_define.pm +++ b/libexec/trick/pm/parse_s_define.pm @@ -707,6 +707,9 @@ sub handle_sim_class ($$$$) { sub handle_sim_class_job($$$) { my ($in_job, $job_id, $sim_ref) = @_ ; + + print "in_job=$in_job\n"; + my ($job_push, $is_dynamic_event) ; my ( $child, $phase, $cycle, $start, $stop, $ov_class , $ov_class_self, $sup_class_data, $tag, $job_call, $job_ret, $job_name, $args , $class ) ; @@ -716,8 +719,8 @@ sub handle_sim_class_job($$$) { $ov_class , $ov_class_self , $sup_class_data, $tag, $job_call, $job_ret, $job_name, $args) = $in_job =~ / (?: \s*(?: - ([Cc][\w\.\-\>]+) | # child spec - ([Pp][\w\.\-\>]+) | # phase spec + ([Cc][\w\.\-\>]+)?\s* # child spec + ([Pp][\w\.\-\>]+)?\s* # phase spec (?: \( (?: @@ -742,6 +745,8 @@ sub handle_sim_class_job($$$) { )\s*; # end job call /sx ; + print "The specified child is $child \n"; + print "The specified cycle is $cycle \n"; $child = 0 if ( $child eq "" ) ; $child =~ s/^C// ; @@ -777,6 +782,8 @@ sub handle_sim_class_job($$$) { } } + print "The specified phase is $phase\n"; + if ( $phase ne "" ) { $phase =~ s/^P// ; $job_push .= ", $phase" ; diff --git a/share/trick/makefiles/config_Linux.mk b/share/trick/makefiles/config_Linux.mk index 8a8876a0..4f32b781 100644 --- a/share/trick/makefiles/config_Linux.mk +++ b/share/trick/makefiles/config_Linux.mk @@ -61,5 +61,9 @@ ifeq "" "c++11" TRICK_ADDITIONAL_CXXFLAGS += -std=c++11 -D_HAVE_STL_RANDOM endif -TRICK_ADDITIONAL_TEST_FLAGS += -std=c++11 +ifeq "" "c++14" +TRICK_ADDITIONAL_CXXFLAGS += -std=c++14 -D_HAVE_STL_RANDOM +endif + +TRICK_ADDITIONAL_TEST_FLAGS += -std=c++14 diff --git a/test/SIM_mc_generation/S_overrides.mk b/test/SIM_mc_generation/S_overrides.mk index 7e7c1958..93b28e9c 100644 --- a/test/SIM_mc_generation/S_overrides.mk +++ b/test/SIM_mc_generation/S_overrides.mk @@ -1,8 +1,9 @@ TRICK_CFLAGS += -g -Wall -Wextra -TRICK_CXXFLAGS += -g -std=c++11 -Wall -Wextra +TRICK_CXXFLAGS += -g -std=c++11 -Wall -Wextra -Wno-error=unused-parameter # We can't yet make warnings to be errors on MacOS, because # MACOS deprecates and warns about sprintf. But SWIG # still generates code containing sprintf.. ifneq ($(TRICK_HOST_TYPE), Darwin) TRICK_CXXFLAGS += -Werror -Wno-stringop-truncation endif + diff --git a/test/SIM_stls/S_overrides.mk b/test/SIM_stls/S_overrides.mk index 5587ab4f..06ccb0b2 100644 --- a/test/SIM_stls/S_overrides.mk +++ b/test/SIM_stls/S_overrides.mk @@ -1,8 +1,8 @@ -TRICK_CFLAGS += -I./models +TRICK_CFLAGS += -I./models -DTRICK_UNIT_TEST TRICK_CXXFLAGS += -I./models -TRICK_CXXFLAGS += -std=c++11 +TRICK_CXXFLAGS += -std=c++11 -DTRICK_UNIT_TEST clean: checkpoint_clean diff --git a/test/SIM_stls/models/STLCheckpoint.cpp b/test/SIM_stls/models/STLCheckpoint.cpp index 1e9839dc..37dd58d5 100644 --- a/test/SIM_stls/models/STLCheckpoint.cpp +++ b/test/SIM_stls/models/STLCheckpoint.cpp @@ -759,5 +759,6 @@ int STLCheckpoint::test() { TRICK_EXPECT_EQ(vec_user_simple[i].d->c, "Here is a test string", test_suite, "vec_user_simple"); } + return 0; } diff --git a/test/SIM_test_sched/S_overrides.mk b/test/SIM_test_sched/S_overrides.mk index 27536a3b..ace5bbf2 100644 --- a/test/SIM_test_sched/S_overrides.mk +++ b/test/SIM_test_sched/S_overrides.mk @@ -1,4 +1,4 @@ TRICK_CFLAGS += -I./models -TRICK_CXXFLAGS += -I./models +TRICK_CXXFLAGS += -std=c++11 -I./models