diff --git a/docs/guide/simulating.rst b/docs/guide/simulating.rst index 1abd93a11..6fb2fa08a 100644 --- a/docs/guide/simulating.rst +++ b/docs/guide/simulating.rst @@ -431,8 +431,7 @@ Profiling ccache efficiency The Verilator-generated Makefile supports basic profiling of ccache behavior during the build. This can be used to track down files that might be unnecessarily rebuilt, though as of today, even minor code changes will -usually require rebuilding a large number of files. Improving ccache -efficiency during the edit/compile/test loop is an active development area. +usually require rebuilding a large number of files. To get a basic report of how well ccache is doing, add the `ccache-report` target when invoking the generated Makefile: @@ -445,8 +444,9 @@ This will print a report based on all executions of ccache during this invocation of Make. The report is also written to a file, in this example `obj_dir/Vout__cache_report.txt`. -To use the `ccache-report` target, at least one other explicit build target -must be specified, and OBJCACHE must be set to 'ccache'. +To use the `ccache-report` target, OBJCACHE must be set to 'ccache' (this is +done by `configure` if 'ccache' is installed). If no other explicit build +targets are specified, `cchache-report` will build the `default` target. This feature is currently experimental and might change in subsequent releases. diff --git a/include/verilated.mk.in b/include/verilated.mk.in index ccc177bfb..189fedeea 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -311,30 +311,27 @@ ifneq ($(findstring ccache-report,$(MAKECMDGOALS)),) endif VK_OTHER_GOALS := $(strip $(subst ccache-report,,$(MAKECMDGOALS))) ifeq ($(VK_OTHER_GOALS),) - $(error ccache-report must be used with at least one other explicit target) + VK_OTHER_GOALS := default endif # Report ccache behaviour for this invocation of make VK_CCACHE_LOGDIR := ccache-logs VK_CCACHE_REPORT := $(VM_PREFIX)__ccache_report.txt - # Remove previous logfiles and report + + # Remove previous logfiles and report, then create log directory $(shell rm -rf $(VK_CCACHE_LOGDIR) $(VK_CCACHE_REPORT)) + $(shell mkdir -p $(VK_CCACHE_LOGDIR)) - $(VK_CCACHE_LOGDIR): - mkdir -p $@ - - $(VK_OBJS): | $(VK_CCACHE_LOGDIR) - + # Add ccache logging to compilation rules $(VK_OBJS): export CCACHE_LOGFILE=$(VK_CCACHE_LOGDIR)/$@.log - $(VK_CCACHE_REPORT): $(VK_OBJS) + # ccache-report runs last + $(VK_CCACHE_REPORT): $(VK_OBJS) $(VK_OTHER_GOALS) $(VERILATOR_CCACHE_REPORT) -o $@ $(VK_CCACHE_LOGDIR) - # ccache-report runs last .PHONY: ccache-report - ccache-report: $(VK_CCACHE_REPORT) $(VK_OTHER_GOALS) + ccache-report: $(VK_CCACHE_REPORT) @cat $< - endif ###################################################################### diff --git a/test_regress/t/t_ccache_report.py b/test_regress/t/t_ccache_report.py index 65ae1e93a..6770b2f88 100755 --- a/test_regress/t/t_ccache_report.py +++ b/test_regress/t/t_ccache_report.py @@ -35,8 +35,7 @@ test.files_identical(report, "t/" + test.name + "__ccache_report_initial.out") # Now rebuild again (should be all up to date) test.run(logfile=test.obj_dir + "/rebuild.log", cmd=[ - os.environ["MAKE"], "-C " + test.obj_dir, "-f " + test.vm_prefix + ".mk", - test.vm_prefix, "ccache-report" + os.environ["MAKE"], "-C " + test.obj_dir, "-f " + test.vm_prefix + ".mk", "ccache-report" ]) test.files_identical(report, "t/" + test.name + "__ccache_report_rebuild.out")