Re: [PATCH] Link to -lssp when available (fixes mingw build)

Pedro Alves
2019-12-19T14:19:55Z

On 12/18/19 11:23 PM, Christian Biesinger via gdb-patches wrote:
> On Wed, Dec 18, 2019 at 5:12 PM Eli Zaretskii <eliz@gnu.org> wrote:
>>
>>> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
>>> Date: Wed, 18 Dec 2019 14:40:42 -0600
>>> Cc: gdb-patches <gdb-patches@sourceware.org>a lot of
>>>
>>> BTW -- you mentioned a licensing issue with depending on DLLs. Doesn't
>>> libstdc++ and perhaps others have the same issue? Or does mingw.org
>>> link it statically?
>>
>> libstdc++ and libgcc DLLs indeed have the same problem. Which is why
>> I mentioned the fact that the binary of GDB 9.0.90 produced by the
>> MinGW build had dependencies on these two. I solved that locally by
>> linking with "CXX='g++ -static-libstdc++ -static-libgcc'", but I
>> thought Pedro once said these dependencies shouldn't happen, and I
>> still hope we could understand why they suddenly appeared.
>
> Hm, I wonder why Pedro said that. GDB uses good amounts of the C++
> standard library, so I would totally expect libstdc++ to appear.

There's some confusion going on here. We must certainly link with
libstdc++ somehow. The only question is whether we link to the
dynamic or static version. What I've said in the past is that GDB
inherited the -static-libstdc++ and -static-libgcc from GCC, due to
the shared top level configure:

https://sourceware.org/ml/gdb-patches/2019-07/msg00040.html

Linking with static versions of the runtime is problematic if we also link
with some other library that is itself linked with a different libstdc++.
Multiple versions of libstc++/libgcc in a program is a recipe for disaster,
such as for example C++ exceptions not working properly. Discussions about
this started a few years ago when we switched to C++. E.g.:

https://sourceware.org/ml/gdb-patches/2017-02/msg00705.html

That is why the top level configure was recently changed to avoid the
-static-libstc++/-static-libgcc:

https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00287.html

Note that the patch added a new --with-static-standard-libraries
configure switch which you can use to get back the previous behavior
of linking with the static versions of the standard libraries.

I think a NEWS entry for that switch would be helpful, though.

> I don't really know what libgcc is used for.

libgcc is GCC's low-level runtime library. It's an essential part
of any program compiled by GCC:
https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html

Thanks,
Pedro Alves