Bug 81424 - [7/8 regression] internal error on GPRbuild with -O2
Summary: [7/8 regression] internal error on GPRbuild with -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 7.1.0
: P3 normal
Target Milestone: 7.2
Assignee: Eric Botcazou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-13 07:08 UTC by Pavel Zhukov
Modified: 2017-07-16 22:09 UTC (History)
2 users (show)

See Also:
Host:
Target: i686-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-07-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Zhukov 2017-07-13 07:08:23 UTC
During compilcation of gprbuild or gnatcoll on i686 in Fedora compiler exits with unrecoverable error [1]. 
Reproducer https://landgraf.fedorapeople.org/gccbug.tgz. Compilation options are in command.sh file inside.
Fedora bugreport: https://bugzilla.redhat.com/show_bug.cgi?id=1444614

It affects entire stack of Ada program in Fedora as all of them are blocked by this.
As gcc<7 works fine and both gprbuild 2016 and 2017 from AdaCore cannot be compiled with gcc>=7 I suspect the problem is in gcc itself not gprbuild.

[1] 
/builddir/build/BUILD/gprbuild-gpl-2017-src/gpr/src/gpr-compilation-protocol.ads:198:7: note: 'PID' was declared here
+===========================GNAT BUG DETECTED==============================+
| 7.1.1 20170526 (Red Hat 7.1.1-2) (i686-redhat-linux) GCC error:          |
| in emit_move_insn, at expr.c:3698                                        |
| Error detected around /builddir/build/BUILD/gprbuild-gpl-2017-src/src/gprclean-main.adb:995:13|
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+
Comment 1 Eric Botcazou 2017-07-15 21:27:58 UTC
Confirmed, but how can it block anything since the workaround is trivial?
Comment 2 Pavel Zhukov 2017-07-16 11:16:51 UTC
(In reply to Eric Botcazou from comment #1)
> Confirmed, but how can it block anything since the workaround is trivial?

Thanks Eric.

We have to use compiler/linker flags provided by distribution's macros and they include O2 [1]. While we can change gnat specific flags relatively easy global optflags is distribution wide.

Ada packaging guidelines:
https://fedoraproject.org/wiki/Packaging:Ada

[1]  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector https://fedoraproject.org/wiki/Packaging:RPMMacros#Build_flags_macros_and_variables
Comment 3 Björn Persson 2017-07-16 12:08:42 UTC
Well it is permissible to change the compilation options if there is a really good reason. If another optimization level works around the bug, then I think we can append for example -O1 until the bug is fixed.
Comment 4 Eric Botcazou 2017-07-16 12:17:08 UTC
Recategorizing.
Comment 5 Eric Botcazou 2017-07-16 12:17:35 UTC
Fixing.
Comment 6 Eric Botcazou 2017-07-16 22:04:26 UTC
Author: ebotcazou
Date: Sun Jul 16 22:03:54 2017
New Revision: 250246

URL: https://gcc.gnu.org/viewcvs?rev=250246&root=gcc&view=rev
Log:
	PR rtl-optimization/81424
	* optabs.c (prepare_cmp_insn): Use copy_to_reg instead of force_reg
	to remove potential trapping from operands if -fnon-call-exceptions.

Added:
    trunk/gcc/testsuite/gnat.dg/opt65.adb
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/optabs.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Eric Botcazou 2017-07-16 22:07:47 UTC
Author: ebotcazou
Date: Sun Jul 16 22:07:15 2017
New Revision: 250247

URL: https://gcc.gnu.org/viewcvs?rev=250247&root=gcc&view=rev
Log:
	PR rtl-optimization/81424
	* optabs.c (prepare_cmp_insn): Use copy_to_reg instead of force_reg
	to remove potential trapping from operands if -fnon-call-exceptions.

Added:
    branches/gcc-7-branch/gcc/testsuite/gnat.dg/opt65.adb   (props changed)
      - copied unchanged from r250246, trunk/gcc/testsuite/gnat.dg/opt65.adb
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/optabs.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog

Propchange: branches/gcc-7-branch/gcc/testsuite/gnat.dg/opt65.adb
            ('svn:mergeinfo' added)
Comment 8 Eric Botcazou 2017-07-16 22:09:06 UTC
Thanks for reporting the problem.