Re: [PATCH 3/3] kbuild: merge temp vmlinux for CONFIG_DEBUG_INFO_BTF and CONFIG_KALLSYMS
From: Andrii Nakryiko
Date: Thu May 30 2024 - 17:18:06 EST
On Wed, May 22, 2024 at 4:48 AM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
>
> CONFIG_DEBUG_INFO_BTF=y requires one additional link step.
> (.tmp_vmlinux.btf)
>
> CONFIG_KALLSYMS=y requires two additional link steps.
> (.tmp_vmlinux.kallsyms1 and .tmp_vmlinux.kallsyms2)
>
> Enabling both requires three additional link steps.
>
> When CONFIG_DEBUG_INFO_BTF=y and CONFIG_KALLSYMS=y, the build step looks
> as follows:
>
> KSYMS .tmp_vmlinux.kallsyms0.S
> AS .tmp_vmlinux.kallsyms0.o
> LD .tmp_vmlinux.btf # temp vmlinux for BTF
> BTF .btf.vmlinux.bin.o
> LD .tmp_vmlinux.kallsyms1 # temp vmlinux for kallsyms step 1
> NM .tmp_vmlinux.kallsyms1.syms
> KSYMS .tmp_vmlinux.kallsyms1.S
> AS .tmp_vmlinux.kallsyms1.o
> LD .tmp_vmlinux.kallsyms2 # temp vmlinux for kallsyms step 2
> NM .tmp_vmlinux.kallsyms2.syms
> KSYMS .tmp_vmlinux.kallsyms2.S
> AS .tmp_vmlinux.kallsyms2.o
> LD vmlinux # final vmlinux
>
> This is redundant because the BTF generation and the kallsyms step 1 can
> be performed against the same temporary vmlinux.
>
> When both CONFIG_DEBUG_INFO_BTF and CONFIG_KALLSYMS are enabled, we can
> reduce the number of link steps.
>
> The build step will look as follows:
>
> KSYMS .tmp_vmlinux0.kallsyms.S
> AS .tmp_vmlinux0.kallsyms.o
> LD .tmp_vmlinux1 # temp vmlinux for BTF and kallsyms step 1
> BTF .tmp_vmlinux1.btf.o
> NM .tmp_vmlinux1.syms
> KSYMS .tmp_vmlinux1.kallsyms.S
> AS .tmp_vmlinux1.kallsyms.o
> LD .tmp_vmlinux2 # temp vmlinux for kallsyms step 2
> NM .tmp_vmlinux2.syms
> KSYMS .tmp_vmlinux2.kallsyms.S
> AS .tmp_vmlinux2.kallsyms.o
> LD vmlinux # final link
>
> Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> ---
>
LGTM, thanks!
Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> scripts/link-vmlinux.sh | 45 +++++++++++++++++++++--------------------
> 1 file changed, 23 insertions(+), 22 deletions(-)
>
[...]