Red Hat Bugzilla – Bug 1316999
gcc6 fails when optimizing c++ code for nightly (firefox development version)
Last modified: 2016-03-17 11:29:41 EDT
Description of problem:
I keep an hg repository of the firefox development version, nightly. I compile it on f21 with gcc 4.9 and rawhide (f25) with gcc6. With gcc 4.9, I can use -O3 and the resulting executable runs fine. With gcc6, neither -O2 or -O3 will run. The compile appears to complete successfully, but gets a seg fault on start. If I compile using gcc6, with -O0, the resulting executable runs fine, though slowly.
Version-Release number of selected component (if applicable):
Name : gcc
Version : 6.0.0
Release : 0.15.fc25
Steps to Reproduce:
1. Clone the hg repository for nightly
2. Default optimization is -O2, have to add
ac_add_options --enable-optimize=" -O3 "
if O3 wanted.
3. cd into the directory and run ./mach build
4. run ./mach install (the appended .mozconfig will put into /usr/local)
5. Observe the crash
Successful build, crash on start
Nightly runs fine
This is a bug at mozilla with some information about tests I've done to work around this. It's actually about another problem, but contains the extra data.
I'll attach the .mozconfig I use to build nightly.
It's possible this isn't a bug in gcc at all, but the fact that the code compiles and runs fine without optimization, -O0, leads me to believe it is.
I've compiled C programs with gcc 6 and -O3, and they have worked correctly. So it could be only in g++.
Please try -flifetime-dse=1 or -fno-lifetime-dse and/or -fno-delete-null-pointer-checks, forgot which of these violates firefox, whether trying to preserve data from before construction to after construction, or calling methods on NULL pointers (or both).
Created attachment 1135307 [details]
The .mozconfig that I am using to compile nightly.
Copy this into ~/.mozconfig in order to use it to compile nightly instead of the built in defaults.
@comment1, thanks jakub for the fast response. Will try those (will search first to profit from other's experience) to see what works. Progress!
See https://gcc.gnu.org/gcc-6/porting_to.html for some details.
Thanks for that reference. Very informative.
Once I confirm that following the advice in the reference allows nightly to compile, I'll close this ticket, as it isn't a problem with gcc 6.
I tried several variations of options, and nightly crashes on start with any optimization regardless of what I do.
ac_add_options --enable-optimize=" -Wall -std=gnu++11 -O3"
ac_add_options --enable-optimize=" -Wall -std=gnu++98 -O3" # this wouldn't compile
ac_add_options --enable-optimize=" -Wall -fno-delete-null-pointer-checks -O3"
ac_add_options --enable-optimize=" -Wnull-dereference -fno-delete-null-pointer-checks -O3"
I don't know whether it is gcc or nightly with the problem. I'm out of my depth here. So, I'll just drop it.
I leave it up to you whether to close the ticket.
Did you try -fno-lifetime-dse ?
Aarrrgh! No, I didn't. I'll give that a try today.
Thanks for the question. That was it!
When I used
ac_add_options --enable-optimize=" -Wall -fno-lifetime-dse -fno-delete-null-pointer-checks -O3"
nightly compiled fine, and started and is running fine. I'm using it to write this message.
So, I assume that means there is no issue with g++ optimization in gcc 6, and that it is coding style in nightly that is the cause of this because it is to a different standard than gcc 6.
If that is the case, then I think this ticket can be closed as NOTABUG.
Thanks for the help.
Not a gcc bug.