Description of problem:
The cross-compilation header /usr/i686-pc-mingw32/sys-root/mingw/include/pthread.h, installed as part of the mingw32-pthreads package, has several coding bugs.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Try cross-compiling any code that uses localtime_r with a second argument with side effects, or try calling (localtime_r)(arg1,arg2).
2. Try cross-compiling any project that uses gnulib's <time.h> replacement header (libvirt is an example project; it includes a ./autobuild.sh script that will automatically try a mingw cross-compilation, if you have installed a mingw portablexdr library, although that library is not yet part of fedora).
The definition of localtime_r is broken, because it evaluates the second argument twice. And, since POSIX allows one to #undef localtime_r, but there is no localtime_r function in the library, you get a link failure if you bypass the function-like macro. Finally, the pthreads-win32 library made the mistake of installing <config.h>, which is asking for namespace collision with most other autotooled packages.
<pthread.h> should not define any *_r functions, nor should it interfere with a proper <time.h>. Also, the library should not install <config.h>, but should instead modify its installed headers to be self-contained.
See this thread on bug-gnulib for more details:
I recently came across this bug when trying to compile libcheck under mingw32, which choked on the localtime_r problem described in comment #1.
Do you happen to know if these issues have been resolved upstream already? There has been activity in upstreams CVS repo to add support for mingw-w64 and possibly other fixes. See http://sourceforge.net/apps/trac/mingw-w64/wiki/Compile%20pthreads for details.
On that link there also are patches to fix the config.h issue which you mentioned. For the new cross compiler framework which I mentioned in your other bugreport (bug 599567) I have those patches already applied.
If you want to test this new version of mingw32-pthreads you can use the testing repository for the new cross compiler framework. Details for that can be found at https://fedoraproject.org/wiki/MinGW/CrossCompilerFramework
(In reply to comment #0)
> Finally, the pthreads-win32 library made the mistake
> of installing <config.h>, which is asking for namespace collision with most
> other autotooled packages.
> Expected results:
> Also, the library should not install <config.h>, but should
> instead modify its installed headers to be self-contained.
I gave a stab at fixing the config.h issue. In rawhide pthreads.h no longer includes config.h and both config.h and its other private headers are no longer installed.
The fix is in mingw32-pthreads-2.8.0-14.fc16
It would also appear that in CVS HEAD localtime_r and other *_r definitions are gone from pthreads.h; perhaps we should consider packaging up a snapshot.
Anyone interested in talking to upstream and asking when they are going to make a new release?
After some discussion with Kalev on IRC I think it's a good idea to update the mingw32-pthreads package in Fedora to the latest CVS version. That way we should also be ready with a compatible version for when mingw-w64 will be introduced in Fedora 16
I just built mingw32-pthreads-2.8.0-15.20110511cvs.fc16 for rawhide, which should fix both the config.h issue by removing the header, and also remove the possibly conflicting localtime_r definition. I did some basic testing, but it would be very awesome if someone else could try it with a real world test case.
Closing the ticket.