Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 801364 - sys-devel/gcc-11.1.0-r2: ICE internal compiler error: Segmentation fault
Summary: sys-devel/gcc-11.1.0-r2: ICE internal compiler error: Segmentation fault
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-09 17:56 UTC by Adel KARA SLIMANE
Modified: 2021-07-10 02:13 UTC (History)
1 user (show)

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


Attachments
emerge info (emerge-info-gcc-11.1.0-r2,7.67 KB, text/plain)
2021-07-09 17:57 UTC, Adel KARA SLIMANE
Details
emerge pqv (emerge-pqv-gcc-11.1.0-r2,291 bytes, text/plain)
2021-07-09 17:57 UTC, Adel KARA SLIMANE
Details
Build log with -j32 (buildlog-gcc-11.1.0-r2-j32.tar.xz,143.49 KB, application/x-xz)
2021-07-09 17:58 UTC, Adel KARA SLIMANE
Details
Build log with -j1 (buildlog-gcc-11.1.0-r2-j1.tar.xz,113.64 KB, application/x-xz)
2021-07-09 17:58 UTC, Adel KARA SLIMANE
Details
Second -j1 build (buildlog-gcc-11.1.0-r2-j1-2.tar.xz,107.96 KB, application/x-xz)
2021-07-09 22:28 UTC, Adel KARA SLIMANE
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adel KARA SLIMANE 2021-07-09 17:56:59 UTC
Hello,

I tried to update the the recent revision sys-devel/gcc-11.1.0-r2 and the compiler seems to get an internal error. It is a PGO+LTO build. Interestingly enough, the compiler does not ICE at the same file when the compilation is done with -j32 or -j1
Comment 1 Adel KARA SLIMANE 2021-07-09 17:57:20 UTC
Created attachment 722968 [details]
emerge info
Comment 2 Adel KARA SLIMANE 2021-07-09 17:57:32 UTC
Created attachment 722971 [details]
emerge pqv
Comment 3 Adel KARA SLIMANE 2021-07-09 17:58:46 UTC
Created attachment 722974 [details]
Build log with -j32
Comment 4 Adel KARA SLIMANE 2021-07-09 17:58:59 UTC
Created attachment 722977 [details]
Build log with -j1
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-09 17:59:51 UTC
If you do a few -j1 builds, do the crash the same?
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-09 18:02:12 UTC
Posting a few unutual things:

> CFLAGS="-O3 -march=native -pipe"
> [ebuild     U ] sys-devel/gcc-11.1.0-r2 [11.1.0-r1] USE="... lto ... pgo ..."

