Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 288212 - sys-libs/zlib-1.2.3-r1 mingw import library not found by -lz
Summary: sys-libs/zlib-1.2.3-r1 mingw import library not found by -lz
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-08 15:08 UTC by spadix
Modified: 2010-04-08 20:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
zlib-1.2.3-mingw-implib.patch (zlib-1.2.3-mingw-implib.patch,214 bytes, patch)
2009-10-08 15:10 UTC, spadix
Details | Diff
zlib-1.2.3-r1.ebuild (zlib-1.2.3-r1.ebuild,2.06 KB, text/plain)
2009-10-08 15:13 UTC, spadix
Details
zlib1.diff (golden vs proposed) (zlib1.diff,984 bytes, patch)
2009-10-09 23:20 UTC, spadix
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description spadix 2009-10-08 15:08:10 UTC
When cross-compiling the library with mingw32, the generated DLL import library uses a non-standard name (libzdll.a), which is not automatically recognized by mingw32-ld.  Subsequently building packages that link against -lz fail to find it.

Of course, I could be missing something else...is no one using this since bug 182903 (initial mingw cross support)?

To reproduce, you need the amazing magic of mingw crossdev and wrappers setup, then just emerge anything that depends on zlib:
# mingw32-emerge sys-libs/zlib media-libs/libpng

zlib emerges fine, but during the linking of libpng I see several warnings from libtool as it decides to skip building the libpng DLL:

*** Warning: linker path does not have real file for library -lz.
...blah blah blah...
*** libtool will only create a static version of it.

Note that the ebuild still appears to succeed, even though it is incomplete (no DLLs produced).  Similarly for other packages I tried that link to -lz

Attaching a patch that fixes things...
Comment 1 spadix 2009-10-08 15:10:20 UTC
Created attachment 206446 [details, diff]
zlib-1.2.3-mingw-implib.patch

Adjust the name of the mingw import library consistent with the default ld/libtool search.
Comment 2 spadix 2009-10-08 15:13:23 UTC
Created attachment 206447 [details]
zlib-1.2.3-r1.ebuild

Adjust the name of the import library consistent with the default ld/libtool search.  I also moved the DLL under bin, where it can be found at runtime (consistent with other packages built in the mingw cross environment).
Comment 3 SpanKY gentoo-dev 2009-10-09 21:34:37 UTC
i really dont know much about creating shared libraries with mingw, so i'm hesitant to add anything that can change the ABI of the dll.  such compatibilities are a nightmare for windows users.
Comment 4 spadix 2009-10-09 23:16:22 UTC
well, i certainly understand that hesitancy :)

i believe that the ABI of the DLL is unaffected by the name of the import library.  as i understand it, this import library is just a static library that stubs out each of the interfaces and manually accomplishes what ld.so does for us automatically in *nix with eg, _dl_runtime_resolve.  by changing the name we only make it easier for ld to find this stub at link time under an expected name - there is no functional impact on either the DLL generated by this package or other binaries linked against it.

i made an attempt to prove this out; attaching a diff showing that the DLL generated by the stock ebuild and the DLL generated by the proposed change differ only in their timestamp
Comment 5 spadix 2009-10-09 23:20:55 UTC
Created attachment 206594 [details, diff]
zlib1.diff (golden vs proposed)

diff showing that the mingw32 cross DLL produced by the current zlib-1.2.3-r1 differs from the proposal only in timestamp, indicating the ABI is unchanged.  generated with these commands:

# PORTDIR_OVERLAY= mingw32-emerge zlib
# ls -l /usr/mingw32/usr/lib/zlib1.dll
-rw-r--r-- 1 root root 78465 Oct  9 18:51 /usr/mingw32/usr/lib/zlib1.dll
# mingw32-objdump -xs /usr/mingw32/usr/lib/zlib1.dll > zlib1-golden.dump

# PORTDIR_OVERLAY='/usr/mingw32/usr/portage' mingw32-emerge zlib
# ls -l /usr/mingw32/usr/bin/zlib1.dll
-rwxr-xr-x 1 root root 78465 Oct  9 18:52 /usr/mingw32/usr/bin/zlib1.dll
# mingw32-objdump -xs /usr/mingw32/usr/bin/zlib1.dll > zlib1-proposed.dump

# diff zlib1-golden.dump zlib1-proposed.dump > zlib1.diff
Comment 6 SpanKY gentoo-dev 2009-10-10 17:01:04 UTC
ok, that works for me.  thanks for the due diligence.

in the future, changes to ebuilds should be posted as diffs so people can quickly review what has changed rather than fetching the new ebuild and doing the diff themselves

changes should be in cvs now:
http://sources.gentoo.org/sys-libs/zlib/zlib-1.2.3-r1.ebuild?r1=1.13&r2=1.14
http://sources.gentoo.org/sys-libs/zlib/files/zlib-1.2.3-mingw-implib.patch?rev=1.1