New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[binutils] internal error aborting #15469
Comments
The exact steps to reproduce the issue would be helpful. |
I'm sorry being so concise. I'm building the application using a IDE. This is its output: Despite it reports 0 errors, the exe file is not generated.
|
Let me add that ffmpeg and cef libraries are updated, build and maintained as local in Msys2 by myself. Those have worked for years in this project with zero issues. |
I confirm there is a regression with mingw-w64-x86_64-binutils==2.40-1 Steps to reproduce from mingw64 installed from msys2-x86_64-20230127.exe installer:
errors out with
Downgrading to mingw-w64-x86_64-binutils==2.39.2 makes things work again This is the "minimum" reproducer I managed to get with GDAL. I also get a similar error when linking the libgdal-32.dll itself on a more feature full build, as can been seen in the log of https://github.com/OSGeo/gdal/actions/runs/4093595228/jobs/7059529472 Wondering if there's a relationship with upstream bug https://sourceware.org/bugzilla/show_bug.cgi?id=30079 although that one is about Debian's binutils-mingw-w64-x86-64 2.39.90.20230110-1+10.3 |
@rouault In your case, the program is trying to link with
In that upstream issue, author also provided a import library which also looks different than binutils generated import library. I can not recall the exact name right now. If you open any libXYZ.dll.a the format looks different between binutils and clang/msvc. |
@Biswa96 The key to reproduce the issue is apparently to link against a .lib not built with mingw64. This can be python39.lib from conda-forge, or the C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/SDK/Lib/x64/msodbcsql17.lib library from Microsoft ODBC Driver 17 for SQL Server (to be installed with https://go.microsoft.com/fwlink/?linkid=2223304 and then select the "ODBC driver for SQL Server SDK" optional component during installation) Failed job https://github.com/rouault/gdal/actions/runs/4096319505/jobs/7063871277 links against msodbcsql17.lib (no Python involved during the linking phase, and this job would only use the one from mingw64), whereas successful job https://github.com/rouault/gdal/actions/runs/4096322267/jobs/7063875659 does not link against it (cf rouault/gdal@7c2c620 for the difference between the 2 job which is the disabling of linking against msodbcsql17.lib) I can also reproduce this locally in my Windows VM with (after installing msodbcsql17.lib as detailed above):
leads to
On the previous configured build, downgrading to binutils 2.39-2 and rebuilding leads to a successful build:
Or keeping 2.40-1 but configuring cmake with -DOGR_ENABLE_DRIVER_MSSQLSPATIAL=OFF to ignore msodbcsql17.lib |
It is not a supported case. I am not familiar with the internals of binutils. I have talked with other developers. The gist is that the primary supported library format is different in binutils. That is, binutils does not properly handle new library format (here .lib ones) since many versions. If you want to link with that .lib file clang would be better choice now. But I agree this is clearly an issue. And using binutils generated import library workarounds the issue. |
By reading your comments on the cause of the issue I've finally been able to compile my app circumventing the canonical .lib linkage I've used for years by linking directly to its associated .dll. In any case I consider this a major issue because I reckon there must be a zillion users having .lib import libraries in their linking stage. As of today this issue is already been treated as a bug in Sourceware's Bugzilla: Thanks a lot you for your hints and support. |
I've bisected it, see https://sourceware.org/bugzilla/show_bug.cgi?id=30079#c1 |
A potential fix is in the repo, please try again now. |
It works with .lib files again. Thank you very much, Lazka. |
I confirm this also fixes the linking issue of GDAL against msodbcsql17.lib |
ok, thanks everyone for figuring this out and testing etc. |
Thanks a lot for fixing it! It was failing my build today. |
This statement gives the wrong picture IMO - the word "supported" has many different possible interpretations. Yes, binutils uses a different import library format normally, and binutils' native format is the one that does get most testing. But binutils does contain some amount of code to handle linking against the MSVC (and LLVM) style import libraries. There have been multiple issues with this mode throughout the years - but effort has been spent on making it work better. Last I checked (before this regression - thanks @lazka for handling it! I just started looking into it, when I see that you've already handled it!) it worked for most of the common cases. Bugs/regressions withstanding, the only missing feature I'm aware of, is handling of weak aliases. These aren't usually used in normal import libraries for user DLLs, but are heavily used in mingw-w64-crt. So binutils should be able to handle linking against third party DLLs with MSVC-style import libraries, but it doesn't work entirely on top of a mingw-w64 sysroot built with LLVM (i.e. the clang64 environment in msys2). So, is this "supported"? I guess that depends on your definition of the word supported. Less tested, for sure - but since there actually has been effort to improve things (e.g. bminor/binutils-gdb@b53b12c and bminor/binutils-gdb@46bbc1c), I think it's important to give the right picture. The remaining barrier between "hopefully works" and "actually works in practice" is real world usage and track record of it. And we won't get that by just discouraging usage. |
In Binutils 2.40, there is a regression that ld fails with MSVC lib files. Add a patch to fix it. [1] msys2/MINGW-packages#15469 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=30079
In Binutils 2.40, there is a regression that ld fails with MSVC lib files. Add a patch to fix it. Closes #59. [1] msys2/MINGW-packages#15469 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=30079
There is a bug in ld.exe as supplied by mingw workaround is to copy .dll but not .lib file to a place where ld will see it. msys2/MINGW-packages#15469
There appears to be an issue in the current version of ld.exe: msys2/MINGW-packages#15469 Changed the linking instructions to move Netica.dll to the source directory without the .lib
Description / Steps to reproduce the issue
Error occurs building a rather complex application linking to ffmpeg, cef, sdl2, ssp libraries.
This error happened overnight, just after updating packages with pacman. I update Msys2 on a almost daily basis.
The code is exactly the same that linked correctly a few days ago, before the pacman update.
Expected behavior
Linkage expected to finish and .exe being generated.
Actual behavior
This errors appears and build stops:
C:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section
C:/Msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: please report this bug
collect2.exe: error: ld returned 1 exit status
Verification
Windows Version
MINGW64_NT-10.0-19045
MINGW environments affected
Are you willing to submit a PR?
No response
The text was updated successfully, but these errors were encountered: