From: Ralf Baechle <ralf@linux-mips.org>
To: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: linux-mips@linux-mips.org, Waldemar Brodkorb <wbx@openadk.org>
Subject: Re: undefined reference to `__multi3' when building with gcc 7.x
Date: Sat, 5 Aug 2017 00:25:00 +0200 [thread overview]
Message-ID: <20170804222500.GA11675@linux-mips.org> (raw)
In-Reply-To: <20170804174151.2eea9af3@windsurf.lan>
On Fri, Aug 04, 2017 at 05:41:51PM +0200, Thomas Petazzoni wrote:
> > > > The bug can be reproduced by building with the toolchain available at
> > > > http://toolchains.free-electrons.com/downloads/2017.08-rc1-fix-binutils/toolchains/mips64r6el-n32/tarballs/mips64r6el-n32--glibc--bleeding-edge-2017.05-1453-ga703fdd-1.tar.bz2
> > > > and building with the attached kernel configuration file.
> > > >
> > > > It is not clear to me if this is a kernel issue (lack of __multi3 in
> > > > arch/mips/lib/), or a gcc bug in that it shouldn't emit a call to this
> > > > function.
> > > >
> > > > FWIW, sparc64 had a similar issue, and they added __multi3 in their
> > > > libgcc replacement, see commit
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/sparc/lib?id=1b4af13ff2cc6897557bb0b8d9e2fad4fa4d67aa.
> > >
> > > I think these days we've given up the stuborn resistance of the old days
> > > against adding new libgcc1 functions to the kernel, so we should probably
> > > just add it.
> > >
> > > I'm looking into this but a small wrench into the gear is that I'm still
> > > on GCC 6 so I'm off to building myself a cross-gcc first ...
> >
> > I now can reproduce the issue with vanilla FSF binutils 2.28 and GCC 7.1.0.
>
> Great! However, looking at the functions that end up calling __multi3,
> I'm wondering why suddenly gcc 7.x needs to call such a function, while
> the same code was compiling without __multi3 in libgcc with gcc 6.x.
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;
computing which requires 128 bit intermediate results. This is the
code generated for MIPS64 R2:
dmultu $4,$5
mfhi $2
sltu $2,$0,$2
And this is for R6:
move $2,$4
move $7,$5 # $6/$7 contain the second op
move $6,$0
move $4,$0
move $5,$2 # $4/$5 contain the first op
sd $31,8($sp)
balc __multi3
sltu $2,$0,$2
Ralf
next prev parent reply other threads:[~2017-08-04 22:25 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 [this message]
2017-08-05 11:56 ` Thomas Petazzoni
2017-08-07 8:34 ` Ralf Baechle
2017-08-13 20:46 ` Thomas Petazzoni
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=20170804222500.GA11675@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=linux-mips@linux-mips.org \
--cc=thomas.petazzoni@free-electrons.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox