Rust for Linux List
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Miguel Ojeda" <ojeda@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Matthew Maurer" <mmaurer@google.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>
Cc: linux-kbuild@vger.kernel.org,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	rust-for-linux@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] kbuild: rust: keep Rust objects out of Clang LTO with inline helpers
Date: Sun, 16 Aug 2026 15:05:05 +0100	[thread overview]
Message-ID: <DKQFBMI8BAWN.JB20KE3YNAFA@garyguo.net> (raw)
In-Reply-To: <20260816133233.197500-2-ojeda@kernel.org>

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 <gary@garyguo.net>
> Cc: Boqun Feng <boqun@kernel.org>
> Cc: Alice Ryhl <aliceryhl@google.com>
> Cc: Matthew Maurer <mmaurer@google.com>
> Cc: stable@vger.kernel.org
> Cc: Josh Poimboeuf <jpoimboe@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Fixes: 3a2486cc1da5 ("kbuild: rust: provide an option to inline C helpers into Rust")
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Acked-by: Gary Guo <gary@garyguo.net>

> ---
>  rust/Makefile          | 2 +-
>  scripts/Makefile.build | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)


  reply	other threads:[~2026-08-16 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 13:32 [PATCH 1/2] kbuild: rust: preserve unreachable traps with inline helpers Miguel Ojeda
2026-08-16 13:32 ` [PATCH 2/2] kbuild: rust: keep Rust objects out of Clang LTO " Miguel Ojeda
2026-08-16 14:05   ` Gary Guo [this message]
2026-08-16 14:04 ` [PATCH 1/2] kbuild: rust: preserve unreachable traps " Gary Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DKQFBMI8BAWN.JB20KE3YNAFA@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mmaurer@google.com \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox