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

Christian Biesinger via gdb-patches
2019-12-18T18:57:07Z

On Wed, Dec 18, 2019 at 12:44 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > Date: Wed, 18 Dec 2019 12:14:13 -0600
> > From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> > Cc: Christian Biesinger <cbiesinger@google.com>
> >
> > Recent mingw versions require -lssp when using _FORTIFY_SOURCE, which
> > gdb does (in common-defs.h)
> > https://github.com/msys2/MINGW-packages/issues/5868#issuecomment-544107564
> >
> > gdb/ChangeLog:
> >
> > 2019-12-18 Christian Biesinger <cbiesinger@google.com>
> >
> > * configure: Regenerate.
> > * gdbsupport/common.m4: Look for -lssp to fix mingw.
>
> This will produce a GDB binary that requires libssp-0.dll to be
> present to run, won't it? And since libssp-0.dll is part of GCC,
> this will have 2 annoying effects:
>
> . we could be in "DLL hell" if there's an incompatibility between
> libssp against which GDB was linkes and the one actually installed
> on the system where we run GDB;
>
> . if someone wants to distribute MinGW binaries of GDB, they will
> have to distribute the GCC sources as well, since DLLs cannot
> enjoy the libgcc-type exception

That's a good point, I did not think of that.

> Is there a way to link against libssp.a statically? If so, it would
> be better to do that. Failing that, I'd recommend not to define
> _FORTIFY_SOURCE in MinGW builds, because the above annoyances IMO
> outweigh its utility.

Looks like the way to do that would be -Wl,-Bstatic -lssp -Wl,-Bdynamic

However, I'm not sure that all the required autoconf changes are worth
it at this point, and maybe we should just not define _FORTIFY_SOURCE
on mingw? I'll send a patch for that shortly.

Christian