diff options
author | Andi Kleen <andi@firstfloor.org> | 2020-07-08 07:19:06 -0700 |
---|---|---|
committer | Andi Kleen <andi@firstfloor.org> | 2021-03-28 22:13:10 -0700 |
commit | a1b337cb772b1ba21fda6e4413eb2ebe7e374209 (patch) | |
tree | 7ab3f8d4e5af1457237684b5a71b974dd5bfa74b | |
parent | 36d1f50c008e659c27e6fe011217662a362aa002 (diff) | |
download | linux-misc-lto-5.11-2.tar.gz |
Kbuild, link-vmlinux: Reuse vmlinux.o for final linklto-5.11-2
Even without kallsyms, link-vmlinux links the kernel twice: once
to generate a vmlinux.o for modpost and objtool, and another
time for the final executable.
This patch reuses the vmlinux.o to create the final executable
to avoid some redundant linking work.
Of course this particularly helps with Link Time Optimization, where
it prevents a double optimization of the whole kernel, but it's
midly beneficial on a standard build too.
This is a config option for now, but probably should be unconditional
at some point once all the architectures have been tested.
um support would need some extra work.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r-- | init/Kconfig | 10 | ||||
-rwxr-xr-x | scripts/link-vmlinux.sh | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig index ff2cd3be2010ec..d280b2e9834182 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1430,6 +1430,16 @@ config LTO_CP_CLONE arguments when it determines these arguments are very commonly called. Experimential. Will increase text size. +config SINGLE_LINK + bool + default y + depends on KALLSYMS_SINGLE + # for now. In theory should work everywhere except for um + depends on X86 + help + Use only a single linking step for the final vmlinux, making + the build faster. + config SYSCTL bool diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 7e3905c6e7d171..5297051dde4181 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -403,14 +403,28 @@ elif [ -n "${CONFIG_KALLSYMS}" ]; then fi fi +if [ -z "${CONFIG_SINGLE_LINK}" ] ; then + info LDFINAL vmlinux vmlinux_link vmlinux "${kallsymso} ${kallsymsorel}" ${btf_vmlinux_bin_o} +else + +# Reuse the partial linking from the modpost vmlinux.o earlier + +info LD vmlinux +${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ + -o vmlinux \ + -T ${objtree}/${KBUILD_LDS} \ + vmlinux.o ${kallsymso} ${kallsymsorel} ${btf_vmlinux_bin_o} +fi + # fill in BTF IDs if [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then info BTFIDS vmlinux ${RESOLVE_BTFIDS} vmlinux fi + if [ -n "${CONFIG_KALLSYMS}" -a -n "${CONFIG_KALLSYMS_SINGLE}" ] ; then # Now regenerate the kallsyms table and patch it into the # previously linked file. We tell kallsyms to pad it |