* [PATCH] kbuild: rust: disable function merging unconditionally
@ 2026-11-18 13:09 Alice Ryhl
2026-11-18 13:15 ` Gary Guo
0 siblings, 1 reply; 2+ messages in thread
From: Alice Ryhl @ 2026-11-18 13:09 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Nick Desaulniers,
Bill Wendling, Justin Stitt, Matthew Maurer, Sami Tolvanen,
Masahiro Yamada
Cc: linux-kbuild, linux-kernel, rust-for-linux, llvm, Alice Ryhl
Function merging causes various different issues:
* For CONFIG_CFI there's an LLVM bug causing functions with different
CFI hashes to get merged. This can lead to crashes at runtime.
* For gendwarfksyms it causes functions with different CRCs to get
merged. This leads to broken MODVERSIONS information if the function
changes in the future so that it can no longer be merged.
* Wrong backtraces when a crash occurs in a merged function.
* Possibly also issues with pahole/BTF as the merged function's debug
info is lost.
These issues are new to Rust because in clang, function merging is off
by default, so these things have never come up before. Because of this,
turn this option off for all configurations.
Link: https://lore.kernel.org/all/avy_9SPRaPSKD8b4@google.com/
Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 5aac6f1b011e..17b7ac3afbc4 100644
--- a/Makefile
+++ b/Makefile
@@ -622,6 +622,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags) \
-Csymbol-mangling-version=v0 \
-Crelocation-model=static \
-Zfunction-sections=n \
+ -Zmerge-functions=disabled \
-Wclippy::float_arithmetic
KBUILD_RUSTFLAGS_OPTION_CHKS :=
@@ -1136,8 +1137,7 @@ endif
ifdef CONFIG_RUST
# Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
# CONFIG_CFI_ICALL_NORMALIZE_INTEGERS.
- # Disable function merging as LLVM incorrectly merges functions with different KCFI types.
- RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled
+ RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI)
export RUSTC_FLAGS_CFI
endif
---
base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
change-id: 20261117-rust-merge-functions-9ccbc0516df5
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] kbuild: rust: disable function merging unconditionally
2026-11-18 13:09 [PATCH] kbuild: rust: disable function merging unconditionally Alice Ryhl
@ 2026-11-18 13:15 ` Gary Guo
0 siblings, 0 replies; 2+ messages in thread
From: Gary Guo @ 2026-11-18 13:15 UTC (permalink / raw)
To: Alice Ryhl, Nathan Chancellor, Nicolas Schier, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Nick Desaulniers, Bill Wendling, Justin Stitt, Matthew Maurer,
Sami Tolvanen, Masahiro Yamada
Cc: linux-kbuild, linux-kernel, rust-for-linux, llvm
On Wed Nov 18, 2026 at 1:09 PM GMT, Alice Ryhl wrote:
> Function merging causes various different issues:
>
> * For CONFIG_CFI there's an LLVM bug causing functions with different
> CFI hashes to get merged. This can lead to crashes at runtime.
> * For gendwarfksyms it causes functions with different CRCs to get
> merged. This leads to broken MODVERSIONS information if the function
> changes in the future so that it can no longer be merged.
> * Wrong backtraces when a crash occurs in a merged function.
> * Possibly also issues with pahole/BTF as the merged function's debug
> info is lost.
>
> These issues are new to Rust because in clang, function merging is off
> by default, so these things have never come up before. Because of this,
> turn this option off for all configurations.
>
> Link: https://lore.kernel.org/all/avy_9SPRaPSKD8b4@google.com/
> Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 13:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 13:09 [PATCH] kbuild: rust: disable function merging unconditionally Alice Ryhl
2026-11-18 13:15 ` Gary Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®