[lkml]   [2022]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v7 06/25] rust: add `compiler_builtins` crate
 On Mon, May 23, 2022 at 4:42 PM Gary Guo <> wrote:
> On Mon, 23 May 2022 11:37:16 -0700
> Nick Desaulniers <> wrote:
> > Also, I'm not sure my concern about explicit build failures for C code
> > was ever addressed? We have a constant problem with `long long`
> > division on ARCH=arm32 and ARCH=i386 in C code.
> >
> >
> > > +#[cfg(target_arch = "arm")]
> > > +define_panicking_intrinsics!("`u64` division/modulo should not be
> > > used", {
> > > + __aeabi_uldivmod,
> > > + __mulodi4,
> > > +});
> Starting in LLVM 14 (used in Rust 1.60+), __mulodi4 will no longer be
> generated. So that can be removed.

I'm familiar, but good catch. ;)

> As for __aeabi_uldivmod, is there any reason that it can't just be
> defined in arch/arm/lib? There are quite a few __aeabi functions already
> defined there.

arch/arm/kernel/armksyms.c and

This is the previous thread I recall w/ Linus:

If CONFIG_RUST provides those symbols, it will hide the linkage
failures that we try to use to spot & avoid 64b division that's open
coded using the / binary operator, rather than the kernel's do_div()
and friends.

> The source of __aeabi_uldivmod in compiler-rt seems quite simple, just
> delegating to __uldivmoddi4. I think just changing that to
> div64_u64_rem should do the job?

Maybe; send a patch and see what happens. There's probably other 32b
architectures that will need other symbols that also handle 64b
division though, so it's not as simple as providing __aeabi_uldivmod
for ARM.

There's probably someone from linux-arm-kernel that can provide
additional context.
is pretty old, but refers to policies that seem to pre-exist other
references to __aeabi_uldivmod on that list.

arch/nios2/kernel/nios2_ksyms.c exports __udivmoddi4, but it also
explicitly links against libgcc. I'm guessing that's frowned upon,
but not out of the question relative to having the kernel ported to
the architecture at all.


Here's the latest source.
and __uldivmoddi4:

By chance, does any of the rust code in this series use open coded
division w/ 64 bit operands (rather than using do_div) by accident?

I'm also curious about the panic message for 128b operands. IIUC,
those are functions that may have `long long` operands. On 32b ARM,
which is ILP32, I'd have expected `long long` to be 64b, not 128b.
Message might be misleading.
~Nick Desaulniers

 \ /
  Last update: 2022-05-25 23:30    [W:0.062 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site