Web lists-archives.com

Re: [Mingw-users] Dependency on libgcc_s_dw2-1.dll




[Please don't take this to private mail.]

> From: John Brown <johnbrown105@xxxxxxxxxxx>
> Date: Thu, 17 Sep 2015 17:29:10 -0400
> 
> I don't understand. Why does gcc care who calls my C-language DLL?

If the DLL you build will throw exceptions, not linking against shared
libgcc will prevent those exceptions from being thrown and caught by
other DLLs.  GCC cannot know whether the applications or DLLs you are
building expect that.

> If my DLL (which neither catches nor throws C++ exceptions)

(I don't think only C++ exceptions are affected.  Windows supports
exceptions in C code as well.)

> is called by a C++ module, then let *that* module link to
> libgcc_s_dw2.dll if it catches or throws exceptions.

You need both the throwing and the catching code to link against the
shared libgcc.

> What specifically causes libgcc_s_dw2-11.dll to be linked?

Some code generated by GCC calls functions in libgcc.  By default, the
MinGW GCC is configured to link in the shared version of libgcc.  You
can see that in the output of "gcc -dumpspecs".

> Merely calling  C functions doesn't cause it.

You need to call a function that requires routines in libgcc.

> > You need to work harder to avoid the dependency, see
> >
> > http://www.mingw.org/wiki/HOWTO_Sneak_GCC_Switches_Past_Libtool
> 
> I don't particularly want to link libgcc statically. My understanding was that it was
> bad for a DLL to link statically to the C runtime because if it is called by a program
> that was built against another C runtime then you could get hard-to-find bugs.

libgcc is NOT the C runtime.  It includes a small number of support
routines that have nothing to do with C runtime.

Moreover, the problems with static linking that you describe can only
happen if you pass objects (like 'FILE *') created by one version of
runtime to a function (like 'fprintf') from another.  This cannot
possibly happen with libgcc, since C programs never actually call
functions from libgcc in their source code, and thus don't access any
values those functions return.

In any case, if you don't want the libgcc DLL dependency, and don't
want to link against libgcc statically, what other options did you
expect to exist?


------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe