Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 701786 - sys-devel/gcc-9.2.0 emerge fails on x86-64 with USE="lto pgo"
Summary: sys-devel/gcc-9.2.0 emerge fails on x86-64 with USE="lto pgo"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal minor (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://gcc.gnu.org/PR97295
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-02 17:31 UTC by jeff.lemos.a
Modified: 2020-10-09 10:46 UTC (History)
1 user (show)

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


Attachments
build log (build.log.xz,164.09 KB, application/x-xz)
2019-12-02 17:31 UTC, jeff.lemos.a
Details
emerge information (file_701786.txt,8.00 KB, text/plain)
2019-12-02 17:37 UTC, jeff.lemos.a
Details
latest build log (gcc-build-logs.tar.bz2,724.12 KB, application/x-bzip2)
2020-03-04 22:33 UTC, jeff.lemos.a
Details
values on /etc/portage/env/gcc.conf (file_701786.txt,571 bytes, text/plain)
2020-03-04 22:51 UTC, jeff.lemos.a
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jeff.lemos.a 2019-12-02 17:31:00 UTC
Created attachment 598282 [details]
build log

the compiler throws an "internal compiler error" and the package fails to emerge
Comment 1 jeff.lemos.a 2019-12-02 17:37:27 UTC
Created attachment 598284 [details]
emerge information
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-23 13:20:58 UTC
The underlying failure is:

/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/d/runtime.cc:37:6: warning: type 'libcall_type' violates the C++ One Definition Rule [-Wodr]
   37 | enum libcall_type
      |      ^
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/rtl.h:4108:6: note: an enum with different value name is defined in another translation unit
 4108 | enum libcall_type
      |      ^
during RTL pass: ira
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/vec.h: In function 'reserve':
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/vec.h:385: internal compiler error: in to_frequency, at profile-count.c:265
  385 | }
      |
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.

1. Do you encounter the same error if you attempt to built gcc again?
2. Does 'dmesg' say if crash happened due to OOM? (unlikely, but just in casee)
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-02 21:06:28 UTC
If it still happens prease reopen with details requested in #comment2
Comment 4 jeff.lemos.a 2020-03-04 19:15:19 UTC
the error is still happening but there is no OOM crash on dmesg. Also, this bug happens on the very end of compilation. Counting from genlop, it was less then 30min to end. Sorry for the late answer, I was having some other minor problem with world update at the same time. I have a memory compressor at the kernel, I dont know if it could be an issue for the profiler
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-04 20:22:09 UTC
Do you encounter the same error if you attempt to built gcc again? Can you upload more recent build failure?
Comment 6 jeff.lemos.a 2020-03-04 22:33:35 UTC
Created attachment 617138 [details]
latest build log
Comment 7 jeff.lemos.a 2020-03-04 22:35:55 UTC
I have tried it just before reopening
Comment 8 jeff.lemos.a 2020-03-04 22:51:51 UTC
Created attachment 617140 [details]
values on /etc/portage/env/gcc.conf
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-05 00:09:49 UTC
Yeah, looks like the bug is deterministic:

"""
   37 | enum libcall_type
      |      ^
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/rtl.h:4108:6: note: an enum with different value name is defined in another translation unit
 4108 | enum libcall_type
      |      ^
during RTL pass: ira
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/vec.h: In function ‘reserve’:
/var/tmp/portage/sys-devel/gcc-9.2.0-r2/work/gcc-9.2.0/gcc/vec.h:385: internal compiler error: in to_frequency, at profile-count.c:265
  385 | }
      |
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
"""
Comment 10 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-05 01:46:42 UTC
Reproduced locally. Looking at the details.
Comment 11 Enne Eziarc 2020-03-05 03:16:39 UTC
Seems to be with USE="lto pgo d" specifically.
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-05 09:14:06 UTC
In my case it is USE=-d:
"""
[ebuild   R    ] sys-devel/gcc-9.2.0-r2:9.2.0::gentoo  USE="(cxx) fortran lto* (multilib) nls nptl openmp pch pgo* (pie) sanitize ssp vtv (-altivec) -d -debug -doc (-fixed-point) -go -graphite (-hardened) (-jit) (-libssp) -objc -objc++ -objc-gc -systemtap -test -vanilla" 0 KiB
"""
Comment 13 Larry the Git Cow gentoo-dev 2020-03-05 23:56:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3bbf3bd432ec1436bef6e2d7ffc83d1c031553ab

commit 3bbf3bd432ec1436bef6e2d7ffc83d1c031553ab
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-03-05 23:52:26 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-03-05 23:52:26 +0000

    toolchain.eclass: mangle -O3 down to -O2, not -O0
    
    In bug #701786 'strip-flags' removed all unsafe options
    first including -O3 and only then mangled -O? to -O2.
    
    This effectively made gcc to compalie wth -O0, generated
    huge slow profile and confused LTO.
    
    Let's default to safer -O3->-O2 transition.
    
    Reported-by: jeff.lemos.a@gmail.com
    Closes: https://bugs.gentoo.org/701786
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/toolchain.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-06 00:10:51 UTC
(In reply to jeff.lemos.a from comment #8)
> Created attachment 617140 [details]
> values on /etc/portage/env/gcc.conf

Also dounble-check your quoting at:

BOOT_CFLAGS='${BOOT_CFLAGS} --param lto-max-streaming-parallelism=3 -pipe -march=native'
CFLAGS_FOR_TARGET='${CFLAGS_FOR_TARGET} --param lto-max-streaming-parallelism=3 -pipe -march=native'

I suspect you lose all optimisations here as well.
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2020-10-09 10:46:23 UTC
https://gcc.gnu.org/PR97295 will fix handling of -O3/-O0+LTO+PGO case in gcc.