History

kbuild: move vmlinux.a build rule to scripts/Makefile.vmlinux_a

Move the build rule for vmlinux.a to a separate file in preparation for supporting distributed builds with Clang ThinLTO.

Masahiro Yamada committed 5 months ago

Commit 9c72d261 parent d7231d82 files · +52 −10Browse files

Showing the changes to scripts (1 of 2 files). Show all

Unified · Split

scripts/Makefile.vmlinux_a+46−0
@@ -0,0 +1,46 @@
1# SPDX-License-Identifier: GPL-2.0-only
2
3PHONY := __default
4__default: vmlinux.a
5
6include include/config/auto.conf
7include $(srctree)/scripts/Kbuild.include
8include $(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
14quiet_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
20targets += built-in-fixup.a
21built-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
27targets += vmlinux.a
28vmlinux.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
34PHONY += FORCE
35FORCE:
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
42existing-targets := $(wildcard $(sort $(targets)))
43
44-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
45
46.PHONY: $(PHONY)