[PATCH V13 5/7] rust: Make __udivdi3() and __umoddi3() panic

Arnd Bergmann arnd at arndb.de
Fri Apr 24 20:20:31 AEST 2026


On Fri, Apr 24, 2026, at 11:43, Link Mauve wrote:
> On Fri, Apr 24, 2026 at 10:14:25AM +0100, David Laight wrote:
>> On Fri, 24 Apr 2026 11:17:40 +0530
>> "Mukesh Kumar Chaurasiya (IBM)" <mkchauras at gmail.com> wrote:
>> 
>> > From: Link Mauve <linkmauve at linkmauve.fr>
>> > 
>> > The core crate currently depends on these two functions for i64/u64/
>> > i128/u128/core::time::Duration formatting, but we shouldn’t use that in
>> > the kernel so let’s panic if they are ever called.
>> 
>> Ugg.
>> Surely you can make it a link-time failure?
>> Or change the underlying code to avoid the divide.
>
> This is currently a link-time failure, which means if any of the core
> crate or drm_panic_qr are linked in, the kernel will fail to link.
>
> And since we rely on core, that means no kernel can be built on PowerPC
> without this patch.
>
> A possible solution would be to change the core crate to not divide
> u64s, but the last time I tried to do that I couldn’t quite figure out
> how to do formatting without it, maybe I will just open an issue against
> Rust.

How hard would it be to have a private copy of the parts of the core
crate that the kernel actually needs? Since Linux is neither quite
hosted (using a full libc) nor entirely freestanding (still using
some library interfaces), the C implementation on most architectures
has a small subset of the libgcc that we ship with the kernel.

I assume the core crate is larger than libgcc, but I don't know how
much of it is actually needed here.

       Arnd


More information about the Linuxppc-dev mailing list