Move the build rule for vmlinux.a to a separate file in preparation for supporting distributed builds with Clang ThinLTO.
Showing the changes to scripts (1 of 2 files). Show all
Unified · Split
| @@ -0,0 +1,46 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 2 | |||
| 3 | PHONY := __default | ||
| 4 | __default: vmlinux.a | ||
| 5 | |||
| 6 | include include/config/auto.conf | ||
| 7 | include $(srctree)/scripts/Kbuild.include | ||
| 8 | include $(srctree)/scripts/Makefile.lib | ||
| 9 | |||
| 10 | # Link of built-in-fixup.a | ||
| 11 | # --------------------------------------------------------------------------- | ||
| 12 | |||
| 13 | # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14 | ||
| 14 | quiet_cmd_ar_builtin_fixup = AR $@ | ||
| 15 | cmd_ar_builtin_fixup = \ | ||
| 16 | rm -f $@; \ | ||
| 17 | $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \ | ||
| 18 | $(AR) mPiT $$($(AR) t $@ | sed -n 1p) $@ $$($(AR) t $@ | grep -F -f $(srctree)/scripts/head-object-list.txt) | ||
| 19 | |||
| 20 | targets += built-in-fixup.a | ||
| 21 | built-in-fixup.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE | ||
| 22 | $(call if_changed,ar_builtin_fixup) | ||
| 23 | |||
| 24 | # vmlinux.a | ||
| 25 | # --------------------------------------------------------------------------- | ||
| 26 | |||
| 27 | targets += vmlinux.a | ||
| 28 | vmlinux.a: built-in-fixup.a FORCE | ||
| 29 | $(call if_changed,copy) | ||
| 30 | |||
| 31 | # Add FORCE to the prerequisites of a target to force it to be always rebuilt. | ||
| 32 | # --------------------------------------------------------------------------- | ||
| 33 | |||
| 34 | PHONY += FORCE | ||
| 35 | FORCE: | ||
| 36 | |||
| 37 | # Read all saved command lines and dependencies for the $(targets) we | ||
| 38 | # may be building above, using $(if_changed{,_dep}). As an | ||
| 39 | # optimization, we don't need to read them if the target does not | ||
| 40 | # exist, we will rebuild anyway in that case. | ||
| 41 | |||
| 42 | existing-targets := $(wildcard $(sort $(targets))) | ||
| 43 | |||
| 44 | -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) | ||
| 45 | |||
| 46 | .PHONY: $(PHONY) | ||