Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1475237 - Bad compilation of small program if LTO is used
Summary: Bad compilation of small program if LTO is used
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw-binutils
Version: 31
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kalev Lember
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1455137 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-26 09:17 UTC by Frediano Ziglio
Modified: 2019-11-28 01:31 UTC (History)
8 users (show)

Fixed In Version: mingw-binutils-2.32-6.fc31 mingw-binutils-2.30-7.fc30
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-28 01:10:57 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1455137 0 unspecified CLOSED Lost relocation using LTO option 2021-02-22 00:41:40 UTC

Description Frediano Ziglio 2017-07-26 09:17:25 UTC
Description of problem:
Trying to narrow down an issue I cannot compile and run a really small program
like

#include <iostream>

int main()
{
    std::cout << std::endl;
    return 0;
}

Trying to compile with 

x86_64-w64-mingw32-g++ -flto -fwhole-program -O2 -g -pipe -Wall -static -Wl,--subsystem,console -o test.exe test.cpp

It compiles without any warnings but when executed it crashes.
Maybe the problem is related to bug #1455137.


Version-Release number of selected component (if applicable):
mingw64-binutils-2.27-2.fc26.x86_64
mingw64-gcc-c++-7.1.0-1.fc26.x86_64
mingw64-headers-5.0.2-1.fc26.noarch


How reproducible:
Always


Steps to Reproduce:
1. compile the test program with options specified
2. execute the compiled program (even with wine)

Actual results:
Crash


Expected results:
An empty line is printed with no crash


Additional info:
Maybe related to bug #1455137

Comment 1 Frediano Ziglio 2017-07-26 09:21:06 UTC
Removing -static and/or -flto make the program works correctly.

Comment 2 Kalev Lember 2017-07-26 09:27:54 UTC
Sorry, I don't think we have anyone with compiler internals knowledge looking at mingw bugs. Can you file this upstream where it is likely to get more attention, please? I'm happy to backport fixes once it's resolved upstream.

Comment 3 Frediano Ziglio 2017-07-26 10:10:09 UTC
(In reply to Kalev Lember from comment #2)
> Sorry, I don't think we have anyone with compiler internals knowledge
> looking at mingw bugs. Can you file this upstream where it is likely to get
> more attention, please? I'm happy to backport fixes once it's resolved
> upstream.

I opened a bug to MinGW time ago but they closed the bug saying to open to the specific distro. Where should I open this bug then?

Comment 4 Kalev Lember 2017-07-26 10:13:11 UTC
Upstream gcc maybe? Not sure where the issue exactly is.

Do you have a link to the upstream MinGW bug that was closed?

Comment 5 Frediano Ziglio 2017-07-26 10:21:12 UTC
The original MinGW bug was at https://sourceforge.net/p/mingw/bugs/2346/.
Could be either gcc or binutils but being -static and -flto gcc options I would suspect gcc. I'll open a bug to them, thanks

Comment 6 Marc-Andre Lureau 2017-07-26 11:16:57 UTC
Kai, any known regression with lto?

Comment 7 Frediano Ziglio 2017-07-26 14:12:18 UTC
Somebody suggested that -flto and -fwhole-program do not play well together, but the issue happens also removing the -fwhole-program, that is even the command

   x86_64-w64-mingw32-g++ -flto -O2 -g -pipe -Wall -static -Wl,--subsystem,console -o test.exe test.cpp

cause the issue.
I don't know how easy would be to try to "git blame" (or something similar) this issue. The Epel 7 mock (older than Fedora 25) does not have this issue.

Comment 8 Frediano Ziglio 2017-08-17 11:18:06 UTC
Opened a bug to gcc, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81879.

Comment 9 Fedora End Of Life 2018-05-03 08:35:30 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 10 Fedora End Of Life 2018-05-29 12:00:05 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 11 Frediano Ziglio 2018-05-29 12:07:02 UTC
Happens also in Fedora 28

Comment 12 Ben Cotton 2019-05-02 21:41:12 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 13 Frediano Ziglio 2019-05-03 07:44:25 UTC
Turns out this was a bug in binutils. Fixed in 2.32.

Comment 14 Frediano Ziglio 2019-05-03 07:45:33 UTC
Turns out to be a bug in binutils, fixed in 2.32.

Comment 15 Frediano Ziglio 2019-07-18 09:29:55 UTC
Still present in Fedora 30

Comment 16 Sandro Mani 2019-11-19 16:58:12 UTC
The upstream patch [1] also applies to binutils-2.32, so I don't think it is fixed there? Anyway, I'll backport it.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=patch;h=2219ae0b0ebe14373850b000c2abaa31dab1d741

Comment 17 Fedora Update System 2019-11-19 21:53:55 UTC
FEDORA-2019-3d381baace has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-3d381baace

Comment 18 Fedora Update System 2019-11-19 21:54:36 UTC
FEDORA-2019-df955aca3d has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-df955aca3d

Comment 19 Fedora Update System 2019-11-20 01:28:14 UTC
mingw-binutils-2.32-6.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-3d381baace

Comment 20 Fedora Update System 2019-11-20 02:19:38 UTC
mingw-binutils-2.30-7.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-df955aca3d

Comment 21 Frediano Ziglio 2019-11-20 10:08:37 UTC
*** Bug 1455137 has been marked as a duplicate of this bug. ***

Comment 22 Frediano Ziglio 2019-11-20 10:10:45 UTC
mingw-binutils-2.30-7.fc30 package (Fedora 30) fixed this issue.
Note that you can use wine to test the program, no need to have a Windows machine.

Comment 23 Fedora Update System 2019-11-28 01:10:57 UTC
mingw-binutils-2.32-6.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 24 Fedora Update System 2019-11-28 01:31:07 UTC
mingw-binutils-2.30-7.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.


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