From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Matthew Fortune <Matthew.Fortune@imgtec.com>,
linux-mips@linux-mips.org, Waldemar Brodkorb <wbx@openadk.org>
Subject: Re: undefined reference to `__multi3' when building with gcc 7.x
Date: Sun, 13 Aug 2017 22:46:02 +0200 [thread overview]
Message-ID: <20170813224602.25043e8a@windsurf> (raw)
In-Reply-To: <20170807083448.GA20713@linux-mips.org>
Hello,
On Mon, 7 Aug 2017 10:34:48 +0200, Ralf Baechle wrote:
> > > Chances are it's something specific to MIPS64 R6. Before trying your
> > > config file I also tried a number of other defconfigs and all built
> > > well.
> > >
> > > Here's a test case which generates a reference to __multi3:
> > >
> > > unsigned long func(unsigned long a, unsigned long b)
> > > {
> > > return a > (~0UL) / b;
> > > }
> > >
> > > GCC rearanges above statement to:
> > >
> > > return (unsigned __int128)a * (unsigned __int128) b > 0xffffffff;
> >
> > And this is normal/expected ?
>
> Without consideration of performance, It's certainly is valid code. And
> with that I can't drop the issue as a GCC code generation bug.
>
> However it seems GCC itself doesn't seem to have a __multi3 in its
> libgcc2 - which indeed would be a GCC issue - at least none I was easily
> able to find with grep so I'm adding Matthew Fortune to cc in the hope he
> can shed some light on this.
Indeed, I don't see __multi3 implemented in libgcc in the source code,
but it's probably because it's tricky to see its implementation,
as it really is there:
$ ./bin/mips64el-linux-readelf -a ./mips64el-buildroot-linux-uclibc/sysroot/lib/libgcc_s.so.1 | grep multi3
1747: 00011700 100 FUNC GLOBAL DEFAULT 11 __multi3@@GCC_3.0
5511: 00011700 100 FUNC GLOBAL DEFAULT 11 __multi3
000435e4 -32236(gp) 00011700 00011700 FUNC 11 __multi3
Objdump says:
00011700 <__multi3>:
11700: 0006103e dsrl32 v0,a2,0x0
11704: 7c89f803 dext a5,a0,0x0,0x20
11708: 0004403e dsrl32 a4,a0,0x0
1170c: 7ccaf803 dext a6,a2,0x0,0x20
11710: 012a589c dmul a7,a5,a6
11714: 010a509c dmul a6,a4,a6
11718: 0122489c dmul a5,a5,v0
1171c: 0102409c dmul a4,a4,v0
11720: 012a482d daddu a5,a5,a6
11724: 000b103e dsrl32 v0,a7,0x0
11728: 0049102d daddu v0,v0,a5
1172c: 184a0003 bgeuc v0,a6,1173c <.L2>
11730: 24090001 li a5,1
11734: 0009483c dsll32 a5,a5,0x0
11738: 0109402d daddu a4,a4,a5
The same __multi3 problem also occurred on SPARC64, and they fixed it
by adding a __multi3 implementation in the kernel. See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/sparc?id=1b4af13ff2cc6897557bb0b8d9e2fad4fa4d67aa.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2017-08-13 20:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 20:55 undefined reference to `__multi3' when building with gcc 7.x Thomas Petazzoni
2017-08-04 0:05 ` Ralf Baechle
2017-08-04 15:19 ` Ralf Baechle
2017-08-04 15:41 ` Thomas Petazzoni
2017-08-04 22:25 ` Ralf Baechle
2017-08-05 11:56 ` Thomas Petazzoni
2017-08-07 8:34 ` Ralf Baechle
2017-08-13 20:46 ` Thomas Petazzoni [this message]
2017-08-17 7:15 ` Ralf Baechle
2017-08-17 8:49 ` Matthew Fortune
2017-08-17 22:19 ` Ralf Baechle
2017-10-07 19:22 ` Thomas Petazzoni
2017-11-07 17:39 ` Thomas Petazzoni
2017-08-17 1:01 ` Maciej W. Rozycki
2017-08-17 1:01 ` Maciej W. Rozycki
2017-12-03 9:56 ` Thomas Petazzoni
2017-12-05 23:49 ` James Hogan
2017-12-05 23:49 ` James Hogan
2017-12-06 7:50 ` Thomas Petazzoni
2017-12-06 7:50 ` Thomas Petazzoni
2017-12-07 7:20 ` [PATCH] MIPS: Implement __multi3 for GCC7 MIPS64r6 builds James Hogan
2017-12-08 23:52 ` Maciej W. Rozycki
2017-12-08 23:52 ` Maciej W. Rozycki
2017-12-09 7:15 ` James Hogan
2017-12-09 7:15 ` James Hogan
2017-12-27 8:31 ` Waldemar Brodkorb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170813224602.25043e8a@windsurf \
--to=thomas.petazzoni@free-electrons.com \
--cc=Matthew.Fortune@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=wbx@openadk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.