[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260114103103.216aa122@pumpkin>
Date: Wed, 14 Jan 2026 10:31:03 +0000
From: David Laight <david.laight.linux@...il.com>
To: "Maciej W. Rozycki" <macro@...am.me.uk>
Cc: kernel test robot <lkp@...el.com>, oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
Linux Memory Management List <linux-mm@...ck.org>, Nicolas Pitre
<npitre@...libre.com>, linux-mips@...r.kernel.org, Thomas Bogendoerfer
<tsbogend@...ha.franken.de>
Subject: Re: mips64-linux-ld: div64.c:undefined reference to `__multi3'
On Wed, 14 Jan 2026 06:19:02 +0000 (GMT)
"Maciej W. Rozycki" <macro@...am.me.uk> wrote:
> On Tue, 13 Jan 2026, David Laight wrote:
>
> > > All errors (new ones prefixed by >>):
> > >
> > > mips64-linux-ld: lib/math/div64.o: in function `mul_u64_add_u64_div_u64':
> > > div64.c:(.text+0x84): undefined reference to `__multi3'
> > > >> mips64-linux-ld: div64.c:(.text+0x11c): undefined reference to `__multi3'
> > >
> >
> > This looks like a bug in the mips 'port'.
> > arch/mips/lib/multi3.c has the comment:
> >
> > /*
> > * GCC 7 & older can suboptimally generate __multi3 calls for mips64r6, so for
> > * that specific case only we implement that intrinsic here.
> > *
> > * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82981
> > */
> > #if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPSR6) && (__GNUC__ < 8)
> >
> > So this code is excluded for gcc 8.5 but the compiler is generating the call.
> >
> > Looking at the git log for that file there is a comment that includes:
> > "we wouldn't expect any calls to __multi3 to be generated from
> > kernel code".
> > Not true....
> > Not sure why the link didn't fail before though, something subtle must
> > have changed.
> >
> > I think the fix is just to remove the gcc version check.
>
> Or rather fix the version check. The GCC fix went in with GCC 10:
Does that mean the GCC 10 generates the multiply instructions and never calls
__multi3?
(Rather than just not using __multi3() for that specific example.)
In this case gcc knows the high bits are all zero - so just needs the two
instructions to generate the high and low parts.
David
>
> $ git log -1 --pretty=oneline 48b2123f6336
> 48b2123f6336ba6c06846d7c8b60bd14eaeae7ec re PR target/82981 (unnecessary __multi3 call for mips64r6 linux kernel)
> $ git show 48b2123f6336:gcc/BASE-VER
> 10.0.0
> $
>
> I don't know why the PR got it all wrong; I've fixed it now.
>
> Maciej
>
Powered by blists - more mailing lists