mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Shuah Khan <shuah@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] selftests: lib.mk: define LINK.c, COMPILE.S and LINK.S when make has none
Date: Sun, 11 Oct 2026 18:33:34 -0400	[thread overview]
Message-ID: <20261011223358.2327625-6-sashal@kernel.org> (raw)

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


                 reply	other threads:[~2026-10-11 22:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261011223358.2327625-6-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®