Bug 18199 - ld fails with -flto for mingw, wrong resolution for main
Summary: ld fails with -flto for mingw, wrong resolution for main
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-04 14:33 UTC by Rainer Emrich
Modified: 2016-01-11 13:55 UTC (History)
1 user (show)

See Also:
Host: x86_64-w64-mingw32
Target: x86_64-w64-mingw32
Build: x86_64-w64-mingw32
Last reconfirmed:


Attachments
Test case including temporaries (4.81 KB, application/x-bzip)
2015-04-04 14:36 UTC, Rainer Emrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Emrich 2015-04-04 14:33:16 UTC
For the Details please see PR65581 in the gcc bugzilla.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65581
Comment 1 Rainer Emrich 2015-04-04 14:36:07 UTC
Created attachment 8224 [details]
Test case including temporaries
Comment 2 Ismail Donmez 2015-06-10 12:22:37 UTC
I can also reproduce this, would be nice to get some feedback on this.
Comment 3 Ismail Donmez 2015-11-16 18:47:03 UTC
This is still the case with ld 2.26.51.20151113, any chance of a fix before 2.26 release?
Comment 4 cvs-commit@gcc.gnu.org 2015-12-10 16:15:22 UTC
The master branch has been updated by Kwok Yeung <kcy@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4a07dc81356ed8728e204e9aabeb256703c59aef

commit 4a07dc81356ed8728e204e9aabeb256703c59aef
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Thu Dec 10 16:11:07 2015 +0000

    ld: Fix LTO for MinGW targets
    
    When creating a dummy BFD for an IR file, the output BFD is used as
    a template for the new BFD, when it needs to be the input BFD passed
    into the function when not dealing with a BFD plugin.
    
    On most targets this is not an issue as the input and output formats
    are the same anyway, but on MinGW targets, there are two variant
    formats used (pe-i386/pe-x86-64 and pei-i386/pei-x86-64) which are
    similar but not interchangeable here.
    
    	PR ld/18199
    	* plugin.c (plugin_get_ir_dummy_bfd): Use srctemplate as the
    	template when calling bfd_create if it does not use the BFD
    	plugin target vector.
Comment 5 Ismail Donmez 2015-12-10 17:09:34 UTC
(In reply to cvs-commit@gcc.gnu.org from comment #4)
> The master branch has been updated by Kwok Yeung <kcy@sourceware.org>:
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=4a07dc81356ed8728e204e9aabeb256703c59aef
> 
> commit 4a07dc81356ed8728e204e9aabeb256703c59aef
> Author: Kwok Cheung Yeung <kcy@codesourcery.com>
> Date:   Thu Dec 10 16:11:07 2015 +0000
> 
>     ld: Fix LTO for MinGW targets

Great thanks! Please also backport to binutils-2_26-branch so it can be in the release (this is a regression compared to 2.25 release.)
Comment 6 cvs-commit@gcc.gnu.org 2016-01-11 13:55:26 UTC
The binutils-2_26-branch branch has been updated by Kwok Yeung <kcy@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=412d26bde8585eca3ec6b8bed70197205288cbdf

commit 412d26bde8585eca3ec6b8bed70197205288cbdf
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Thu Dec 10 16:11:07 2015 +0000

    ld: Fix LTO for MinGW targets
    
    When creating a dummy BFD for an IR file, the output BFD is used as
    a template for the new BFD, when it needs to be the input BFD passed
    into the function when not dealing with a BFD plugin.
    
    On most targets this is not an issue as the input and output formats
    are the same anyway, but on MinGW targets, there are two variant
    formats used (pe-i386/pe-x86-64 and pei-i386/pei-x86-64) which are
    similar but not interchangeable here.
    
    	PR ld/18199
    	* plugin.c (plugin_get_ir_dummy_bfd): Use srctemplate as the
    	template when calling bfd_create if it does not use the BFD
    	plugin target vector.
    
    (Cherry-picked from commit 4a07dc81356ed8728e204e9aabeb256703c59aef)