Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: Fix O=dir builds

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>
Link: https://lore.kernel.org/r/20221206102838.272584-1-bjorn@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Björn Töpel and committed by
Jakub Kicinski
17961a37 ce87a957

+3 -3
+3 -3
tools/testing/selftests/net/bpf/Makefile
··· 12 12 13 13 BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a 14 14 15 - MAKE_DIRS := $(BUILD_DIR)/libbpf 15 + MAKE_DIRS := $(BUILD_DIR)/libbpf $(OUTPUT)/bpf 16 16 $(MAKE_DIRS): 17 17 mkdir -p $@ 18 18 ··· 37 37 38 38 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) 39 39 40 - $(TEST_CUSTOM_PROGS): $(BPFOBJ) 41 - $(CLANG) -O2 -target bpf -c $(@:.o=.c) $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ 40 + $(TEST_CUSTOM_PROGS): $(OUTPUT)/%.o: %.c $(BPFOBJ) | $(MAKE_DIRS) 41 + $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@ 42 42 43 43 $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ 44 44 $(APIDIR)/linux/bpf.h \