Fix ccache-report with PCH files

This commit is contained in:
Geza Lore 2025-11-07 09:36:09 +00:00
parent 9d74984163
commit 0b0e103fde
3 changed files with 13 additions and 17 deletions

View File

@ -431,8 +431,7 @@ Profiling ccache efficiency
The Verilator-generated Makefile supports basic profiling of ccache The Verilator-generated Makefile supports basic profiling of ccache
behavior during the build. This can be used to track down files that might 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 be unnecessarily rebuilt, though as of today, even minor code changes will
usually require rebuilding a large number of files. Improving ccache usually require rebuilding a large number of files.
efficiency during the edit/compile/test loop is an active development area.
To get a basic report of how well ccache is doing, add the `ccache-report` To get a basic report of how well ccache is doing, add the `ccache-report`
target when invoking the generated Makefile: 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 invocation of Make. The report is also written to a file, in this example
`obj_dir/Vout__cache_report.txt`. `obj_dir/Vout__cache_report.txt`.
To use the `ccache-report` target, at least one other explicit build target To use the `ccache-report` target, OBJCACHE must be set to 'ccache' (this is
must be specified, and OBJCACHE must be set to 'ccache'. 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 This feature is currently experimental and might change in subsequent
releases. releases.

View File

@ -311,30 +311,27 @@ ifneq ($(findstring ccache-report,$(MAKECMDGOALS)),)
endif endif
VK_OTHER_GOALS := $(strip $(subst ccache-report,,$(MAKECMDGOALS))) VK_OTHER_GOALS := $(strip $(subst ccache-report,,$(MAKECMDGOALS)))
ifeq ($(VK_OTHER_GOALS),) ifeq ($(VK_OTHER_GOALS),)
$(error ccache-report must be used with at least one other explicit target) VK_OTHER_GOALS := default
endif endif
# Report ccache behaviour for this invocation of make # Report ccache behaviour for this invocation of make
VK_CCACHE_LOGDIR := ccache-logs VK_CCACHE_LOGDIR := ccache-logs
VK_CCACHE_REPORT := $(VM_PREFIX)__ccache_report.txt 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 rm -rf $(VK_CCACHE_LOGDIR) $(VK_CCACHE_REPORT))
$(shell mkdir -p $(VK_CCACHE_LOGDIR))
$(VK_CCACHE_LOGDIR): # Add ccache logging to compilation rules
mkdir -p $@
$(VK_OBJS): | $(VK_CCACHE_LOGDIR)
$(VK_OBJS): export CCACHE_LOGFILE=$(VK_CCACHE_LOGDIR)/$@.log $(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) $(VERILATOR_CCACHE_REPORT) -o $@ $(VK_CCACHE_LOGDIR)
# ccache-report runs last
.PHONY: ccache-report .PHONY: ccache-report
ccache-report: $(VK_CCACHE_REPORT) $(VK_OTHER_GOALS) ccache-report: $(VK_CCACHE_REPORT)
@cat $< @cat $<
endif endif
###################################################################### ######################################################################

View File

@ -35,8 +35,7 @@ test.files_identical(report, "t/" + test.name + "__ccache_report_initial.out")
# Now rebuild again (should be all up to date) # Now rebuild again (should be all up to date)
test.run(logfile=test.obj_dir + "/rebuild.log", test.run(logfile=test.obj_dir + "/rebuild.log",
cmd=[ cmd=[
os.environ["MAKE"], "-C " + test.obj_dir, "-f " + test.vm_prefix + ".mk", os.environ["MAKE"], "-C " + test.obj_dir, "-f " + test.vm_prefix + ".mk", "ccache-report"
test.vm_prefix, "ccache-report"
]) ])
test.files_identical(report, "t/" + test.name + "__ccache_report_rebuild.out") test.files_identical(report, "t/" + test.name + "__ccache_report_rebuild.out")