On Mon, Jun 12, 2023 at 06:18:35PM +0200, Peter Oberparleiter wrote: > I'm unaware of any kbuild support for setting GCOV_PROFILE for a > specific sub-directory from the command line, only from within the > associated Makefile. I'm not sure how this could have worked in the past > with the provide sample command line. > > Here's how GCOV_PROFILE evaluation works (from scripts/Makefile.lib): > > ifeq ($(CONFIG_GCOV_KERNEL),y) > _c_flags += $(if $(patsubst n%,, \ > $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)),\ > $(CFLAGS_GCOV)) > endif > > This bit of Makefile code determines whether to add the flags needed to > enabled gcov profiling (CFLAGS_GCOV) to the compiler flags for the > current compilation unit (_c_flags) by looking at the concatenation of > the following variables: > > - GCOV_PROFILE_<target base name>.o > - GCOV_PROFILE > - CONFIG_GCOV_PROFILE_ALL > > gcov flags are only added if this concatenation does not start with an > "n", and at least one of these variables is set to a non-empty value > other than "n" ("y" typically). The "starts with" part is required to > enable precedence for the more specific variable, e.g. an "n" in > GCOV_PROFILE_filename.o overwrites a "y" in GCOV_PROFILE. > > As you can see, there is no reference to a GCOV_PROFILE variable that is > named after the sub-directory for which profiling should be enabled. I've been digging through the git history, and I would swear I hallucinated the whole thing except I have the code in ktest for driving gcov and I swear it used to work :) Anyways - any thoughts on how we might implement this? I really need a way to specify directories to enable gcov for _without_ monkey patching; that's not a viable workflow in an automated setup. It seems like if we can get a list of directory prefixes for a path (e.g. given fs/bcachefs/btree_iter.o it would return fs, fs/bcachefs) it should be possible to extend the code you referenced.