Skip to content

Commit 1cc8f51

Browse files
Darksonngregkh
authored andcommitted
rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
commit 191f49f upstream. Due to a rustc bug, the -Cforce-frame-pointers=y flag only emits the frame-pointer annotation for functions, but not for the module. This means that functions generated by the LLVM backend such as 'asan.module_ctor' do not receive the frame-pointer annotation. This is likely to lead to broken backtraces and may also cause issues with ftrace if these features are used with functions generated by the LLVM backend. Thus, use -Zllvm_module_flag to work around this rustc bug if using a rustc without the fix. [ The fix [1] has landed for Rust 1.98.0 (expected release on 2026-08-20). - Miguel ] Cc: stable@vger.kernel.org # 6.12.y and later (flag not available in pinned Rust in older LTSs). Fixes: 2f7ab12 ("Kbuild: add Rust support") Link: rust-lang/rust#156980 [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260616-frame-ptr-fix-v1-1-dc6b29a631d9@google.com [ - Adjusted Cc: stable@ as discussed. - Added comment with link to the PR, similar to what we did in commit ac35b55 ("rust: arm64: set uwtable llvm module flag for CONFIG_UNWIND_TABLES"). - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70fe1ac commit 1cc8f51

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ KBUILD_CFLAGS += $(stackp-flags-y)
905905
ifdef CONFIG_FRAME_POINTER
906906
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
907907
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
908+
# Work around rustc bug on compilers without
909+
# https://github.com/rust-lang/rust/pull/156980.
910+
KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:max)
908911
else
909912
# Some targets (ARM with Thumb2, for example), can't be built with frame
910913
# pointers. For those, we don't have FUNCTION_TRACER automatically

0 commit comments

Comments
 (0)