[gthr.h] : Fix PR libstdc++/52300 Gthreads functions linking error at dynamic linking with libstdc++ when using MinGW.

Submitted by Kai Tietz on Feb. 20, 2012, 8:14 p.m.

Details

Message ID CAEwic4bhLSyUK8Bc22hPsLk5qtDg2DbJ1tR-Zn7y6rYZdA0UFQ@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Feb. 20, 2012, 8:14 p.m.
Hi,

this patch fixes for mingw target gthread-linking issues about
weak-symbols.  The issue is that pe-coff's weak support is partial
present, but it isn't fully compatible to ELF-version.  For static
libraries it works in this case equivalent, but for shared (DLL)
version it doesn't.  Therefore it makes sense to disable in gthread
the use of WEAK.
This patch fixes libstdc++ and OpenMP issues we recognized using
POSIX-threading API.

ChangeLog libgcc/

2012-02-20  Kai Tietz  <ktietz@redhat.com>

        PR libstdc++/52300
       * gthr.h (GTHREAD_USE_WEAK): Define as zero for mingw.

Tested for i686-w64-mingw32, x86_64-w64-mingw32, and regression-tested
for x86_64-unkown-linux-gnu.  Ok for apply?

Regards,
Kai

Comments

Richard Henderson Feb. 20, 2012, 8:59 p.m.
On 02/20/12 12:14, Kai Tietz wrote:
> 2012-02-20  Kai Tietz  <ktietz@redhat.com>
> 
>         PR libstdc++/52300
>        * gthr.h (GTHREAD_USE_WEAK): Define as zero for mingw.

Ok.


r~
Richard Guenther Feb. 21, 2012, 9:22 a.m.
On Mon, Feb 20, 2012 at 9:59 PM, Richard Henderson <rth@redhat.com> wrote:
> On 02/20/12 12:14, Kai Tietz wrote:
>> 2012-02-20  Kai Tietz  <ktietz@redhat.com>
>>
>>         PR libstdc++/52300
>>        * gthr.h (GTHREAD_USE_WEAK): Define as zero for mingw.
>
> Ok.

It looks like this belongs in some config/gthr-mingw.h file instead, see
confit/gthr-lynx.h.

Richard.

>
> r~

Patch hide | download patch | download mbox

Index: gthr.h
===================================================================
--- gthr.h      (revision 184333)
+++ gthr.h      (working copy)
@@ -135,6 +135,14 @@ 
 */

 #if SUPPORTS_WEAK
+/* The pe-coff weak support isn't fully compatible to ELF's weak.
+   For static libraries it might would work, but as we need to deal
+   with shared versions too, we disable it for mingw-targets.  */
+#ifdef __MINGW32__
+#undef GTHREAD_USE_WEAK
+#define GTHREAD_USE_WEAK 0
+#endif
+
 #ifndef GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 1
 #endif