mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-26 10:57:38 +08:00
A recent LLVM commit [1] renamed the internal LLVM plugin option
'-split-machine-functions' to '-function-splitting=all', breaking the
AutoFDO + ThinLTO build with:
ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument '-split-machine-functions'. Try: 'ld.lld --help'
The plugin option is needed for in-process ThinLTO, so handle the rename
accordingly using ld-option.
Cc: stable@vger.kernel.org
Closes: https://github.com/ClangBuiltLinux/linux/issues/2186
Fixes: 2fd65f7afd ("AutoFDO: Enable machine function split optimization for AutoFDO")
Link: https://github.com/llvm/llvm-project/commit/3e6acc87c58843e551d6e8e4bf06c26712b04622 [1]
Link: https://patch.msgid.link/20261014-update-autofdo-split-machine-function-option-v1-1-5c71b3005e89@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
29 lines
1.3 KiB
Makefile
29 lines
1.3 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Enable available and selected Clang AutoFDO features.
|
|
|
|
CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true
|
|
RUSTFLAGS_AUTOFDO_CLANG := $(if $(call rustc-min-version,109800),-Zdebuginfo-for-profiling,-Zdebug-info-for-profiling) -Cllvm-args=-enable-fs-discriminator=true -Cllvm-args=-improved-fs-discriminator=true
|
|
|
|
ifndef CONFIG_DEBUG_INFO
|
|
CFLAGS_AUTOFDO_CLANG += -gmlt
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Cdebuginfo=line-tables-only
|
|
endif
|
|
|
|
ifdef CLANG_AUTOFDO_PROFILE
|
|
CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections
|
|
CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Zprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -Zfunction-sections=y
|
|
RUSTFLAGS_AUTOFDO_CLANG += -Cllvm-args=-split-machine-functions
|
|
endif
|
|
|
|
ifdef CONFIG_LTO_CLANG_THIN
|
|
ifdef CLANG_AUTOFDO_PROFILE
|
|
KBUILD_LDFLAGS += --lto-sample-profile=$(CLANG_AUTOFDO_PROFILE)
|
|
endif
|
|
KBUILD_LDFLAGS += --mllvm=-enable-fs-discriminator=true --mllvm=-improved-fs-discriminator=true -plugin-opt=thinlto
|
|
KBUILD_LDFLAGS += $(call ld-option,-plugin-opt=-function-splitting=all,-plugin-opt=-split-machine-functions)
|
|
endif
|
|
|
|
export CFLAGS_AUTOFDO_CLANG RUSTFLAGS_AUTOFDO_CLANG
|