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@nvidia.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.