On Mon, Apr 24, 2023 at 02:46:53PM -0300, Marcos Paulo de Souza wrote: > Hi, > > I've being trying to understand a problem when adding a new rule to compile > modules on ksefltests: > > $ make kselftest TARGETS=livepatch > make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' > make[3]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' > make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules > m2c -o scripts/Makefile.build -e scripts/Makefile.build scripts/Makefile.build.mod > make[5]: m2c: No such file or directory > > I managed to create a minimal reproducer for the problem here[1]. I'll attach > the patches at the end of the email if you want to inspect the changes without > getting the patches from github. Humble ping :) > > The curious part is, if I execute the ksefltests using a different target, it > works: > > $ make -C tools/testing/selftests run_tests TARGETS=livepatch > make: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests' > make[1]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' > make -C /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules > make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' > make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules > CC [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.o > MODPOST /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/Module.symvers > CC [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.mod.o > LD [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.ko > BTF [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.ko > make[2]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' > make[1]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' > make[1]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' > make -C /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules > make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' > make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules > make[2]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' > TAP version 13 > 1..1 > # selftests: livepatch: test-true.sh > ok 1 selftests: livepatch: test-true.sh > make[1]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' > make: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests' > > In the root Makefile, ksefltest is defined as: > > PHONY += kselftest > kselftest: headers > $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests > > So, it's quite odd that a "mostly identical" rules being triggered result in > that odd "m2c" command being invoked. Both outputs here were got from a openSUSE > Tumbleweed machine, using make 4.4.1. When executing the kselftest target on a > Ubuntu machine, the error is similar but not the same: > > ... > make[4]: Entering directory '/root/linux-kbuild' > make -f ./scripts/Makefile.build obj=arch/x86/entry/syscalls all > m2c -o scripts/Makefile.lib -e scripts/Makefile.lib scripts/Makefile.lib.mod > make[5]: m2c: No such file or directory > make[5]: *** [<builtin>: scripts/Makefile.lib] Error 127 > make[4]: *** [arch/x86/Makefile:248: archheaders] Error 2 > ... > > So, error is the same, but it failed on Makefile.lib, instead of Makefile.build > from the previous run. > > I also tried to change the KDIR from > tools/testing/selftests/livepatch/test_modules/Makefile to point to KDIR ?= > /lib/modules/$(shell uname -r)/build, but it then results in a different > problem, making building_out_of_srctree to be set to false on > /usr/src/linux-6.2.10-1-obj/x86_64/default/Makefile, which then results in > different problems... So I would like to understand this problem first, since > there was no way to stop make from calling "m2c". It was also tested on > linux-kbuild/for-next, but the problem is the same. > > I also found some links[2] mentioning "m2c", but the workarounds didn't solved > the issue. At this point any help would be great! > > [1]: https://github.com/marcosps/linux/commits/kbuild-next-kselftests > [2]: https://lists.mcs.anl.gov/pipermail/petsc-users/2010-November/007299.html