03 Sep, 2021

1 commit

  • With CONFIG_LTO_CLANG, we currently link modules into native
    code just before modpost, which means with TRIM_UNUSED_KSYMS
    enabled, we still look at the LLVM bitcode in the .o files when
    generating the list of used symbols. As the bitcode doesn't
    yet have calls to compiler intrinsics and llvm-nm doesn't see
    function references that only exist in function-level inline
    assembly, we currently need a whitelist for TRIM_UNUSED_KSYMS to
    work with LTO.

    This change moves module LTO linking to happen earlier, and
    thus avoids the issue with LLVM bitcode and TRIM_UNUSED_KSYMS
    entirely, allowing us to also drop the whitelist from
    gen_autoksyms.sh.

    Link: https://github.com/ClangBuiltLinux/linux/issues/1369
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Alexander Lobakin
    Tested-by: Alexander Lobakin
    Signed-off-by: Masahiro Yamada

    Sami Tolvanen
     

28 Feb, 2021

1 commit

  • Commit fbe078d397b4 ("kbuild: lto: add a default list of used symbols")
    does not work as expected if the .config file has already specified
    CONFIG_UNUSED_KSYMS_WHITELIST="my/own/white/list" before enabling
    CONFIG_LTO_CLANG.

    So, the user-supplied whitelist and LTO-specific white list must be
    independent of each other.

    I refactored the shell script so CONFIG_MODVERSIONS and CONFIG_CLANG_LTO
    handle whitelists in the same way.

    Fixes: fbe078d397b4 ("kbuild: lto: add a default list of used symbols")
    Signed-off-by: Masahiro Yamada
    Tested-by: Sedat Dilek

    Masahiro Yamada
     

12 Feb, 2021

1 commit

  • Stephen Rothwell reported a build error on ppc64 when
    CONFIG_TRIM_UNUSED_KSYMS is enabled.

    Jessica Yu pointed out the cause of the error with the reference to the
    ppc64 ELF ABI:
    "Symbol names with a dot (.) prefix are reserved for holding entry
    point addresses. The value of a symbol named ".FN", if it exists,
    is the entry point of the function "FN".

    As it turned out, CONFIG_TRIM_UNUSED_KSYMS has never worked for ppc64,
    but this issue has been unnoticed until recently because this option
    depends on !UNUSED_SYMBOLS hence is disabled by all{mod,yes}config.
    (Then, it was uncovered by another patch removing UNUSED_SYMBOLS.)

    Removing the dot prefix in scripts/gen_autoksyms.sh fixes the issue.
    Please note it must be done before 'sort -u' because modules have
    both ._mcount and _mcount undefined when CONFIG_FUNCTION_TRACER=y.

    Link: https://lore.kernel.org/lkml/20210209210843.3af66662@canb.auug.org.au/
    Reported-by: Stephen Rothwell
    Signed-off-by: Masahiro Yamada
    Tested-by: Jessica Yu

    Masahiro Yamada
     

03 Mar, 2020

2 commits

  • When doing a cold build, autoksyms.h starts empty, and is updated late
    in the build process to have visibility over the symbols used by in-tree
    drivers. But since the symbol whitelist is known upfront, it can be used
    to pre-populate autoksyms.h and maximize the amount of code that can be
    compiled to its final state in a single pass, hence reducing build time.

    Do this by using gen_autoksyms.sh to initialize autoksyms.h instead of
    creating an empty file.

    Acked-by: Nicolas Pitre
    Tested-by: Matthias Maennich
    Reviewed-by: Matthias Maennich
    Signed-off-by: Quentin Perret
    Signed-off-by: Masahiro Yamada

    Quentin Perret
     
  • In order to prepare the ground for a build-time optimization, split
    adjust_autoksyms.sh into two scripts: one that generates autoksyms.h
    based on all currently available information (whitelist, and .mod
    files), and the other to inspect the diff between two versions of
    autoksyms.h and trigger appropriate rebuilds.

    Acked-by: Nicolas Pitre
    Tested-by: Matthias Maennich
    Reviewed-by: Matthias Maennich
    Signed-off-by: Quentin Perret
    Signed-off-by: Masahiro Yamada

    Quentin Perret