"""
      |                ^
during RTL pass: reload
options.c: In function ‘cl_enum_evrp_mode_set’:
options.c:312: internal compiler error: Segmentation fault
  312 | cl_enum_evrp_mode_set (void *var, int value)
      |
"""
Comment 7 Adel KARA SLIMANE 2021-07-09 18:06:47 UTC
I will try again with another -j1, the crash happens several hours after the emerge process starts, I will report back as soon as I get the ICE.
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-09 21:46:01 UTC
(In reply to Sergei Trofimovich from comment #6)
> Posting a few unutual things:
> 
> > CFLAGS="-O3 -march=native -pipe"
> > [ebuild     U ] sys-devel/gcc-11.1.0-r2 [11.1.0-r1] USE="... lto ... pgo ..."

I failed to reproduce locally :( I believe I have access to the same CPU as your's:

System uname: Linux-5.13.0-11856-g55e748397e9a-x86_64-AMD_Ryzen_9_5950X_16-Core_Processor-with-glibc2.33

That might be either a sign of very elusive bug:
- in userspace (unlikely elusive as you are able to consistently hit it)
- in kernel (might be?)
- in hardware

USE='lto' and USE='pgo' are heavyweight flags that "allow" you to generate effectively unique binaries for your system.

Would be nice to narrow down to smaller set of changes from default stage3 to get to that broken state.

I suggest a few things:
1. Try vanilla kernel (maybe, gentoo-sources; ideally built on non-O3 system)
2. Try sys-apps/memtest86+ and make sure RAM is not outright broken
3. Try disabling USE='lto' (might require 2 gcc rebuilds)
4. Try disabling USE='pgo'
5. Add -ggdb to CFLAGS/CXXFLAGS. That should make gcc crashes more informative. Might not yield too much information to narrow it down precisely. But worth a try.
Comment 9 Adel KARA SLIMANE 2021-07-09 21:59:58 UTC
My second -j1 build is still ongoing... 

Thank you for  your suggestions!

- I went through 4 passes of memtest86+ few days ago, and it successfully passed them, I will retry because I am aware that sometimes things just randomly change.
- The last times I tried to compile GCC my CPU was actually dropping to 0.5Ghz all core because of PBO and a motherboard with poor VRM, I had to disable it. Maybe that actually broke something in the motherboard, I will be receiving a new motherboard tomorrow and I will retry with it. Maybe my CPU is actually erroring out.
- I will actually save my current GCC-11.1.0-r1 in a binpkg and will try to rebuild that same version. To see if it still works, if it doesn't then that may point towards hardware error. I will rebuild glibc with -O2 because I have it built with USE=custom-cflags. 
- I will build a standard kernel with an archlinux config to see, too.
Comment 10 Adel KARA SLIMANE 2021-07-09 22:07:01 UTC
> ideally built on non-O3 system

Isn't the compiler entirely bootstrapped from what's in the system ? I have seen it rebuilt itself with the past version of itself during the emerge.
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-09 22:16:45 UTC
(In reply to Adel KARA SLIMANE from comment #10)
> > ideally built on non-O3 system
> 
> Isn't the compiler entirely bootstrapped from what's in the system ? I have
> seen it rebuilt itself with the past version of itself during the emerge.

Oh, I only meant to build a kernel by a compiler that was built with -O2 itself to avoid use of potentially broken compiler (it crashes on us after all).
Comment 12 Adel KARA SLIMANE 2021-07-09 22:28:05 UTC
Created attachment 723022 [details]
Second -j1 build

Alright, here's the second -j1 build. It ICEs at a different file.

```
/var/tmp/portage/sys-devel/gcc-11.1.0-r2/work/gcc-11.1.0/gcc/profile-count.h: In member function ‘profile_count profile_count::apply_probability(int) const’:
/var/tmp/portage/sys-devel/gcc-11.1.0-r2/work/gcc-11.1.0/gcc/profile-count.h:1046:26: internal compiler error: Aborted
 1046 |       if (!initialized_p ())
      |            ~~~~~~~~~~~~~~^~
```
Comment 13 Adel KARA SLIMANE 2021-07-09 22:29:38 UTC
> Oh, I only meant to build a kernel by a compiler that was built with -O2 itself to avoid use of potentially broken compiler (it crashes on us after all).

Alright! I will add building an -O2 kernel with gcc to the list of things I need to try (because I have that built too with -O3, clang and LTO... xD). 

I do not have USE=custom-cflags with GCC so it is already -O2 built as the -O3 flag gets stripped.

> strip-flags: CFLAGS: changed '-O3 -march=native -pipe' to '-march=native -pipe -O2'
Comment 14 Adel KARA SLIMANE 2021-07-09 23:42:03 UTC
Okay, some new elements:
- memtest86-efi for 35 minutes doesn't give any errors
- I successfully built gcc-11.1.0-r1 again. So something changed between these two. 
- I will retry to emerge gcc-11.1.0-r2, maybe it will work this time, who knows.
Comment 15 Adel KARA SLIMANE 2021-07-10 00:21:52 UTC
After re-emerging gcc-11.1.0-r1 with the same usual flags (includes LTO and PGO), gcc-11.1.0-r2 successfully got built. I have no idea why this is the case...

Thank you for your help and your time!