mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests: lib.mk: define LINK.c, COMPILE.S and LINK.S when make has none
@ 2026-10-11 22:33 Sasha Levin
  2026-11-02  1:33 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2026-10-11 22:33 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Sasha Levin, linux-kselftest, linux-kernel

The kernel build runs make with -rR, which removes make's built-in rules
and variables. tools/testing/selftests/Makefile copes by clearing
MAKEFLAGS for its sub-makes, and lib.mk defines LINK.c, COMPILE.S and
LINK.S again, but only when building_out_of_srctree is set. A selftest
directory built directly by a make that inherited -R gets neither, so
LINK.c is empty and the generic rule tries to execute the source file:

  make[4]: acct_syscall.c: No such file or directory

Define them whenever make does not provide them, as make itself defines
them, so that they are the same with and without -R. The definitions
lib.mk used for O= builds until now differed from make's only in using
TARGET_ARCH instead of TARGET_MACH for assembly, which no selftest sets.

Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/lib.mk | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index f02cc8a2e4ae3..4de034f3e9d34 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -207,14 +207,11 @@ CFLAGS += -I${top_srcdir}/tools/testing/selftests
 CFLAGS += $(USERCFLAGS)
 LDFLAGS += $(USERLDFLAGS)
 
-# When make O= with kselftest target from main level
-# the following aren't defined.
-#
-ifdef building_out_of_srctree
-LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
-COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
-LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
-endif
+# Make's built-in variables are not defined when run with -R, which kbuild
+# passes down when a test is built from the main level.
+LINK.c ?= $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
+COMPILE.S ?= $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
+LINK.S ?= $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)
 
 # Selftest makefiles can override those targets by setting
 # OVERRIDE_TARGETS = 1.
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests: lib.mk: define LINK.c, COMPILE.S and LINK.S when make has none
  2026-10-11 22:33 [PATCH] selftests: lib.mk: define LINK.c, COMPILE.S and LINK.S when make has none Sasha Levin
@ 2026-11-02  1:33 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-02  1:33 UTC (permalink / raw)
  To: Shuah Khan; +Cc: Sasha Levin, linux-kselftest, linux-kernel

On Sun, Oct 11, 2026 at 06:33:34PM -0400, Sasha Levin wrote:
>The kernel build runs make with -rR, which removes make's built-in rules
>and variables. tools/testing/selftests/Makefile copes by clearing
>MAKEFLAGS for its sub-makes, and lib.mk defines LINK.c, COMPILE.S and
>LINK.S again, but only when building_out_of_srctree is set. A selftest
>directory built directly by a make that inherited -R gets neither, so
>LINK.c is empty and the generic rule tries to execute the source file:
>
>  make[4]: acct_syscall.c: No such file or directory

Hi Shuah,

Ping on this one. It still applies to v7.4-rc1.

The tools_build series [1] depends on it: without it, 70 of the 74
selftests the series builds fail this way. Could you pick it up for
7.5, or ack it so it can go through kbuild with the next version of the
series?

[1] https://lore.kernel.org/r/20261016143143.3613501-1-sashal@kernel.org

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-02  1:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 22:33 [PATCH] selftests: lib.mk: define LINK.c, COMPILE.S and LINK.S when make has none Sasha Levin
2026-11-02  1:33 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®