mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 09:13:38 +00:00
selftests/bpf: Do not update vmlinux.h unnecessarily
%.bpf.o objects depend on vmlinux.h, which makes them transitively dependent on unnecessary libbpf headers. However vmlinux.h doesn't actually change as often. When generating vmlinux.h, compare it to a previous version and update it only if there are changes. Example of build time improvement (after first clean build): $ touch ../../../lib/bpf/bpf.h $ time make -j8 Before: real 1m37.592s After: real 0m27.310s Notice that %.bpf.o gen step is skipped if vmlinux.h hasn't changed. Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/CAEf4BzY1z5cC7BKye8=A8aTVxpsCzD=p1jdTfKC7i0XVuYoHUQ@mail.gmail.com Link: https://lore.kernel.org/bpf/20240828174608.377204-2-ihor.solodrai@pm.me
This commit is contained in:
parent
38960ac8f9
commit
2ad6d23f46
@ -399,10 +399,14 @@ $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
|
|||||||
DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
|
DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# vmlinux.h is first dumped to a temprorary file and then compared to
|
||||||
|
# the previous version. This helps to avoid unnecessary re-builds of
|
||||||
|
# $(TRUNNER_BPF_OBJS)
|
||||||
$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
|
$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
|
||||||
ifeq ($(VMLINUX_H),)
|
ifeq ($(VMLINUX_H),)
|
||||||
$(call msg,GEN,,$@)
|
$(call msg,GEN,,$@)
|
||||||
$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
|
$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $(INCLUDE_DIR)/.vmlinux.h.tmp
|
||||||
|
$(Q)cmp -s $(INCLUDE_DIR)/.vmlinux.h.tmp $@ || mv $(INCLUDE_DIR)/.vmlinux.h.tmp $@
|
||||||
else
|
else
|
||||||
$(call msg,CP,,$@)
|
$(call msg,CP,,$@)
|
||||||
$(Q)cp "$(VMLINUX_H)" $@
|
$(Q)cp "$(VMLINUX_H)" $@
|
||||||
|
Loading…
Reference in New Issue
Block a user