Re: [PATCH] kbuild: Remove debug info from kallsyms linking

From: Andrii Nakryiko
Date: Tue Mar 03 2020 - 01:55:20 EST


On Mon, Feb 24, 2020 at 9:17 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
>
> When CONFIG_DEBUG_INFO is enabled, the two kallsyms linking steps spend
> time collecting and writing the dwarf sections to the temporary output
> files. kallsyms does not need this information, and leaving it off
> halves their linking time. This is especially noticeable without
> CONFIG_DEBUG_INFO_REDUCED. The BTF linking stage, however, does still
> need those details.
>
> Refactor the BTF and kallsyms generation stages slightly for more
> regularized temporary names. Skip debug during kallsyms links.
>
> For a full debug info build with BTF, my link time goes from 1m06s to
> 0m54s, saving about 12 seconds, or 18%.
>
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---

I've tested locally, seems to be generating BTF properly (I haven't
timed anything, though). See nit below, but otherwise:

Acked-by: Andrii Nakryiko <andriin@xxxxxx>

> scripts/link-vmlinux.sh | 28 +++++++++++++++++++---------
> 1 file changed, 19 insertions(+), 9 deletions(-)
>

[...]

> @@ -106,6 +114,8 @@ gen_btf()
> {
> local pahole_ver
> local bin_arch
> + local bin_format
> + local bin_file
>
> if ! [ -x "$(command -v ${PAHOLE})" ]; then
> echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
> @@ -118,8 +128,9 @@ gen_btf()
> return 1
> fi
>
> - info "BTF" ${2}
> vmlinux_link ${1}
> +
> + info "BTF" ${2}

Any reason to exclude linking from "BTF" step? It's still a part of
BTF generation, so seems fair to have BTF encompass both vmlinux
linking and BTF generation/deduplication?

> LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
>
> # dump .BTF section into raw binary file to link with final vmlinux

[...]