All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>
Cc: "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>,
	"Peter Zijlstra" <peterz@infradead.org>,
	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 1/2] kbuild: rust: preserve unreachable traps with inline helpers
Date: Tue, 18 Aug 2026 11:54:15 +0100	[thread overview]
Message-ID: <DKS0ILSW36D1.20JOSTOVBQZP2@garyguo.net> (raw)
In-Reply-To: <aoPOqlGAlLOJ3wgx@jpoimboe>

On Tue Aug 18, 2026 at 4:18 AM BST, Josh Poimboeuf wrote:
> On Sun, Aug 16, 2026 at 03:32:32PM +0200, 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.
>
> FWIW, I've been working on some patches that should hopefully let us get
> rid of all the objtool hard-coded noreturn lists altogether.  I'll try to post
> those soon.

That'll be nice. I once prototyped a generator for such list by using dwarf
debug info, but obviously that cannot be part of objtool because objtool
operates independently from dwarf.

Looking forward to your approach and how you solve this. Please keep me (and the
rust-for-linux list) in cc when you do.

Thanks,
Gary

      reply	other threads:[~2026-08-18 10:54 UTC|newest]

Thread overview: 7+ 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
2026-08-17 18:12   ` Nathan Chancellor
2026-08-16 14:04 ` [PATCH 1/2] kbuild: rust: preserve unreachable traps " Gary Guo
2026-08-18  3:18 ` Josh Poimboeuf
2026-08-18 10:54   ` Gary Guo [this message]

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=DKS0ILSW36D1.20JOSTOVBQZP2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.