On 10.06.2023 01:36, Kent Overstreet wrote: > Adding Peter to the cc, because I just realized gcov has a maintainer :) > > On Fri, Jun 09, 2023 at 04:12:56PM -0700, Nick Desaulniers wrote: >> On Fri, Jun 9, 2023 at 4:11 PM Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote: >>> >>> On Fri, Jun 9, 2023 at 3:23 PM Kent Overstreet >>> <kent.overstreet@xxxxxxxxx> wrote: >>>> >>>> Hello kbuild maintainers & list, >>>> >>>> Years ago I used to be able to specify additional CFLAGS for a specific >>> >>> Probably cause it's KCFLAGS ;) >>> >>> I used this yesterday, it works. >>> >>>> subdirectory on the command line, which I used for enabling gcov >> >> Ah, for a specific subdir? No I've not seen that, at least from the >> command line. Such flags can be specified via Makefile >> `subdir-ccflags-y`. > > Sorry, not CFLAGS, I misread my old code - it's just a make variable. > > From Documentation/dev-tools/gcov.rst, you enable gcov on a specific > subdirectory by editing that directory's makefile, and adding > > GCOV_PROFILE := y > > or, for a specific file within that directory, > > GCOV_PROFILE_main.o := y > > So, if appending a file to GCOV_PROFILE works, why not a path? > > This used to work - my old code would pass GCOV_PROFILE_fs_bcachefs=y on > the make command line, but doesn't anymore. 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. -- Peter Oberparleiter Linux on IBM Z Development - IBM Germany R&D