|
6 | 6 | PHONY := __modfinal |
7 | 7 | __modfinal: |
8 | 8 |
|
| 9 | +include include/config/auto.conf |
9 | 10 | include $(srctree)/scripts/Kbuild.include |
10 | 11 |
|
11 | 12 | # for c_flags |
@@ -36,8 +37,23 @@ quiet_cmd_ld_ko_o = LD [M] $@ |
36 | 37 | -T scripts/module.lds -o $@ $(filter %.o, $^); \ |
37 | 38 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) |
38 | 39 |
|
39 | | -$(modules): %.ko: %.o %.mod.o scripts/module.lds FORCE |
40 | | - +$(call if_changed,ld_ko_o) |
| 40 | +quiet_cmd_btf_ko = BTF [M] $@ |
| 41 | + cmd_btf_ko = LLVM_OBJCOPY=$(OBJCOPY) $(PAHOLE) -J --btf_base vmlinux $@ |
| 42 | + |
| 43 | +# Same as newer-prereqs, but allows to exclude specified extra dependencies |
| 44 | +newer_prereqs_except = $(filter-out $(PHONY) $(1),$?) |
| 45 | + |
| 46 | +# Same as if_changed, but allows to exclude specified extra dependencies |
| 47 | +if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \ |
| 48 | + $(cmd); \ |
| 49 | + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) |
| 50 | + |
| 51 | +# Re-generate module BTFs if either module's .ko or vmlinux changed |
| 52 | +$(modules): %.ko: %.o %.mod.o scripts/module.lds vmlinux FORCE |
| 53 | + +$(call if_changed_except,ld_ko_o,vmlinux) |
| 54 | +ifdef CONFIG_DEBUG_INFO_BTF_MODULES |
| 55 | + +$(if $(newer-prereqs),$(call cmd,btf_ko)) |
| 56 | +endif |
41 | 57 |
|
42 | 58 | targets += $(modules) $(modules:.ko=.mod.o) |
43 | 59 |
|
|
0 commit comments