diff mbox series

[net-next] selftests: net: Fix O=dir builds

Message ID 20221206102838.272584-1-bjorn@kernel.org (mailing list archive)
State Accepted
Commit 17961a37ce4077ae43128ba5ce0b1dfd8f02fdb9
Delegated to: Netdev Maintainers
Headers show
Series [net-next] selftests: net: Fix O=dir builds | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 9 maintainers not CCed: bpf@vger.kernel.org trix@redhat.com llvm@lists.linux.dev linux-mediatek@lists.infradead.org matthias.bgg@gmail.com nathan@kernel.org ndesaulniers@google.com shuah@kernel.org linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Björn Töpel Dec. 6, 2022, 10:28 a.m. UTC
From: Björn Töpel <bjorn@rivosinc.com>

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/202212060009.34CkQmCN-lkp@intel.com/

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 837a3d66d698 ("selftests: net: Add cross-compilation support for BPF programs")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
 tools/testing/selftests/net/bpf/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


base-commit: c9f8d73645b6f76c8d14f49bc860f7143d001cb7

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 9, 2022, 3:30 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  6 Dec 2022 11:28:38 +0100 you wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> 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!
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/bpf/Makefile b/tools/testing/selftests/net/bpf/Makefile
index a26cb94354f6..4abaf16d2077 100644
--- a/tools/testing/selftests/net/bpf/Makefile
+++ b/tools/testing/selftests/net/bpf/Makefile
@@ -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					       \