From 194825f78e0c5f24ec8d26cb18d6a4351bb3518f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 7 Oct 2011 06:48:40 -0400 Subject: [PATCH] Add configure options for cc warnings and extended tests. --- Changes | 2 ++ Makefile.in | 31 ++++++++-------- bin/verilator | 12 ++----- configure.ac | 40 ++++++++++++++++++++- include/verilated.mk.in | 5 ++- nodist/install_test | 68 +++++++++++++++++++++++++++++------- src/Makefile.in | 22 +++--------- src/Makefile_obj.in | 6 ++-- test_c/Makefile_obj | 4 +-- test_regress/Makefile | 3 +- test_regress/Makefile_obj | 7 ---- test_regress/t/t_vpi_var.cpp | 2 +- test_sp/Makefile_obj | 3 -- 13 files changed, 128 insertions(+), 77 deletions(-) diff --git a/Changes b/Changes index 1d22fd519..f2cad212f 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Fix --help output to go to stderr, not stdout, bug397. [Ruben Diez] +*** Add configure options for cc warnings and extended tests. [Ruben Diez] + **** Fix MSVC compile warning with trunc/round, bug394. [Amir Gonnen] **** Fix autoconf and Makefile warnings, bug396. [Ruben Diez] diff --git a/Makefile.in b/Makefile.in index bba615387..6a8411155 100644 --- a/Makefile.in +++ b/Makefile.in @@ -88,7 +88,10 @@ pkgdatadir = @pkgdatadir@ datarootdir = @datarootdir@ # Compile options +CFG_WITH_CCWARN = @CFG_WITH_CCWARN@ CFG_WITH_DEFENV = @CFG_WITH_DEFENV@ +CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@ +PACKAGE_VERSION = @PACKAGE_VERSION@ #### End of system configuration section. #### ###################################################################### @@ -101,8 +104,6 @@ INFOS = README internals.txt verilator.txt verilator.html verilator.1 verilator. # Files that can be generated, but should be up to date for a distribution. DISTDEP = info Makefile -# Files to distribute. -DISTBIN = $(wildcard bin/verilator-*) DISTFILES_INC = $(INFOS) .gitignore Artistic COPYING COPYING.LESSER \ *.in *.ac \ @@ -170,7 +171,7 @@ msg_test: @echo .PHONY:test -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +ifeq ($(CFG_WITH_LONGTESTS),yes) # Local... Else don't burden users test: test_vcs test_c test_sc test_sp test_verilated test_regress else test: test_c test_sc test_sp @@ -245,9 +246,6 @@ VL_INST_BIN_FILES = verilator verilator_bin verilator_bin_dbg \ # See uninstall also - don't put wildcards in this variable, it might uninstall other stuff VL_INST_MAN_FILES = verilator.1 -# Man files can either be part of the original kit, or built in current directory; local one wins -VL_INST_MAN_FILES_VPATH = $(wildcard $(addprefix $(VPATH),$(VL_INST_MAN_FILES)) $(VL_INST_MAN_FILES)) - VL_INST_INC_BLDDIR_FILES = \ include/verilated.mk \ @@ -271,9 +269,11 @@ installbin: $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(pkgdatadir)/bin ( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_includer $(DESTDIR)$(pkgdatadir)/bin/verilator_includer ) -installman: info $(VL_INST_MAN_FILES) +# Man files can either be part of the original kit, or built in current directory +# So important we use $< so VPATH is searched +installman: $(VL_INST_MAN_FILES) $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(mandir)/man1 - for p in $(VL_INST_MAN_FILES_VPATH) ; do \ + for p in $< ; do \ $(INSTALL_DATA) $$p $(DESTDIR)$(mandir)/man1/$$p; \ done @@ -318,6 +318,8 @@ install: all_nomsg installbin installman installdata install-msg install-here: installman ftp ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +DISTNAMEREV = $(shell sed -e '/DTVERSION/!d' -e 's/.*verilator_\([^"]*\).*/\1/' -e q ${srcdir}/src/config_rev.h) + DIRPROJECT := $(shell project_dir --project) VERILATOR_CAD_DIR = $(CAD_DIR)/verilator/$(DISTNAMEREV)/$(DIRPROJECT_ARCH) INST_PROJ_CVS = cp_if_cvs_diff @@ -326,7 +328,7 @@ install-project: dist @echo "Install-project to $(DIRPROJECT)" strip verilator_bin* $(MAKE) install-project-quick - for p in $(VL_INST_MAN_FILES_VPATH) ; do \ + for p in $(VL_INST_MAN_FILES) ; do \ $(INSTALL_DATA) $$p $(DIRPROJECT_PREFIX)/man/man1/$$p; \ done $(INST_PROJ_CVS) $(DISTNAME).tgz $(DIRPROJECT)/hw/utils/verilator/verilator.tgz @@ -350,7 +352,7 @@ install-cadtools: dist strip verilator_bin* $(MAKE) install-cadtools-quick $(SHELL) ${srcdir}/mkinstalldirs $(VERILATOR_CAD_DIR)/man/man1 - for p in $(VL_INST_MAN_FILES_VPATH) ; do \ + for p in $(VL_INST_MAN_FILES) ; do \ $(INSTALL_DATA) $$p $(VERILATOR_CAD_DIR)/man/man1/$$p; \ done $(INST_PROJ_CVS) $(DISTNAME).tgz $(VERILATOR_CAD_DIR)/verilator.tgz @@ -405,7 +407,7 @@ config.status: configure ./config.status --recheck configure: configure.ac -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users autoconf --warnings=all else autoconf @@ -450,11 +452,8 @@ dist-file-list: ###################################################################### # Distributions -DISTCONFIG = ${srcdir}/configure.ac - -DISTTITLE := $(shell sed -e '/^AC_INIT/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e 's/v/V/' -e q $(DISTCONFIG)) -DISTNAME := $(shell sed -e '/^AC_INIT/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e q $(DISTCONFIG)) -DISTNAMEREV := $(shell sed -e '/DTVERSION/!d' -e 's/.*verilator_\([^"]*\).*/\1/' -e q ${srcdir}/src/config_rev.h) +DISTTITLE := Verilator $(PACKAGE_VERSION) +DISTNAME := verilator-$(word 1,$(PACKAGE_VERSION)) DISTTAGNAME := $(subst .,_,$(subst -,_,$(DISTNAME))) diff --git a/bin/verilator b/bin/verilator index 98a2e2956..02aaf3209 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1233,11 +1233,6 @@ all runs of the C++ Compiler. For example, "objcache --read --write", or "ccache". If using distcc, it would generally be run under either objcache or ccache; see the documentation for those programs. -=item OBJCACHE_JOBS - -Optionally lists Make flags that specifies parallel make jobs. For example -a 4 CPU system may use "-j 6" to request 6 parallel compiles when making. - =item SYSTEMC Required for SystemC output mode. If set, specifies the directory @@ -3152,10 +3147,9 @@ Between GCC 3.0 to 3.3, each compiled progressively slower, thus if you can use GCC 2.95, or GCC 3.4 you'll have faster builds. Two ways to cheat are to compile on parallel machines and avoid compilations altogether. See the --output-split option, and the web for the ccache, distcc and icecream -packages, and the Make::Cache package available from -L. Make::Cache will skip GCC runs between -identical source builds, even across different users. You can use the -OBJCACHE environment variable to use these CC wrappers. +packages. ccache will skip GCC runs between identical source builds, even +across different users. You can use the OBJCACHE environment variable to +use these CC wrappers. =item Why do so many files need to recompile when I add a signal? diff --git a/configure.ac b/configure.ac index 07d5b1c58..8d0bc3cde 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,8 @@ AC_CONFIG_FILES(Makefile src/Makefile src/Makefile_obj include/verilated.mk) AC_MSG_RESULT([configuring for $PACKAGE_STRING]) -# Special Substitutions +# Special Substitutions - CFG_WITH_DEFENV +AC_MSG_CHECKING(whether to disable hardcoded paths) AC_ARG_ENABLE([defenv], [AS_HELP_STRING([--disable-defenv], [disable using some hardcoded data paths extracted from some default environment variables (the default is to use hardcoded paths)])], @@ -21,6 +22,43 @@ AC_ARG_ENABLE([defenv], esac], CFG_WITH_DEFENV=yes) AC_SUBST(CFG_WITH_DEFENV) +AC_MSG_RESULT($CFG_WITH_DEFENV) + +# Special Substitutions - CFG_WITH_CCWARN +AC_MSG_CHECKING(whether to show and stop on compilation warnings) +AC_ARG_ENABLE([ccwarn], + [AS_HELP_STRING([--enable-ccwarn], + [enable showing and stopping on compilation warnings])], + [case "${enableval}" in + yes) CFG_WITH_CCWARN=yes ;; + no) CFG_WITH_CCWARN=no ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-ccwarn]) ;; + esac], + [case "x${VERILATOR_AUTHOR_SITE}" in + x) CFG_WITH_CCWARN=no ;; + *) CFG_WITH_CCWARN=yes ;; + esac] + ) +AC_SUBST(CFG_WITH_CCWARN) +AC_MSG_RESULT($CFG_WITH_CCWARN) + +# Special Substitutions - CFG_WITH_LONGTESTS +AC_MSG_CHECKING(whether to run long tests) +AC_ARG_ENABLE([longtests], + [AS_HELP_STRING([--enable-longtests], + [enable running long developer tests])], + [case "${enableval}" in + yes) CFG_WITH_LONGTESTS=yes ;; + no) CFG_WITH_LONGTESTS=no ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-longtests]) ;; + esac], + [case "x${VERILATOR_AUTHOR_SITE}" in + x) CFG_WITH_LONGTESTS=no ;; + *) CFG_WITH_LONGTESTS=yes ;; + esac] + ) +AC_SUBST(CFG_WITH_LONGTESTS) +AC_MSG_RESULT($CFG_WITH_LONGTESTS) # Compiler flags CFLAGS=-I${includedir} diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 1cdfc1802..bcdface87 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -13,6 +13,9 @@ LINK = @CXX@ AR = ar RANLIB = ranlib +CFG_WITH_CCWARN = @CFG_WITH_CCWARN@ +CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@ + ###################################################################### # Programs @@ -38,7 +41,7 @@ VK_CPPFLAGS_ALWAYS += \ -DVM_TRACE=$(VM_TRACE) \ -DVM_COVERAGE=$(VM_COVERAGE) \ -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users VK_CPPFLAGS_WALL += -Wall \ -Wno-char-subscripts \ -Wno-sign-compare \ diff --git a/nodist/install_test b/nodist/install_test index ef243b24f..0a0134424 100755 --- a/nodist/install_test +++ b/nodist/install_test @@ -12,12 +12,15 @@ use vars qw ($Debug); #====================================================================== # main +our $Opt_Stage = 0; + autoflush STDOUT 1; autoflush STDERR 1; Getopt::Long::config ("no_auto_abbrev"); if (! GetOptions ( "debug" => sub { $Debug = 1; }, "<>" => sub { die "%Error: Unknown parameter: $_[0]\n"; }, + "stage=i" => \$Opt_Stage, )) { die "%Error: Bad usage, try 'install_test --help'\n"; } @@ -33,14 +36,14 @@ sub test { $ENV{VERILATOR_NO_OPT_BUILD} = 1; # Don't build optimized executables; just slows this down run("make distclean") if -r "Makefile"; - my $stage = $ENV{VERILATOR_INSTALL_TEST_STAGE}||0; # For debugging this process - # Try building from a scratch area my $srcdir = getcwd(); my $blddir = $srcdir."/test_regress/obj_dir/install_test_bld"; my $prefix = $srcdir."/test_regress/obj_dir/install_test_prefix"; - my $testdir = $srcdir."/test_regress/obj_dir/install_test_test"; - if ($stage <= 0) { + my $testdirp= $srcdir."/test_regress/obj_dir/install_test_testp"; + my $testdirn= $srcdir."/test_regress/obj_dir/install_test_testn"; + + if ($Opt_Stage <= 0) { run("/bin/rm -rf $blddir"); run("/bin/mkdir -p $blddir"); run("cd $blddir && $srcdir/configure --prefix $prefix"); @@ -48,24 +51,63 @@ sub test { } # Install it under the prefix - if ($stage <= 1) { + if ($Opt_Stage <= 1) { run("/bin/rm -rf $prefix"); run("/bin/mkdir -p $prefix"); run("cd $blddir && make install"); + run("test -e $prefix/share/man/man1/verilator.1"); + run("test -e $prefix/share/verilator/examples/test_c/Makefile"); + run("test -e $prefix/share/verilator/include/verilated.h"); + run("test -e $prefix/bin/verilator"); + run("test -e $prefix/bin/verilator_bin"); + run("test -e $prefix/bin/verilator_bin_dbg"); + run("test -e $prefix/bin/verilator_profcfunc"); } # Run a test using just the path - if ($stage <= 2) { - run("/bin/rm -rf $testdir"); - run("/bin/mkdir -p $testdir"); + if ($Opt_Stage <= 2) { + my $dir = $testdirp; + run("/bin/rm -rf $dir"); + run("/bin/mkdir -p $dir"); my $bin1 = $prefix."/bin"; my $bin2 = $prefix."/share/bin"; - IO::File->new(">$testdir/foo.v")->print('module t; initial begin $display("HELLO WORLD"); end endmodule'."\n"); - run("cd $testdir && PATH=$bin1:$bin2:\$PATH verilator --cc foo.v"); - run("cd $testdir/obj_dir && PATH=$bin1:$bin2:\$PATH make -f Vfoo.mk"); - #Need .c file, and --exe for this to work - #run("cd $testdir && PATH=$bin1:$bin2:\$PATH obj_dir/Vfoo"); + write_verilog($dir); + run("cd $dir && PATH=$bin1:$bin2:\$PATH verilator --cc foo.v --exe foo.cpp"); + run("cd $dir/obj_dir && PATH=$bin1:$bin2:\$PATH make -f Vfoo.mk"); + run("cd $dir && PATH=$bin1:$bin2:\$PATH obj_dir/Vfoo"); } + + # Run a test using exact path to binary + if ($Opt_Stage <= 3) { + my $dir = $testdirn; + run("/bin/rm -rf $dir"); + run("/bin/mkdir -p $dir"); + write_verilog($dir); + my $bin1 = $prefix."/bin"; + my $bin2 = $prefix."/share/bin"; + run("cd $dir && $bin1/verilator --cc foo.v --exe foo.cpp"); + run("cd $dir/obj_dir && make -f Vfoo.mk"); + run("cd $dir/obj_dir && ./Vfoo"); + } +} + +sub write_verilog { + my $dir = shift; + IO::File->new(">$dir/foo.v")->print('module t; initial begin $display("HELLO WORLD"); $finish; end endmodule'."\n"); + my $fh = IO::File->new(">$dir/foo.cpp"); + $fh->print('#include "Vfoo.h"' ,"\n"); + $fh->print('unsigned int main_time = 0;' ,"\n"); + $fh->print('double sc_time_stamp () {' ,"\n"); + $fh->print(' return main_time;' ,"\n"); + $fh->print('}' ,"\n"); + $fh->print('int main() {' ,"\n"); + $fh->print(' Vfoo *top = new Vfoo;' ,"\n"); + $fh->print(' while (!Verilated::gotFinish()) {',"\n"); + $fh->print(' top->eval();' ,"\n"); + $fh->print(' main_time++;' ,"\n"); + $fh->print(' }' ,"\n"); + $fh->print(' top->final();' ,"\n"); + $fh->print('}' ,"\n"); } sub cleanenv { diff --git a/src/Makefile.in b/src/Makefile.in index 7d1cb404d..08ee63450 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,20 +33,6 @@ default: dbg opt debug: dbg optimize: opt -ifeq ($(OBJCACHE_HOSTS),) - ifneq ($(SLCHOOSED_HOST),) - ifeq ($(VERILATOR_AUTHOR_SITE),1) -export OBJCACHE_HOSTS := $(shell rschedule --no-allow-reserved --similar hostnames) - endif - endif -endif - -ifeq ($(OBJCACHE_JOBS),) -ifneq ($(OBJCACHE_HOSTS),) -export OBJCACHE_JOBS := -j $(shell objcache --jobs "$(OBJCACHE_HOSTS)") -endif -endif - ifneq ($(words $(CURDIR)),1) $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif @@ -69,14 +55,14 @@ ifeq ($(VERILATOR_NO_OPT_BUILD),1) # Faster laptop development... One build -cp -p $<$(EXEEXT) $@$(EXEEXT) else ../verilator_bin: obj_opt prefiles - cd obj_opt && $(MAKE) -j 1 TGT=../$@ -f ../Makefile_obj serial - cd obj_opt && $(MAKE) $(OBJCACHE_JOBS) TGT=../$@ -f ../Makefile_obj + cd obj_opt && $(MAKE) -j 1 TGT=../$@ -f ../Makefile_obj serial + cd obj_opt && $(MAKE) TGT=../$@ -f ../Makefile_obj endif dbg: ../verilator_bin_dbg ../verilator_bin_dbg: obj_dbg prefiles - cd obj_dbg && $(MAKE) -j 1 TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj serial - cd obj_dbg && $(MAKE) $(OBJCACHE_JOBS) TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj + cd obj_dbg && $(MAKE) -j 1 TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj serial + cd obj_dbg && $(MAKE) TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj prefiles:: diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 5d0991563..dd2c07de0 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -57,6 +57,7 @@ datarootdir = @datarootdir@ pkgdatadir = @pkgdatadir@ # Compile options +CFG_WITH_CCWARN = @CFG_WITH_CCWARN@ CFG_WITH_DEFENV = @CFG_WITH_DEFENV@ CPPFLAGS += @CPPFLAGS@ LDFLAGS += @LDFLAGS@ @@ -92,7 +93,7 @@ CPPFLAGS += -DYYDEBUG # Required to get nice error messages #CPPFLAGS += -DVL_LEAK_CHECKS # If running valgrind or other hunting tool CPPFLAGS += $(COPT) CPPFLAGS += -MP # Only works on recent GCC versions -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users CPPFLAGS += -W -Wall -Wno-unused-parameter -Wno-char-subscripts -Werror #CPPFLAGS += -pedantic-errors endif @@ -252,9 +253,6 @@ $(TGT): V3Ast__gen_classes.h $(OBJS) @echo " Linking $@..." -rm -rf $@ $@.exe ${LINK} ${LDFLAGS} -o $@ $(OBJS) $(CCMALLOC) ${LIBS} -ifneq ($(EXEEXT),) - cp $@$(EXEEXT) $@ -endif V3Number_test: V3Number_test.o ${LINK} ${LDFLAGS} -o $@ $^ ${LIBS} diff --git a/test_c/Makefile_obj b/test_c/Makefile_obj index ecc6b7b68..4d4f16f4f 100644 --- a/test_c/Makefile_obj +++ b/test_c/Makefile_obj @@ -19,11 +19,9 @@ include Vtop.mk # Compile flags CPPFLAGS += -DVL_DEBUG=1 -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users +ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users CPPFLAGS += -DVL_THREADED=1 CPPFLAGS += -W -Werror -Wall -#CPPFLAGS += -Wno-unused-variable # Instead, add VL_ATTR_UNUSED in gen'ed code -#CPPFLAGS += -pedantic-errors endif ####################################################################### diff --git a/test_regress/Makefile b/test_regress/Makefile index 879754046..56a137f47 100644 --- a/test_regress/Makefile +++ b/test_regress/Makefile @@ -35,7 +35,8 @@ endif PRODUCTS += --vlt -ifeq ($(VERILATOR_AUTHOR_SITE),1) +# Run tests in parallel. Requires Parallel::Forker to be installed. +ifeq ($(CFG_WITH_LONGTESTS),yes) DRIVER_FLAGS += -j 0 endif diff --git a/test_regress/Makefile_obj b/test_regress/Makefile_obj index c2c2817a1..7ef4abbcd 100644 --- a/test_regress/Makefile_obj +++ b/test_regress/Makefile_obj @@ -25,13 +25,6 @@ VPATH += ../../$(VM_USER_DIR) ####################################################################### -ifeq ($(VERILATOR_AUTHOR_SITE),1) -#OBJCACHE := objcache --read --write -#OBJCACHE_HOSTS := -endif - -####################################################################### - # Needed by DPI tests CPPFLAGS += -DVERILATOR=1 diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index ef540b072..e7a3188ae 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -80,7 +80,7 @@ int _mon_check_mcd() { PLI_INT32 status; PLI_UINT32 mcd; - PLI_BYTE8* filename = (PLI_BYTE8*)"mcd_open.tmp"; + PLI_BYTE8* filename = (PLI_BYTE8*)"obj_dir/mcd_open.tmp"; mcd = vpi_mcd_open(filename); CHECK_RESULT_NZ(mcd); diff --git a/test_sp/Makefile_obj b/test_sp/Makefile_obj index f85d89e61..6d2186798 100644 --- a/test_sp/Makefile_obj +++ b/test_sp/Makefile_obj @@ -22,9 +22,6 @@ CPPFLAGS += -DUTIL_PRINTF=sp_log_printf CPPFLAGS += -Wno-deprecated CPPFLAGS += $(SYSTEMC_CXX_FLAGS) CPPFLAGS += $(OPT) -ifeq ($(VERILATOR_AUTHOR_SITE),1) # Local... Else don't burden users -#CPPFLAGS += -W -Wall -Wno-char-subscripts -Wno-unused-parameter -Wno-unused-variable -Wno-uninitialized -Werror -endif LDFLAGS += $(SYSTEMC_CXX_FLAGS)