Bug 1316999 - gcc6 fails when optimizing c++ code for nightly (firefox development version)
gcc6 fails when optimizing c++ code for nightly (firefox development version)
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2016-03-11 11:41 EST by stan
Modified: 2016-03-17 11:29 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-03-17 11:29:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
The .mozconfig that I am using to compile nightly. (1.17 KB, text/plain)
2016-03-11 11:45 EST, stan
no flags Details

  None (edit)
Description stan 2016-03-11 11:41:06 EST
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
Architecture: x86_64

How reproducible:
Every time.

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

Actual results:
Successful build, crash on start

Expected results:
Nightly runs fine

Additional info:
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++.
Comment 1 Jakub Jelinek 2016-03-11 11:45:01 EST
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).
Comment 2 stan 2016-03-11 11:45 EST
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.
Comment 3 stan 2016-03-11 12:24:30 EST
@comment1, thanks jakub for the fast response.  Will try those (will search first to profit from other's experience) to see what works.  Progress!
Comment 4 Jakub Jelinek 2016-03-11 12:27:08 EST
See https://gcc.gnu.org/gcc-6/porting_to.html for some details.
Comment 5 stan 2016-03-11 14:01:09 EST
Thanks for that reference.  Very informative.
Comment 6 stan 2016-03-11 14:02:19 EST
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.
Comment 7 stan 2016-03-11 16:48:46 EST
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.
Comment 8 Jonathan Wakely 2016-03-12 07:02:05 EST
Did you try -fno-lifetime-dse ?
Comment 9 stan 2016-03-13 15:26:08 EDT
Aarrrgh!  No, I didn't.  I'll give that a try today.
Comment 10 stan 2016-03-13 16:22:37 EDT
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.
Comment 11 Jakub Jelinek 2016-03-17 11:29:41 EDT
Not a gcc bug.

Note You need to log in before you can comment on or make changes to this bug.