MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

LD linker fails with GCC+LTO+`-Wa,-mbig-obj`

Open OliverSCE opened this issue 6 years ago • 12 comments

Hello,

when compiling and linking with the 64-bit gcc with -flto, the linker failes with: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: release/main.o: plugin needed to handle lto object.

The 32-bit version of the compiler in the same msys2 installation works without this issue.

Win 10, actual msys2, starting shells with mingw64.exe resp. mingw32.exe.

Any idea, where to dig in to solve the problem?

OliverSCE avatar Mar 27 '18 07:03 OliverSCE

Sounds like this problem.

ssbssa avatar Apr 02 '18 15:04 ssbssa

It sounds similar, but unfortunately the proposed solution there does not work.

As this issue seems to be unknown here, there are two options:

a) nobody is using lto with the 64 bit compiler b) my installation has an issue, which is not common

To be sure that b) is the case, can anybody confirm that lto with the 64 bit compiler works?

Oliver

OliverSCE avatar Apr 03 '18 09:04 OliverSCE

64bit with lto works for me, exactly with this solution.

ssbssa avatar Apr 03 '18 10:04 ssbssa

After doing some more trials it is the combination with -Wa,-mbig-obj, which seems to create the problem. Simple test programs work fine with the standard installation (without the bfd-plugins "fix").

google finds this one here: https://bugs.archlinux.org/task/53859

which is apparently the problem, but unfortunatedly it doesn't really help. At least I don't understand the comment.

Any ideas, where to search for more info?

Oliver

OliverSCE avatar Apr 03 '18 18:04 OliverSCE

Is there a solution? I need the -Wa,-mbig-obj because of huge header libraries I use (Eigen and ExprTk) and I'm also in need of LTO because linking with MinGW64 (as of 7.1.0 version) is painfully slow for me (5 minutes for a 5MB EXE).

PauloCarvalhoRJ avatar Aug 25 '18 18:08 PauloCarvalhoRJ

Here is my project in GitHub if it helps: https://github.com/PauloCarvalhoRJ/gammaray . If you try to compile it with MinGW64, you'll see linking takes quite a while for a program that can be considered small by current standards.

PauloCarvalhoRJ avatar Aug 25 '18 21:08 PauloCarvalhoRJ

@OliverSCE Please consider closing this issue if it is already fixed. If not, Please provide a minimal reproducer to test with.

MehdiChinoune avatar Aug 26 '22 06:08 MehdiChinoune

Still open.

echo "int main(){} >test.cpp gcc -O3 -flto test.cpp -Wa,-mbig-obj

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccRnQMhA.o: plugin needed to handle lto object C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function main': C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to WinMain' collect2.exe: error: ld returned 1 exit status

Oliver

OliverSCE avatar Aug 26 '22 17:08 OliverSCE

I have asked for minimal reproducer.

MehdiChinoune avatar Aug 26 '22 17:08 MehdiChinoune

What do you mean? Code quoted in previous post is minimal and reproduces the issue.

mati865 avatar Aug 26 '22 17:08 mati865

What do you mean? Code quoted in previous post is minimal and reproduces the issue.

Sorry, haven't notice.

MehdiChinoune avatar Aug 26 '22 18:08 MehdiChinoune

I just noticed that this is my older issue entry regarding this problem.

To be precise in the answer to the question, if this issue is still open: The issue was actually fixed for gcc 8.x.x - 11.1.0 (which came out after my initial post), but is back in more recent versions still today.

Oliver

OliverSCE avatar Sep 18 '22 08:09 OliverSCE