History

selftests/bpf: Support out-of-tree vmlinux builds for VMLINUX_BTF

Add detection of out-of-tree built vmlinux image for the purpose of VMLINUX_BTF detection. According to Documentation/kbuild/kbuild.rst, O takes precedence over KBUILD_OUTPUT. Also ensure ~/path/to/build/dir also works by relying on wildcard's resolution first, but then applying $(abspath) at the end to also handle O=../../whatever cases.

Andrii Nakryiko committed 6 years ago

Commit cc6fa771 parent af73d781 file · +7 −4Browse files

Unified · Split

tools/testing/selftests/bpf/Makefile+7−4
@@ -129,10 +129,13 @@ $(OUTPUT)/test_stub.o: test_stub.c $(BPFOBJ) · 128 unmodified lines
129 $(call msg,CC,,$@)129 $(call msg,CC,,$@)
130 $(CC) -c $(CFLAGS) -o $@ $<130 $(CC) -c $(CFLAGS) -o $@ $<
131 131
132VMLINUX_BTF_PATHS := $(abspath ../../../../vmlinux) \132VMLINUX_BTF_PATHS := $(if $(O),$(O)/vmlinux) \
133 /sys/kernel/btf/vmlinux \133 $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
134 /boot/vmlinux-$(shell uname -r)134 ../../../../vmlinux \
135VMLINUX_BTF:= $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))135 /sys/kernel/btf/vmlinux \
136 /boot/vmlinux-$(shell uname -r)
137VMLINUX_BTF:= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
138
136$(OUTPUT)/runqslower: $(BPFOBJ)139$(OUTPUT)/runqslower: $(BPFOBJ)
137 $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \140 $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \
138 OUTPUT=$(SCRATCH_DIR)/ VMLINUX_BTF=$(VMLINUX_BTF) \141 OUTPUT=$(SCRATCH_DIR)/ VMLINUX_BTF=$(VMLINUX_BTF) \