On 4/29/24 7:39 PM, Michael Ellerman wrote:
Madhavan Srinivasan <ma...@linux.ibm.com> writes:
When running `make -C powerpc/pmu run_tests` from top level selftests
directory, currently this error is being reported

make: Entering directory '/home/maddy/linux/tools/testing/selftests/powerpc/pmu'
Makefile:40: warning: overriding recipe for target 'emit_tests'
../../lib.mk:111: warning: ignoring old recipe for target 'emit_tests'
gcc -m64    count_instructions.c ../harness.c event.c lib.c ../utils.c loop.S  
-o /home/maddy/selftest_output//count_instructions
In file included from count_instructions.c:13:
event.h:12:10: fatal error: utils.h: No such file or directory
12 | #include "utils.h"
   |          ^~~~~~~~~
compilation terminated.

This is due to missing of include path in CFLAGS. That is, CFLAGS and
GIT_VERSION macros are defined in the powerpc/ folder Makefile which
in this case not involved.

To address the failure incase of executing specific sub-folder test directly,
a new rule file has been addded by the patch called "flags.mk" under
selftest/powerpc/ folder and is linked to all the Makefile of powerpc/pmu
sub-folders.
This patch made my selftest build go from ~10s to ~50s !

I tracked it down to "git describe" being run hundreds of times.

diff --git a/tools/testing/selftests/powerpc/flags.mk 
b/tools/testing/selftests/powerpc/flags.mk
new file mode 100644
index 000000000000..28374f470126
--- /dev/null
+++ b/tools/testing/selftests/powerpc/flags.mk
@@ -0,0 +1,12 @@
+#This checks for any ENV variables and add those.
+
+#ifeq ($(GIT_VERSION),)
This isn't right, # is a comment in make syntax, so this line is just a
comment. It needs to be "ifeq".

oops, my bad :(
But nice catch. Thanks

Maddy



+GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
Using '=' here means Make re-runs the command every time the variable is
used. Previously that was OK because the variable was set once and then
exported. But now that it's a Make variable in each file it leads to
"git describe" being run a few hundred times.

I've squashed in those fixes, no need to send a v2.

cheers

Reply via email to