This is the mail archive of the mailing list for the pthreas-win32 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Mingw-users] mingw32 DLLs, threads and exceptions HOWTO

Hi Paul,

> TP> It was Franco Bez that pointed me in the right direction, that is
> TP> libgcc.a into a dll.
>     Can you point me to any normal GNU-based system which has shared
> libgcc? If not, I don't think it's valid for win32 either.

Any normal GNU-based system has shared libraries. It is only the main module
that will be linked against libgcc.a. Due to the design of DLLs every DLL
that is compiled with gcc is linked against libgcc.a. Libgcc.a contains
static variables for exception handling. Every module will include these and
make exception handling work only in this module. You must  rewrite
libgcc2.c in a way that all statics are removed and replaced by variables in
shared memory, link only static or find a way to make real shared libs to
make exception handling work as expected.

I do not see any reason why libgcc must always be static. I had never had
any trouble with the gcc.dll. If someone cares about create a compiler
switch to select between static and shared libgcc.

> TP> 1. Include the mingwm10.dll function into the gcc.dll to have only one
> TP> left.
> TP> 2. make -mthreads and -fnative-struct default compiler options.
> TP> 3. convert libstdc++ to a dll by adding the declspec dllexport and
> TP> to every class definition.
>     Alternative proposal:
> 1) Partition libgcc into C and C++ parts (consider generic exception
> handling C++ burden).

Currently all this eh stuff is in libgcc2.c. I don't see any reason to break
this only for win32. Consider that you can have c++ code that does not
require libstdc++. There is no performance penalty if you don't use

The mingwm10 must be build as a dll, because it use features the from
DllMain (thread detach ) to cleanup eh after thread termination (free some
If this would be included in a gcc.dll there is no more need for -mthreads
since exceptions are thread safe by default, and the gcc dll will use the
right get_eh_context call (eh_context_specific).

>     Next gcc package alpha/beta will contain at least 3) (i.e. shared
> libstdc++), of course if I won't find flaw with it, so far I didn't. I
> don't use C++ exception currently, so I'm rather indifferent to 1) and
> 2), if you're interested, your help welcome. Ideally, it should be
> shell script which will produce that libstdc++.dll from static libs
> and/or their object.

I would spend some time to make a shell script that does the libgcc.a to dll
conversion and that will include the mingwm10 code for those who are
If you change your mind about a libgcc.dll i would also take a look at to get a dll by default when gcc is configured
with --enable-threads (or implement a new configure option).
The libstdc++ dll is only nice to have but low on priority.

I would be very interested in getting the latest sources for gcc and
binutils but have not seen any 'till now. Currently i am using Mumits

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]