From: Miguel Ojeda <ojeda@kernel.org>
To: Alexandre Courbot <acourbot@nvidia.com>, Miguel Ojeda <ojeda@kernel.org>
Cc: "Yury Norov" <yury.norov@gmail.com>,
rust-for-linux@vger.kernel.org, "Boqun Feng" <boqun@kernel.org>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Antoni Boucher" <bouanto@zoho.com>
Subject: [PATCH] rust: bitfield: always inline test conversions
Date: Fri, 7 Aug 2026 19:50:12 +0200 [thread overview]
Message-ID: <20260807175012.142083-1-ojeda@kernel.org> (raw)
From: Antoni Boucher <bouanto@zoho.com>
When using the Rust GCC backend (i.e. `rustc_codegen_gcc`), GCC does not
inline enough these `Bounded::from_expr` calls:
/usr/bin/x86_64-linux-gnu-ld.bfd: rust/kernel.o: in function `<kernel::num::bounded::Bounded<u16, 2> as core::convert::From<kernel::bitfield::tests::Priority>>::from':
fake.c:(.text.unlikely+0x7be): undefined reference to `rust_build_error'
/usr/bin/x86_64-linux-gnu-ld.bfd: rust/kernel.o: in function `<kernel::num::bounded::Bounded<u64, 4> as core::convert::From<kernel::bitfield::tests::MemoryType>>::from':
fake.c:(.text.unlikely+0x90d): undefined reference to `rust_build_error'
Thus, similar to commit bc197e24a3ac ("rust: num: bounded: Always inline
fits_within and from_expr"), mark them as `#[inline(always)]`.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Antoni Boucher <bouanto@zoho.com>
[ Reworded to add the error and to follow our usual style and sent on
behalf of Antoni, who found this during his work to support Rust for
Linux with the GCC backend, i.e. with `rustc_codegen_gcc`.- Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
rust/kernel/bitfield.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs
index 35ede53f2b8e..a0d089423f21 100644
--- a/rust/kernel/bitfield.rs
+++ b/rust/kernel/bitfield.rs
@@ -581,6 +581,7 @@ fn try_from(value: Bounded<u64, 4>) -> Result<Self, Self::Error> {
}
impl From<MemoryType> for Bounded<u64, 4> {
+ #[inline(always)]
fn from(mt: MemoryType) -> Bounded<u64, 4> {
Bounded::from_expr(mt as u64)
}
@@ -606,6 +607,7 @@ fn from(value: Bounded<u16, 2>) -> Self {
}
impl From<Priority> for Bounded<u16, 2> {
+ #[inline(always)]
fn from(p: Priority) -> Bounded<u16, 2> {
Bounded::from_expr(p as u16)
}
base-commit: dc01dfb37b34beeefcfe1c3055364d41a4070c7e
--
2.55.0
next reply other threads:[~2026-08-07 17:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 17:50 Miguel Ojeda [this message]
2026-08-07 18:11 ` [PATCH] rust: bitfield: always inline test conversions Danilo Krummrich
2026-08-07 19:14 ` Gary Guo
2026-08-09 2:11 ` Alexandre Courbot
2026-08-10 5:01 ` Miguel Ojeda
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=20260807175012.142083-1-ojeda@kernel.org \
--to=ojeda@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bouanto@zoho.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=yury.norov@gmail.com \
/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