Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 894134 - sys-devel/gcc: ICEs on all pkgs (e.g. internal compiler error: Illegal instruction) in dev-libs/gmp 's __gmpn_mul_1/__gmpn_invert_limb) on PPC64 stage3
Summary: sys-devel/gcc: ICEs on all pkgs (e.g. internal compiler error: Illegal instru...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: PPC64 Linux
: Normal critical
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard: G5 Mac
Keywords:
: 895964 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-02-12 21:54 UTC by Matt
Modified: 2023-05-04 08:05 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
'emerge --info' output (emerge--info.txt,5.32 KB, text/plain)
2023-02-12 21:54 UTC, Matt
Details
"emerge --info '=sys-apps/grep-3.8-r1::gentoo'" output (grep-3.8-r1_info,6.15 KB, text/plain)
2023-02-12 21:55 UTC, Matt
Details
"emerge -pqv '=sys-apps/grep-3.8-r1::gentoo'" output (grep-3.8-r1_pqv,86 bytes, text/plain)
2023-02-12 21:56 UTC, Matt
Details
"emerge --info '=sys-libs/pam-1.5.2-r3::gentoo'" output (pam-1.5.2-r3_info,6.17 KB, text/plain)
2023-02-12 21:56 UTC, Matt
Details
"emerge -pqv '=sys-libs/pam-1.5.2-r3::gentoo'" output (pam-1.5.2-r3_pqv,106 bytes, text/plain)
2023-02-12 21:57 UTC, Matt
Details
"emerge --info '=app-editors/nano-6.4::gentoo'" output (nano-6.4_info,6.18 KB, text/plain)
2023-02-12 21:57 UTC, Matt
Details
"emerge -pqv '=app-editors/nano-6.4::gentoo'" output (nano-6.4_pqv,125 bytes, text/plain)
2023-02-12 21:58 UTC, Matt
Details
grep-3.8-r1 build.log (build.log,77.00 KB, application/octet-stream)
2023-02-12 21:58 UTC, Matt
Details
grep-3.8-r1 environment (environment,77.61 KB, text/plain)
2023-02-12 21:59 UTC, Matt
Details
pam-1.5.2-r3 build.log (build.log,26.37 KB, application/octet-stream)
2023-02-12 21:59 UTC, Matt
Details
pam-1.5.2-r3 environment (environment,112.29 KB, text/plain)
2023-02-12 22:00 UTC, Matt
Details
nano-6.4 build.log (build.log,93.03 KB, application/octet-stream)
2023-02-12 22:01 UTC, Matt
Details
nano-6.4 environment (environment,72.18 KB, text/plain)
2023-02-12 22:01 UTC, Matt
Details
"emerge --info '=dev-libs/gmp-6.2.1-r5::gentoo'" output (gmp-6.2.1-r5_info.txt,6.18 KB, text/plain)
2023-02-18 17:52 UTC, Matt
Details
"emerge -pqv '=dev-libs/gmp-6.2.1-r5::gentoo'" output (gmp-6.2.1-r5_pqv.txt,93 bytes, text/plain)
2023-02-18 17:53 UTC, Matt
Details
gmp-6.2.1-r5 environment (gmp-6.2.1-r5_enviroment.txt,73.70 KB, text/plain)
2023-02-18 17:53 UTC, Matt
Details
gmp-6.2.1-r5 build.log (gmp-6.2.1-r5_build.log,6.25 KB, application/octet-stream)
2023-02-18 17:54 UTC, Matt
Details
gmp-6.2.1-r5 config.log (gmp-6.2.1-r5_config.log,22.32 KB, text/plain)
2023-02-18 17:54 UTC, Matt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt 2023-02-12 21:54:42 UTC
Created attachment 850614 [details]
'emerge --info' output

I'm trying to install Gentoo on an iMac G5, following the PPC64 Handbook.

I started with the stage3 tarball 'stage3-ppc64-systemd-20230210T011702Z.tar.xz'.
I selected the profile 'default/linux/ppc64/17.0/systemd (stable)'.

While installing the base system, updating the world set fails. It says:

> libtool: compile:  powerpc64-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-libs/pam-1.5.2-r3/work/Linux-PAM-1.5.2/libpam -I.. -DDEFAULT_MODULE_PATH=\"/lib64/security/\" -DLIBPAM_COMPILE -I/var/tmp/portage/sys-libs/pam-1.5.2-r3/work/Linux-PAM-1.5.2/libpam/include -DPAM_VERSION=\"1.5.2\" -DSYSCONFDIR=\"/etc\" -W -Wall -Wbad-function-cast -Wcast-align -Wcast-align=strict -Wcast-qual -Wdeprecated -Winline -Wmain -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wshadow -Wstrict-prototypes -Wuninitialized -Wwrite-strings -O2 -pipe -c /var/tmp/portage/sys-libs/pam-1.5.2-r3/work/Linux-PAM-1.5.2/libpam/pam_delay.c  -fPIC -DPIC -o .libs/pam_delay.o
> /var/tmp/portage/sys-libs/pam-1.5.2-r3/work/Linux-PAM-1.5.2/libpam/pam_delay.c: In function '_pam_compute_delay':
> /var/tmp/portage/sys-libs/pam-1.5.2-r3/work/Linux-PAM-1.5.2/libpam/pam_delay.c:74:6: internal compiler error: Illegal instruction
>    74 |      sum = (sum/3.)/1e6 - .5;                      /* rescale */
>       |      ^~~
> 0x1172bf4b internal_error(char const*, ...)
>         ???:0
> 0x3f704eb3f8c4 .__gmpn_mul_1
>         ???:0

I then tested building nano-6.4, and ran into a very similar error.

> powerpc64-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I..   -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw    -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -O2 -pipe -Wall -c -o libgnu_a-float.o `test -f 'float.c' || echo './'`float.c
> float.c:25:3: internal compiler error: Illegal instruction
>    25 |   { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
>       |   ^
> 0x1172bf4b internal_error(char const*, ...)
>         ???:0
> 0x3f546f5df984 .__gmpn_mul_1
>         ???:0

And for grep-3.8-r1:

> powerpc64-unknown-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I..      -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -O2 -pipe -c -o libgreputils_a-c-strncasecmp.o `test -f 'c-strncasecmp.c' || echo './'`c-strncasecmp.c
> during GIMPLE pass: evrp
> c-strncasecmp.c: In function 'c_strncasecmp':
> c-strncasecmp.c:56:1: internal compiler error: Illegal instruction
>    56 | }
>       | ^
> 0x1172bf4b internal_error(char const*, ...)
>         ???:0
> 0x3f44d602ec28 __gmpn_invert_limb
>         ???:0


I tried searching around, but didn't find anything useful. Seems vaguely related to libgmp?

I'll attach all logs related to each package.
Comment 1 Matt 2023-02-12 21:55:40 UTC
Created attachment 850616 [details]
"emerge --info '=sys-apps/grep-3.8-r1::gentoo'" output
Comment 2 Matt 2023-02-12 21:56:17 UTC
Created attachment 850618 [details]
"emerge -pqv '=sys-apps/grep-3.8-r1::gentoo'" output
Comment 3 Matt 2023-02-12 21:56:46 UTC
Created attachment 850620 [details]
"emerge --info '=sys-libs/pam-1.5.2-r3::gentoo'" output
Comment 4 Matt 2023-02-12 21:57:07 UTC
Created attachment 850622 [details]
"emerge -pqv '=sys-libs/pam-1.5.2-r3::gentoo'" output
Comment 5 Matt 2023-02-12 21:57:44 UTC
Created attachment 850624 [details]
"emerge --info '=app-editors/nano-6.4::gentoo'" output
Comment 6 Matt 2023-02-12 21:58:11 UTC
Created attachment 850626 [details]
"emerge -pqv '=app-editors/nano-6.4::gentoo'" output
Comment 7 Matt 2023-02-12 21:58:54 UTC
Created attachment 850644 [details]
grep-3.8-r1 build.log
Comment 8 Matt 2023-02-12 21:59:11 UTC
Created attachment 850646 [details]
grep-3.8-r1 environment
Comment 9 Matt 2023-02-12 21:59:50 UTC
Created attachment 850648 [details]
pam-1.5.2-r3 build.log
Comment 10 Matt 2023-02-12 22:00:34 UTC
Created attachment 850650 [details]
pam-1.5.2-r3 environment
Comment 11 Matt 2023-02-12 22:01:04 UTC
Created attachment 850652 [details]
nano-6.4 build.log
Comment 12 Matt 2023-02-12 22:01:27 UTC
Created attachment 850654 [details]
nano-6.4 environment
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-12 22:45:17 UTC
This is too many coincidences now. This has got to be related to the changes we made for gmp in bug 883201.

If it's not a defect in those changes, my only guess is that when stage building, we're doing USE=-cpudetection..
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-18 12:23:14 UTC
In releng.git:
```
commit 5378e83aab46e53b3bbeb72d45f91024155ab878 (HEAD -> master, origin/master, origin/HEAD)
Author: Andreas K. Hüttel <dilfridge@gentoo.org>
Date:   Sat Feb 18 13:18:07 2023 +0100

    Test enabling cpudetection for gmp, for bug 894134

    Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
```

For now, could you try downgrade gmp (or ememrge it with USE=cpudetection)?
Comment 15 Matt 2023-02-18 17:51:39 UTC
I started from the 2/15/

I tried to build gmp-6.2.1-r5 USE="cpudetection", and it failed while configuring source with:

> checking ABI=mode64
> checking whether powerpc64-unknown-linux-gnu-gcc is gcc... yes
> checking compiler powerpc64-unknown-linux-gnu-gcc -O2 -pipe ... no, long long reliability test 1
> checking ABI=mode32
> checking whether powerpc64-unknown-linux-gnu-gcc is gcc... yes
> checking compiler powerpc64-unknown-linux-gnu-gcc -O2 -pipe ... no, long long reliability test 1
> checking ABI=32
> checking whether powerpc64-unknown-linux-gnu-gcc is gcc... yes
> checking compiler powerpc64-unknown-linux-gnu-gcc -O2 -pipe ... no, long long reliability test 1
> configure.wrapped: error: could not find a working compiler, see config.log for details

Looking into the config.log:

> Test compile: long long reliability test 1
> configure.wrapped:6543: powerpc64-unknown-linux-gnu-gcc -O2 -pipe  conftest.c >&5
> during GIMPLE pass: ldist
> conftest.c: In function 'f':
> conftest.c:11:6: internal compiler error: Illegal instruction
>    11 | void f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;
>       |      ^
> 0x1172bf4b internal_error(char const*, ...)
> 	???:0
> 0x3fee9bcfec28 __gmpn_invert_limb
> 	???:0

I then tried to downgrade to gmp-6.2.1-r1, and got the same error. I then just tried to rebuild gmp-6.2.1-r5 without cpudetection, again, same error.

I'll attach the gmp-6.2.1-r5 cpudetection info/logs.
Comment 16 Matt 2023-02-18 17:52:27 UTC
Created attachment 852708 [details]
"emerge --info '=dev-libs/gmp-6.2.1-r5::gentoo'" output
Comment 17 Matt 2023-02-18 17:53:14 UTC
Created attachment 852710 [details]
"emerge -pqv '=dev-libs/gmp-6.2.1-r5::gentoo'" output
Comment 18 Matt 2023-02-18 17:53:48 UTC
Created attachment 852712 [details]
gmp-6.2.1-r5 environment
Comment 19 Matt 2023-02-18 17:54:15 UTC
Created attachment 852714 [details]
gmp-6.2.1-r5 build.log
Comment 20 Matt 2023-02-18 17:54:40 UTC
Created attachment 852716 [details]
gmp-6.2.1-r5 config.log
Comment 21 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-23 22:12:55 UTC
*** Bug 895964 has been marked as a duplicate of this bug. ***
Comment 22 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-23 22:13:42 UTC
From David at https://bugs.gentoo.org/895964#c0:
"""
The binary of dev-libs/gmp included in stage3-ppc64-openrc-20230220T024702Z.tar.xz triggers SIGILL in __gmpn_invert_limb when running gcc on an e6500 (Freescale T4240) CPU.  Not all uses of gcc trigger the issue, presumably that math function is only used in specific circumstances.  Trying to build sys-devel/gcc triggers the issue reliably.

This is on a 5.15 kernel with math emulation for unimplemented math functions *enabled*. (The e6500 does not have FSQRT.)

I haven't tracked down yet what instruction exactly is causing the issue;  I ended up overwriting libgmp with a binary from Debian to get gcc working so I could rebuild dev-libs/gmp (which then worked as expected - no issue with the ebuild itself.)

It seems that this is simply an issue of the stage3 tarball being built with too aggressive CPU flags.

As I was under time pressure to get the setup running, I'll circle back to grab additional information in a few days.  (I can of course simply grab the stage tarball again, unpack it in a fresh directory on the now-working system, and run gcc inside that to reproduce the problem.  Just need to get the box up&running otherwise first, sorry.)

Reproducible: Always

Steps to Reproduce:
1. acquire an e6500 powerpc64 system or try emulating one with QEMU
2. grab stage3-ppc64-openrc-20230220T024702Z.tar.xz 
3. emerge sys-devel/gcc
Actual Results:  
SIGILL during build.

Expected Results:  
sys-devel/gcc being built.

# uname -a                            
Linux zehir 5.15.71+ #9 SMP Sun Feb 19 07:51:53 CET 2023 ppc64 GNU/Linux

# gunzip -c /proc/config.gz | grep MATH
CONFIG_MATH_EMULATION=y
# CONFIG_MATH_EMULATION_FULL is not set
CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED=y

# tail -n8 /proc/cpuinfo
processor       : 23
cpu             : e6500, altivec supported
clock           : 1666.666650MHz
revision        : 2.0 (pvr 8040 0120)

timebase        : 45833333
platform        : CoreNet Generic
model           : fsl,T4240QDS
"""

The next set of stages _should_ be fine, but if not, we'll need to do more.
Comment 23 David Lamparter 2023-02-24 09:15:18 UTC
(In reply to Sam James from comment #22)
> The next set of stages _should_ be fine, but if not, we'll need to do more.

That was quick, Thanks!  I'll retry to confirm when they become available.  If it still fails, at least now I have a sys-devel/gdb to get more info about the crash.

Also, no idea why I didn't find this bug, I did search for dev-libs/gmp... Apologies for the duplicate!
Comment 24 Mike G 2023-02-25 13:41:10 UTC
Just to confirm this problem exists in
stage3-ppc64-systemd-20230220T024702Z.tar.xz

Verified on iMac G5
Verified on IBM pSeries POWER7 QEMU/KVM virtual machine

The latter gives:
/var/tmp/portage/sys-devel/gettext-0.21.1/work/gettext-0.21.1/libtextstyle/lib/printf-frexp.c:104:11: internal compiler error: Illegal instruction
  104 |           for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
      |           ^~~
0x1172bf4b internal_error(char const*, ...)
        ???:0
0x3f3e5e68fc0c .__gmpn_submul_1
        ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Comment 25 immolo 2023-02-26 18:46:49 UTC
I've been tested this issue and Sam is correct with -cpudetection being the cause.

The workaround I used to get around it from a fresh stage3 (stage3-ppc64-systemd-20230225T031702Z.tar.xz)

(Using my amd64 machine running Gentoo)
1. emerge -va crossdev
2. crossdev -s4 powerpc64-unknown-linux-gnu
3. edit /usr/powerpc64-unknown-linux-gnu/etc/portage/make.conf and add USE="cpudetection"
3. emerge -va dev-libs/gmp
4. transfer gmp-6.2.1-r5-1.xpak from /usr/powerpc64-unknown-linux-gnu/var/cache/binpkgs/dev-libs/gmp to the PPC64 machine and place it in /var/cache/binpkgs/dev-libs/gmp 

(on the PPC64 machine)
5. edit /etc/portage/make.conf and add PKGDIR="/var/cache/binpkgs"
6. edit /etc/portage/profile/use.mask and add -cpudetection
7. emerge -vaK dev-libs/gmp

This will then get the system working for any user finding the issue today.

As a fix for Gentoo itself it looks like a fix we applied for mplayer is causing the issue so making it only apply to mplayer or if not just masking mplayer on ppc so it's not needed would solve this in future builds.

See https://github.com/gentoo/gentoo/blob/master/profiles/arch/powerpc/ppc64/use.mask#L36
Comment 26 Larry the Git Cow gentoo-dev 2023-02-26 19:24:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=935f64c522978b3f18349c06dac9aac54cb0ba7b

commit 935f64c522978b3f18349c06dac9aac54cb0ba7b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-02-26 19:23:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-02-26 19:24:13 +0000

    profiles/arch/powerpc/ppc64: shift cpudetection mask into p.use.mask
    
    Otherwise, this affects gmp[cpudetection]. This seems to be because
    the mask predated package.use.mask support...?
    
    Bug: https://bugs.gentoo.org/234629
    Bug: https://bugs.gentoo.org/894134
    Thanks-to: Ian Jordan <immoloism@gmail.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 profiles/arch/powerpc/ppc64/package.use.mask | 3 +++
 profiles/arch/powerpc/ppc64/use.mask         | 5 +----
 2 files changed, 4 insertions(+), 4 deletions(-)