For the Details please see PR65581 in the gcc bugzilla. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65581
Created attachment 8224 [details] Test case including temporaries
I can also reproduce this, would be nice to get some feedback on this.
This is still the case with ld 2.26.51.20151113, any chance of a fix before 2.26 release?
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.
(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.)
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)
(In reply to cvs-commit@gcc.gnu.org from comment #6) > 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) Wasn't this bug fixed with this commit?
(In reply to Hannes Domani from comment #7) > (In reply to cvs-commit@gcc.gnu.org from comment #6) > > 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) > > Wasn't this bug fixed with this commit? Yes, I think that's fixed. At least it doesn't reproduce with newer versions.
I have this issue with ld version 2.35 using binutils from archlinux (https://www.archlinux.org/packages/community/x86_64/mingw-w64-binutils/)