This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2] Don't define _FORTIFY_SOURCE on mingw
- From: "Christian Biesinger via gdb-patches" <gdb-patches at sourceware dot org>
- To: gdb-patches at sourceware dot org
- Cc: Christian Biesinger <cbiesinger at google dot com>
- Date: Wed, 18 Dec 2019 13:07:05 -0600
- Subject: [PATCH v2] Don't define _FORTIFY_SOURCE on mingw
- References: <CAPTJ0XHS3mhnBzUmN0X1wJZMH69V_aQQPH7Trxf9TnQMfgH0ng@mail.gmail.com>
- Reply-to: Christian Biesinger <cbiesinger at google dot 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
To avoid all the complications with checking for -lssp and making sure it's
linked statically, just don't define it.
gdb/ChangeLog:
2019-12-18 Christian Biesinger <cbiesinger@google.com>
* gdbsupport/common-defs.h: Don't define _FORTIFY_SOURCE on mingw.
Change-Id: Ide6870ab57198219a2ef78bc675768a789ca2b1d
---
gdb/gdbsupport/common-defs.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbsupport/common-defs.h b/gdb/gdbsupport/common-defs.h
index 203bd8972d..53ce3c96ea 100644
--- a/gdb/gdbsupport/common-defs.h
+++ b/gdb/gdbsupport/common-defs.h
@@ -66,9 +66,13 @@
plus this seems like a reasonable safety measure. The check for
optimization is required because _FORTIFY_SOURCE only works when
optimization is enabled. If _FORTIFY_SOURCE is already defined,
- then we don't do anything. */
+ then we don't do anything. Also, on mingw, fortify requires
+ linking to -lssp, and to avoid the hassle of checking for
+ that and linking to it statically, we just don't define
+ _FORTIFY_SOURCE there. */
-#if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
+#if (!defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0 \
+ && !defined(__MINGW32__))
#define _FORTIFY_SOURCE 2
#endif
--
2.24.1.735.g03f4e72817-goog