Re: div64.c:(.text.mul_u64_add_u64_div_u64+0x40): undefined reference to `__multi3'

From: David Laight

Date: Sat Mar 21 2026 - 05:24:26 EST


On Sat, 21 Mar 2026 12:48:23 +0800
kernel test robot <lkp@xxxxxxxxx> wrote:

> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 42bddab0563fe67882b2722620a66dd98c8dbf33
> commit: 6480241f31f543333ed0c7a209962412461f6e41 lib: add mul_u64_add_u64_div_u64() and mul_u64_u64_div_u64_roundup()
> date: 4 months ago
> config: mips-randconfig-r122-20260321 (https://download.01.org/0day-ci/archive/20260321/202603211216.YTKRdi1b-lkp@xxxxxxxxx/config)
> compiler: mips64-linux-gcc (GCC) 8.5.0
> sparse: v0.6.5-rc1
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260321/202603211216.YTKRdi1b-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202603211216.YTKRdi1b-lkp@xxxxxxxxx/
>
> All errors (new ones prefixed by >>):
>
> mips64-linux-ld: lib/math/div64.o: in function `mul_u64_add_u64_div_u64':
> >> div64.c:(.text.mul_u64_add_u64_div_u64+0x40): undefined reference to `__multi3'
>

I thought someone was going to change the #if so that __multi3 was defined
for compilers after (IIRC) 7.1 until at (also IIRC) 10.5.
But for __mips why worry that much - the function is quite small.
Just enable it unconditionally.

While this code only wants the 128bit product of two 64bit integers
(which is a single instruction) the full 128x128 product looks
faster than the fallback code that uses 32bit multiples.

More interesting is sparc64 - where __multi3 can also get called.
That function looks horrid - I presume it is carefully optimised!
Without any comment it is hard to see what it is doing.
(Not helped by me only knowing sparc32 from 1988.)

David