|
Sources Bugzilla – Full Text Bug Listing |
| Summary: | Crash with dlltool geneated import *.libs in MSVC++ Release target (Debug OK) | ||
|---|---|---|---|
| Product: | binutils | Reporter: | Francesco Pretto <ceztko> |
| Component: | binutils | Assignee: | unassigned |
| Status: | NEW --- | ||
| Severity: | normal | CC: | martin |
| Priority: | P2 | ||
| Version: | 2.20 | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Last reconfirmed: | ||
| Attachments: | Minimal test case | ||
|
Description
Francesco Pretto
2011-04-02 16:45:18 UTC
Adding the /OPT:NOREF option to the Release target sorts the problem. The option can be found in project Properties -> Configuration Properties -> Linker -> Optimization -> References -> Keep Unreferenced Data (/OPT:NOREF). It appears that /OPT:NOREF is the default in the Debug target. This would explain why the dlltool generated libs work in Debug target with default options. In Release target the default is /OPT:REF . It still seems a dlltool problem because lib.exe (from the Visual Studio tools) is indeed able to produce *.libs that work correctly in both Debug and Release with (with Eliminate Unreferenced Data /OPT:REF enabled). Created attachment 5700 [details]
Minimal test case
Here's an attached quite minimal testcase for this issue.
The makefile builds a tiny DLL using mingw/gcc, and generates an import
library, both using --out-implib with ld and using dlltool. Then the makefile
builds two test exes that links to the created import libraries - both exes run
just fine on windows.
The batch script msvc.bat builds the same test exes using the MSVC command line
tools, both with and without the /OPT:REF flag, against both of the created
import libraries. The ones built with /OPT:NOREF work fine, while the ones
built with /OPT:REF fail.
For comparison, it also creates an import library from the .def file using
lib.exe, and links against it. For the exes built against this import library,
both versions work.
For what it's worth, it seems that this issue has been fixed in the MSVC 2012 linker - there binaries linked with /OPT:REF against dlltool-produced import libraries seem to work just fine. |