Re: [PATCH 1/2] kbuild: rust: preserve unreachable traps with inline helpers
"Gary Guo" <[email protected]>
| Newsgroups | org.kernel.vger.linux-kbuild,org.kernel.vger.rust-for-linux,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On Sun Aug 16, 2026 at 2:32 PM BST, Miguel Ojeda wrote: > When `CONFIG_RUST_INLINE_HELPERS` is enabled, it is possible to hit > `objtool` warnings like: > > vmlinux.o: warning: objtool: _R..._4cmdq12CommandToGsp4init() > falls through to next function _R..._4core5array4iter8IntoIterRShKj3_EEEBa_() > > `rustc` normally emits traps for unreachable paths. However, under > `CONFIG_RUST_INLINE_HELPERS=y`, `rustc` emits LLVM bitcode and Clang > performs final code generation after the helper bitcode is linked, > but Clang does not trap unreachable IR by default. > > In turn, this means `objtool` follows compiler-generated impossible Rust > `enum` paths through alignment padding into the next function, resulting > in fallthrough warnings. > > Thus pass the LLVM `trap-unreachable` option to the final Clang invocation > and suppress traps immediately after `noreturn` calls, which `objtool` > already recognizes as dead ends. The combination of both flags makes it > match `rustc`'s behavior. > > Rust 1.85.0 (the minimum supported one) supports LLVM >= 18, and both > flags are available in LLVM 18. > > Assisted-by: LLM > Cc: Gary Guo <[email protected]> > Cc: Boqun Feng <[email protected]> > Cc: Alice Ryhl <[email protected]> > Cc: Matthew Maurer <[email protected]> > Cc: Josh Poimboeuf <[email protected]> > Cc: Peter Zijlstra <[email protected]> > Cc: [email protected] > Fixes: 3a2486cc1da5 ("kbuild: rust: provide an option to inline C helpers into Rust") > Signed-off-by: Miguel Ojeda <[email protected]> Acked-by: Gary Guo <[email protected]> > --- > Makefile | 10 ++++++++++ > rust/Makefile | 3 ++- > scripts/Makefile.build | 3 ++- > 3 files changed, 14 insertions(+), 2 deletions(-)