On Thu, Sep 17, 2026 at 05:06:15PM +0100, Lorenzo Stoakes (ARM) wrote: > A kernel build consists of more than one linking pass on vmlinux.o and > vmlinux, at minimum two, and with CONFIG_KALLSYMS and BTF enabled on x86-64 > for example there are 5 such stages. > > For architectures that build their own relocation tables (x86, riscv, mips, > s390), vmlinux is linked with the --emit-relocs parameter specified. > > However, this is only required on the final vmlinux link. > > Symbol tables of trial links preceding it don't need it because they > already check that System.map matches kallsyms symbols on each build. > > GNU ld is slow at emitting relocation tables, so this results in a > reduction in build time. > > Whole build, 128-thread Threadripper 9980X, best of N runs: > > before after delta > ------------------------------- > x86 defconfig, touch mm/vma.c, gcc 9.5s 9.1s -0.42s (-4%) > x86 defconfig, clean, gcc 30.1s 29.5s -0.59s (-2%) > x86 allmodconfig, touch mm/vma.c, gcc 37.2s 35.8s -1.4s (-4%) > > Note that this has little impact on LLVM ld which performs this operation > more efficiently. > > Assisted-by: LLM > Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]> > --- > Makefile | 2 +- > scripts/link-vmlinux.sh | 5 +++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > }
Reviewed-by: Nicolas Schier <[email protected]> -- Nicolas

