diff --git a/.travis.yml b/.travis.yml index 1de130691..319443126 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,13 @@ before_script: export SYSTEMC_INCLUDE=/usr/include export SYSTEMC_LIBDIR=/usr/lib/x86_64-linux-gnu fi + # Override compiler for M32 + - | + if [ "$M32" = "1" ]; then + export CC="$CC -m32" + export CXX="$CXX -m32" + unset M32 # verilated.mk actually references $(M32) so unset + fi before_cache: - ccache -s -z @@ -72,6 +79,8 @@ jobs: - {stage: build, os: linux, dist: focal, compiler: clang, workspaces: {create: {name: focal-clang, paths: .}}} # Coverage build - {stage: build, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {create: {name: coverage, paths: .}}, env: COVERAGE=1} + # 32-bit build + - {stage: build, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {create: {name: focal-gcc-m32, paths: .}}, env: M32=1} # OS X build - {stage: build, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {create: {name: osx-xcode11.6, paths: .}}} # FreeBSD build @@ -115,6 +124,11 @@ jobs: - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-1} - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-2} - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: coverage}, git: {clone: false}, env: TESTS=coverage-vltmt-3} + # 32-bit tests + - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: focal-gcc-m32}, git: {clone: false}, env: [M32=1, TESTS=dist-vlt-0]} + - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: focal-gcc-m32}, git: {clone: false}, env: [M32=1, TESTS=dist-vlt-1]} + - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: focal-gcc-m32}, git: {clone: false}, env: [M32=1, TESTS=vltmt-0]} + - {stage: test, if: type = cron, os: linux, dist: focal, compiler: gcc, workspaces: {use: focal-gcc-m32}, git: {clone: false}, env: [M32=1, TESTS=vltmt-1]} # OS X tests - {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=dist-vlt-0} - {stage: test, if: type = cron, os: osx, osx_image: xcode11.6, compiler: clang, workspaces: {use: osx-xcode11.6}, git: {clone: false}, env: TESTS=dist-vlt-1} diff --git a/ci/travis-install.bash b/ci/travis-install.bash index e75e765f4..f4c89c9bd 100755 --- a/ci/travis-install.bash +++ b/ci/travis-install.bash @@ -55,6 +55,9 @@ if [ "$TRAVIS_BUILD_STAGE_NAME" = "build" ]; then if [ "$COVERAGE" = 1 ]; then yes yes | sudo cpan -fi Unix::Processors Parallel::Forker fi + if [ "$M32" = 1 ]; then + sudo apt-get install gcc-multilib g++-multilib + fi elif [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update brew install ccache perl gperftools @@ -74,6 +77,9 @@ elif [ "$TRAVIS_BUILD_STAGE_NAME" = "test" ]; then if [ "$TRAVIS_DIST" = "focal" ]; then sudo apt-get install libsystemc-dev fi + if [ "$M32" = 1 ]; then + sudo apt-get install lib32z1-dev gcc-multilib g++-multilib + fi yes yes | sudo cpan -fi Unix::Processors Parallel::Forker # Not listing Bit::Vector as slow to install, and only skips one test install-vcddiff diff --git a/configure.ac b/configure.ac index 53ff82eaa..a09125d96 100644 --- a/configure.ac +++ b/configure.ac @@ -447,14 +447,18 @@ AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec], # - If not found or not system-wide, user can set SYSTEMC_INCLUDE. # AC_CHECK_HEADERS seems to not locate on Travis-CI but include does work. AC_MSG_CHECKING([whether SystemC is found (in system path)]) -AC_COMPILE_IFELSE( +ACO_SAVE_LIBS="$LIBS" +LIBS="$LIBS -lsystemc" +AC_LINK_IFELSE( [AC_LANG_PROGRAM([[#include - ]],[])], + extern "C" int sc_main(int argc, char* argv[]) {} + ]],[[sc_version()]])], [_my_result=yes - AC_DEFINE([HAVE_SYSTEMC_H],[1],[Defined if have systemc.h])], + AC_DEFINE([HAVE_SYSTEMC],[1],[Defined if have SystemC library])], [_my_result=no]) AC_MSG_RESULT($_my_result) -AC_SUBST(HAVE_SYSTEMC_H) +LIBS="$ACO_SAVE_LIBS" +AC_SUBST(HAVE_SYSTEMC) # Checks for system services diff --git a/include/verilated.h b/include/verilated.h index e375146c0..60fd02949 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -843,7 +843,7 @@ inline vluint64_t vl_time_stamp64() { return static_cast(sc_time_sta // Optimized assuming scale is always constant. // Can't use multiply in Q flavor, as might lose precision #define VL_TIME_UNITED_Q(scale) (VL_TIME_Q() / static_cast(scale)) -#define VL_TIME_UNITED_D(scale) (VL_TIME_D() * (1.0 / (scale))) +#define VL_TIME_UNITED_D(scale) (VL_TIME_D() / static_cast(scale)) /// Time imported from units to time precision double vl_time_multiplier(int scale); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 1fe8c3a1e..0dd0d337d 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -568,7 +568,7 @@ string V3Options::getenvVERILATOR_ROOT() { } bool V3Options::systemCSystemWide() { -#ifdef HAVE_SYSTEMC_H +#ifdef HAVE_SYSTEMC return true; #else return false; diff --git a/src/config_build.h.in b/src/config_build.h.in index 250ac1f96..f31046e03 100644 --- a/src/config_build.h.in +++ b/src/config_build.h.in @@ -80,7 +80,7 @@ using std::make_pair; // Define if SystemC found // - If defined, the default search path has it, so support is always enabled. // - If undef, not system-wide, user can set SYSTEMC_INCLUDE. -#undef HAVE_SYSTEMC_H +#undef HAVE_SYSTEMC //********************************************************************** //**** OS and compiler specifics diff --git a/test_regress/driver.pl b/test_regress/driver.pl index 8ab33a51b..0c5dc3851 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -9,7 +9,8 @@ BEGIN { if (!$ENV{VERILATOR_ROOT} && -x "../bin/verilator") { $ENV{VERILATOR_ROOT} = Cwd::getcwd()."/.."; } - $ENV{MAKE} ||= "make" + $ENV{MAKE} ||= "make"; + $ENV{CXX} ||= "c++"; } use Getopt::Long; @@ -1165,7 +1166,7 @@ sub compile { if ($param{make_pli}) { $self->oprint("Compile vpi\n") if $self->{verbose}; - my @cmd = ('c++', @{$param{pli_flags}}, "-DIS_VPI", + my @cmd = ($ENV{CXX}, @{$param{pli_flags}}, "-DIS_VPI", "$self->{t_dir}/$self->{pli_filename}"); $self->_run(logfile=>"$self->{obj_dir}/pli_compile.log", diff --git a/test_regress/t/t_flag_ldflags.pl b/test_regress/t/t_flag_ldflags.pl index e1feb205b..db80da480 100755 --- a/test_regress/t/t_flag_ldflags.pl +++ b/test_regress/t/t_flag_ldflags.pl @@ -11,13 +11,13 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(vlt => 1); run(cmd => ["cd $Self->{obj_dir}" - ." && c++ -c ../../t/t_flag_ldflags_a.cpp" + ." && $ENV{CXX} -c ../../t/t_flag_ldflags_a.cpp" ." && ar -cr t_flag_ldflags_a.a t_flag_ldflags_a.o" ." && ranlib t_flag_ldflags_a.a "], check_finished => 0); run(cmd => ["cd $Self->{obj_dir}" - ." && c++ -fPIC -c ../../t/t_flag_ldflags_so.cpp" - ." && c++ -shared -o t_flag_ldflags_so.so -lc t_flag_ldflags_so.o"], + ." && $ENV{CXX} -fPIC -c ../../t/t_flag_ldflags_so.cpp" + ." && $ENV{CXX} -shared -o t_flag_ldflags_so.so -lc t_flag_ldflags_so.o"], check_finished => 0); compile(