[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DET9YBKJ7XSC.FFZZQRIAW09V@nvidia.com>
Date: Tue, 09 Dec 2025 09:54:46 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Gary Guo" <gary@...yguo.net>, "Alexandre Courbot" <acourbot@...dia.com>
Cc: "Danilo Krummrich" <dakr@...nel.org>, "Alice Ryhl"
<aliceryhl@...gle.com>, "Daniel Almeida" <daniel.almeida@...labora.com>,
"Miguel Ojeda" <ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>,
"Boqun Feng" <boqun.feng@...il.com>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Trevor Gross" <tmgross@...ch.edu>,
"Rafael J. Wysocki" <rafael@...nel.org>, "Viresh Kumar"
<viresh.kumar@...aro.org>, "Will Deacon" <will@...nel.org>, "Peter
Zijlstra" <peterz@...radead.org>, "Mark Rutland" <mark.rutland@....com>,
<rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-pm@...r.kernel.org>, <stable@...r.kernel.org>
Subject: Re: [PATCH v3 0/7] rust: build_assert: document and fix use with
function arguments
On Mon Dec 8, 2025 at 10:49 PM JST, Gary Guo wrote:
> On Mon, 08 Dec 2025 11:46:58 +0900
> Alexandre Courbot <acourbot@...dia.com> wrote:
>
>> `build_assert` relies on the compiler to optimize out its error path,
>> lest build fails with the dreaded error:
>>
>> ERROR: modpost: "rust_build_error" [path/to/module.ko] undefined!
>>
>> It has been observed that very trivial code performing I/O accesses
>> (sometimes even using an immediate value) would seemingly randomly fail
>> with this error whenever `CLIPPY=1` was set. The same behavior was also
>> observed until different, very similar conditions [1][2].
>>
>> The cause, as pointed out by Gary Guo [3], appears to be that the
>> failing function is eventually using `build_assert` with its argument,
>> but is only annotated with `#[inline]`. This gives the compiler freedom
>> to not inline the function, which it notably did when Clippy was active,
>> triggering the error.
>
> That's an interesting observation, so `#[inline]` is fine without
> clippy but `#[inline(always)]` is needed when Clippy is used?
Precisely. And sometimes just moving the code invoking the
not-always-inlined function that invokes build_assert is enough to fix
it, so I don't know of an accurately reproducible pattern. It also
occurs pretty rarely.
Powered by blists - more mailing lists