summaryrefslogtreecommitdiff
path: root/Documentation/controllers/git@git.tavy.me:linux.git
diff options
context:
space:
mode:
authorYonghong Song <yonghong.song@linux.dev>2026-03-06 21:02:50 -0800
committerNicolas Schier <nsc@kernel.org>2026-03-16 13:36:02 +0100
commitdc3b90751d6ffa8865e09a81645a539b9de6d642 (patch)
tree206a013f518356e039e24f6913e090e89560e096 /Documentation/controllers/git@git.tavy.me:linux.git
parent0d3fccf68d9873a3c824fb70be0dbb2c4642aa90 (diff)
kbuild: Reduce the number of compiler-generated suffixes for clang thin-lto build
The current clang thin-lto build often produces lots of symbols with suffix. The following is a partial list of such function call symbols: ... ethnl_module_fw_flash_ntf.llvm.7631589765585346066 __nf_conntrack_alloc.llvm.6438426151906658917 tcp_can_early_drop.llvm.11937612064648250727 tcp_print_conntrack.llvm.11937612064648250727 ... In my particular build with current bpf-next, the number of '*.llvm.<hash>' function calls is 1212. As the side effect of cross-file inlining, some static variables may be promoted with '*.llvm.<hash>' as well. In my same setup, the number of variables with such suffixes is 9. Such symbols make kernel live patching difficult since - a minor code change will change the hash and then the '*.llvm.<hash>' symbol becomes another one with a different hash. Sometimes, maybe the suffix is gone. - a previous source-level symbol may become a one with suffix after live patching code. In [1], Song Liu suggested to reduce the number of '*.llvm.<hash>' functions to make live patch easier. In respond of this, I implemented this in llvm ([2]). The same thin-lto build with [2] only has two symbols with suffix: m_stop.llvm.14460341347352036579 m_next.llvm.14460341347352036579 This should make live patch much easier. To support suffix symbol reduction, two lld flags are necessary to enable this feature in kernel: - Flag '--lto-whole-program-visibility' is needed as it ensures that all non-assembly files are available in the same thin-lto lld, which is true for kernel. - Flag '-mllvm -always-rename-promoted-locals=false' is needed to enable suffix reduction. Currently in llvm [1], only process mode is supported. There is another distributed mode (across different processes or even different machines) which is not supported yet ([2]). The kernel uses process mode so it should work. The assembly files may have some global functions/data which may potentially conflict with thin-lto global symbols after the above two flags. But such assembly global symbols are limited and tend to be uniquely named for its context. Hence the conflict with globals in non-assembly codes is rare. If indeed the conflict happens, we can rename either of them to avoid conflicts. Nathan Chancellor suggested the following under thin-lto: KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm -always-rename-promoted-locals=false) The '-mllvm -always-rename-promoted-locals=false' flag is only available for llvm23. So for llvm22 or earlier, the above KBUILD_LDFLAGS will ignore those two flags. For llvm23 and later, two flags will be added to KBUILD_LDFLAGS. [1] https://lpc.events/event/19/contributions/2212 [2] https://github.com/llvm/llvm-project/pull/178587 Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: Song Liu <song@kernel.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> # build Link: https://patch.msgid.link/20260307050250.3767489-1-yonghong.song@linux.dev Signed-off-by: Nicolas Schier <nsc@kernel.org>
Diffstat (limited to 'Documentation/controllers/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions