Bug 811909

Summary: Linking against mingw32 libbzip2 fails
Product: [Fedora] Fedora Reporter: David Nečas <yeti>
Component: mingw32-bzip2Assignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: amorilia, fedora-mingw, h.peter.anvin, lfarkas, rjones
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-12 19:17:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
possible patch none

Description David Nečas 2012-04-12 09:59:50 UTC
Description of problem:
Linking against the MinGW port of bzip2 fails.  For start, code generated by standard configure tests such as

AC_CHECK_LIB(bz2, BZ2_bzopen, ...)


Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Create the following C code (essentially what configure creates as conftest.c), calling it conftest.c:

char BZ2_bzopen ();
int main ()
return BZ2_bzopen ();
return 0;

2. Run
i686-pc-mingw32-gcc -o conftest.exe -g -O2   conftestc.c -lbz2

Actual results:
/home/yeti/tmp/ccEfyAbq.o: In function `main':
/home/yeti/xxx/conftest.c:5: undefined reference to `_BZ2_bzopen'
collect2: ld returned 1 exit status

Expected results:
It links and creates conftest.exe.

Additional info:
According to i686-pc-mingw32-nm, symbols in libbz2.dll.a bear extensions such as @8, @10, etc., so BZ2_bzopen is there as _BZ2_bzopen@8.

Comment 1 David Nečas 2012-04-12 12:40:30 UTC
Created attachment 577056 [details]
possible patch

A patch is attached that appears to fix the library for me by removing the WINAPI trickery in the header (apparently intended for native Win32).  I do not understand the Win32 stuff enough to say this is the right fix though.

Comment 2 Kevin Kofler 2012-04-12 15:04:59 UTC
That's not the correct solution. It will make the functions use the cdecl calling convention instead of stdcall upstream uses and thus make the bzip2 DLL we ship binary-incompatible with the upstream one.

Renaming the DLL's symbols to remove the default stdcall mangling (those @8 etc. suffixes) is also binary-incompatible.

Comment 3 David Nečas 2012-04-12 16:18:48 UTC
I see.  So does the configure test (and possibly linking) of every cross-compiled program using bzip2 need to be changed and how?  Or are there other options?

Comment 4 H. Peter Anvin, Intel 2012-04-12 16:35:23 UTC
This is a general and very serious braindamage in autoconf: compiling test programs without including the necessary header files does not work in general.  It might have been expected to work that way 20+ years ago, but today it's just broken.

Comment 5 David Nečas 2012-04-12 19:17:16 UTC
So, there is no bug in mingw32-bzip2.  I may still want a cdecl version of it but that not relevant to this bug report.  Thanks for your time.

Comment 6 Fedora Update System 2012-04-25 15:58:13 UTC
mingw-bzip2-1.0.6-1.fc17 has been submitted as an update for Fedora 17.

Comment 7 Fedora Update System 2012-05-04 22:54:54 UTC
mingw-bzip2-1.0.6-1.fc17, mingw-boost-1.48.0-8.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.