On 3/6/26 2:45 PM, Nathan Chancellor wrote:
On Fri, Mar 06, 2026 at 02:12:44PM -0800, Yonghong Song wrote:
So you mean we do not need a new config. Should just check clang and
clang versionn like below?
diff --git a/Makefile b/Makefile
index e944c6e71e81..9bd3990024c5 100644
--- a/Makefile
+++ b/Makefile
@@ -1034,6 +1034,11 @@ endif
ifdef CONFIG_LTO_CLANG
ifdef CONFIG_LTO_CLANG_THIN
CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
+ifdef CONFIG_CC_IS_CLANG
+ifeq ($(shell test $(CONFIG_CLANG_VERSION) -ge 230000; echo $$?),0)
This is the same as
ifeq ($(call clang-min-version,230000),y)
That being said, could we not just do a dynamic check so that it always
works when these flags are supported?
Thanks for the suggestion! What you had below with 'call ld-option' is perfect
to satisfy this requirement: <= llvm22, two flags will be ignored, and
= llvm23, two flags will be used.
v2:
https://lore.kernel.org/linux-kbuild/[email protected]/
+KBUILD_LDFLAGS += --lto-whole-program-visibility -mllvm
-always-rename-promoted-locals=false
KBUILD_LDFLAGS += $(call ld-option,--lto-whole-program-visibility -mllvm
-always-rename-promoted-locals=false)
+endif
+endif
else
CC_FLAGS_LTO := -flto
endif
I think this should work. In rare case, renaming the function should
solve the problem.
I agree with Josh that having this be the default behavior with the
workarounds that we have available to us to avoid problems from it is
worth it. Thanks for chasing this after the discussions at LPC.
Cheers,
Nathan