Skip to contentSkip to conversation

selftests: net: Fix O=dir builds

PATCH Applied Björn Töpel 2 participants 2 messages Dec 6, 2022 – Dec 9, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: net: Fix O=dir builds

From: Björn Töpel <[email protected]>

The BPF Makefile in net/bpf did incorrect path substitution for O=dir builds, e.g.

make O=/tmp/kselftest headers
make O=/tmp/kselftest -C tools/testing/selftests

would fail in selftest builds [1] net/ with

clang-16: error: no such file or directory: 'kselftest/net/bpf/nat6to4.c'
clang-16: error: no input files

Add a pattern prerequisite and an order-only-prerequisite (for creating the directory), to resolve the issue.

[1] https://lore.kernel.org/all/[email protected]/

Fixes 837a3d66d698 ("selftests: net: Add cross-compilation support for BPF programs")
---
 tools/testing/selftests/net/bpf/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/bpf/Makefile +3 -3
index a26cb94354f6..4abaf16d2077 100644
@@ -12,7 +12,7 @@ CCINCLUDE += -I$(SCRATCH_DIR)/include
 
 BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
 
-MAKE_DIRS := $(BUILD_DIR)/libbpf
+MAKE_DIRS := $(BUILD_DIR)/libbpf $(OUTPUT)/bpf
 $(MAKE_DIRS):
 	mkdir -p $@
 
@@ -37,8 +37,8 @@ endif
 
 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
 
-$(TEST_CUSTOM_PROGS): $(BPFOBJ)
-	$(CLANG) -O2 -target bpf -c $(@:.o=.c) $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%.o: %.c $(BPFOBJ) | $(MAKE_DIRS)
+	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
 
 $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)		       \
 	   $(APIDIR)/linux/bpf.h					       \

base-commit: c9f8d73645b6f76c8d14f49bc860f7143d001cb7

Signature · 1 line
2.37.2
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 6 Dec 2022 11:28:38 +0100 you wrote:

From: Björn Töpel <[email protected]>

The BPF Makefile in net/bpf did incorrect path substitution for O=dir builds, e.g.

make O=/tmp/kselftest headers
make O=/tmp/kselftest -C tools/testing/selftests

[...]

Here is the summary with links:
- [net-next] selftests: net: Fix O=dir builds

    https://git.kernel.org/netdev/net-next/c/17961a37ce40

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html