Message ID | rgbi7vgqel5f2vtzeuxykeh7civd6xxbxkohsgwgsond3vwbbv@hebfs24hxzir (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Question: Adding new kselftest mod build rule resulting on "m2c: command not found" | expand |
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
On Wed, May 17, 2023 at 7:21 AM Marcos Paulo de Souza <mpdesouza@suse.de> wrote: > > 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 :) I do not know much about kselftests. Better to ask this in the kselftest ML.
From 5ac1d2d3e7e66bfe58094f00029fc4ba15555d10 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza <mpdesouza@suse.com> Date: Thu, 20 Apr 2023 11:51:29 -0300 Subject: [PATCH 2/2] easily test mods building for kselftests Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> --- tools/testing/selftests/livepatch/Makefile | 8 ++------ tools/testing/selftests/livepatch/test-true.sh | 3 +++ .../selftests/livepatch/test_modules/Makefile | 11 +++++++++++ .../selftests/livepatch/test_modules/mod_test.c | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/livepatch/test-true.sh create mode 100644 tools/testing/selftests/livepatch/test_modules/Makefile create mode 100644 tools/testing/selftests/livepatch/test_modules/mod_test.c diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile index 02fadc9d55e0..bfe048f6a65d 100644 --- a/tools/testing/selftests/livepatch/Makefile +++ b/tools/testing/selftests/livepatch/Makefile @@ -1,13 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 +TEST_GEN_MODS_DIR := test_modules TEST_PROGS_EXTENDED := functions.sh TEST_PROGS := \ - test-livepatch.sh \ - test-callbacks.sh \ - test-shadow-vars.sh \ - test-state.sh \ - test-ftrace.sh \ - test-sysfs.sh + test-true.sh TEST_FILES := settings diff --git a/tools/testing/selftests/livepatch/test-true.sh b/tools/testing/selftests/livepatch/test-true.sh new file mode 100755 index 000000000000..8c3cbfc39d94 --- /dev/null +++ b/tools/testing/selftests/livepatch/test-true.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exit 0 diff --git a/tools/testing/selftests/livepatch/test_modules/Makefile b/tools/testing/selftests/livepatch/test_modules/Makefile new file mode 100644 index 000000000000..2975fe21f48c --- /dev/null +++ b/tools/testing/selftests/livepatch/test_modules/Makefile @@ -0,0 +1,11 @@ +LP_TESTMODS_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +#KDIR ?= /lib/modules/$(shell uname -r)/build +KDIR ?= $(abspath $(LP_TESTMODS_DIR)/../../../../..) + +obj-m += mod_test.o + +all: + make -C $(KDIR) M=$(LP_TESTMODS_DIR) modules + +clean: + make -C $(KDIR) M=$(LP_TESTMODS_DIR) clean diff --git a/tools/testing/selftests/livepatch/test_modules/mod_test.c b/tools/testing/selftests/livepatch/test_modules/mod_test.c new file mode 100644 index 000000000000..135f5d0b55b0 --- /dev/null +++ b/tools/testing/selftests/livepatch/test_modules/mod_test.c @@ -0,0 +1,15 @@ +#include <linux/module.h> +#include <linux/kernel.h> + +static int mod_init(void) +{ + return 0; +} + +static void mod_exit(void) +{ +} + +module_init(mod_init); +module_exit(mod_exit); +MODULE_LICENSE("GPL"); -- 2.40.0