Re: [PATCH 2/2] kbuild: rust: keep Rust objects out of Clang LTO 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: > Under `CONFIG_LTO_CLANG` + `CONFIG_RUST_INLINE_HELPERS`, one may hit > `objtool` errors such as: > > vmlinux.o: error: objtool: _R..._3Gsp4boot+0xd6a: > can't find jump dest instruction at .text._R..._3Gsp4boot+0x1dfd > > The reason is that in such builds, the Clang invocation that compiles > the combined Rust plus helpers bitcode emits LLVM bitcode (again) -- > the final code generation happens in the linker's LTO step, which the > `-mllvm` trap options passed to Clang do not reach. > > This, in turn, means that unreachable traps are missing, and the > impossible paths do not merely fallthrough to the next symbol, but past > the end of their own section, since LTO builds place each function in > its own section. > > Thus filter `CC_FLAGS_LTO` out of the Clang invocation, so that it always > emits machine code directly, with the traps in place. > > Assisted-by: LLM > Cc: Gary Guo <[email protected]> > Cc: Boqun Feng <[email protected]> > Cc: Alice Ryhl <[email protected]> > Cc: Matthew Maurer <[email protected]> > Cc: [email protected] > Cc: Josh Poimboeuf <[email protected]> > Cc: Peter Zijlstra <[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]> > --- > rust/Makefile | 2 +- > scripts/Makefile.build | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-)