Bug 1316999 - gcc6 fails when optimizing c++ code for nightly (firefox development version)
Summary: gcc6 fails when optimizing c++ code for nightly (firefox development version)
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-11 16:41 UTC by stan
Modified: 2016-03-17 15:29 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-03-17 15:29:41 UTC
Type: Bug
Embargoed:


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

Description stan 2016-03-11 16:41:06 UTC
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.
https://bugzilla.mozilla.org/show_bug.cgi?id=1245076

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 16:45:01 UTC
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 16:45:30 UTC
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 17:24:30 UTC
@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 17:27:08 UTC
See https://gcc.gnu.org/gcc-6/porting_to.html for some details.

Comment 5 stan 2016-03-11 19:01:09 UTC
Thanks for that reference.  Very informative.

Comment 6 stan 2016-03-11 19:02:19 UTC
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 21:48:46 UTC
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 12:02:05 UTC
Did you try -fno-lifetime-dse ?

Comment 9 stan 2016-03-13 19:26:08 UTC
Aarrrgh!  No, I didn't.  I'll give that a try today.

Comment 10 stan 2016-03-13 20:22:37 UTC
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 15:29:41 UTC
Not a gcc bug.


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