Discussion:
[Bug gdb/23835] New: gdb/common/common-defs.h:71:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
noring at nocrew dot org
2018-10-27 00:29:53 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

Bug ID: 23835
Summary: gdb/common/common-defs.h:71:0: error:
"_FORTIFY_SOURCE" redefined [-Werror]
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: noring at nocrew dot org
Target Milestone: ---

Compilation of GDB (Binutils) on a recent Gentoo

% gcc --version
gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% equery l sys-libs/glibc
* Searching for glibc in sys-libs ...
[IP-] [ ] sys-libs/glibc-2.26-r7:2.2

fails with the following error:

CXX gdb.o
In file included from ../../gdb/defs.h:28:0,
from ../../gdb/gdb.c:19:
../../gdb/common/common-defs.h:71:0: error: "_FORTIFY_SOURCE" redefined
[-Werror]
#define _FORTIFY_SOURCE 2

<built-in>: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:1619: gdb.o] Error 1

This patch is a simple workaround:

--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -67,7 +67,7 @@
optimization is required because _FORTIFY_SOURCE only works when
optimization is enabled. */

-#if defined __OPTIMIZE__ && __OPTIMIZE__ > 0
+#if defined __OPTIMIZE__ && __OPTIMIZE__ > 0 && 0
#define _FORTIFY_SOURCE 2
#endif
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-30 16:04:25 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |sergiodj at redhat dot com
Resolution|--- |WONTFIX

--- Comment #1 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Apparently this is a Gentoo problem. See:

https://bugs.gentoo.org/621036

Gentoo patches their GCC to explicitly define _FORTIFY_SOURCE=2, which causes
problems when the user tries to (re)define it. There's at least one other bug
report here:

https://jira.mongodb.org/browse/SERVER-29982

Because it's a distro bug, I'm closing this bug as WONTFIX. If you still think
this is a GDB bug, feel free to reopen.

Thanks.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-30 21:36:19 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Last reconfirmed| |2018-10-30
Resolution|WONTFIX |---
Ever confirmed|0 |1

--- Comment #2 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Well, one could argue that it's also possible to make GDB more robust in this
scenario. It's just a matter of guarding the definition of _FORTIFY_SOURCE.
I'll submit a patch for it.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-30 16:13:27 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |ASSIGNED
Assignee|unassigned at sourceware dot org |sergiodj at redhat dot com

--- Comment #3 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Patch sent: https://sourceware.org/ml/gdb-patches/2018-10/msg00732.html
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-10-31 21:43:35 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sergio Durigan Junior
<***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=656efb5e2691b2bd29573d9985d20206c47b6927

commit 656efb5e2691b2bd29573d9985d20206c47b6927
Author: Sergio Durigan Junior <***@redhat.com>
Date: Tue Oct 30 17:37:03 2018 -0400

Fix PR gdb/23835: Don't redefine _FORTIFY_SOURCE if it's already defined

Gentoo has a local GCC patch which always defines _FORTIFY_SOURCE=2.
This causes a build problem when building GDB there, because
"common/common-defs.h" also defines _FORTIFY_SOURCE=2:

CXX gdb.o
In file included from ../../gdb/defs.h:28:0,
from ../../gdb/gdb.c:19:
../../gdb/common/common-defs.h:71:0: error: "_FORTIFY_SOURCE" redefined
[-Werror]
#define _FORTIFY_SOURCE 2

<built-in>: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:1619: gdb.o] Error 1

Even though it is questionable whether Gentoo's approach is the
correct one:

https://jira.mongodb.org/browse/SERVER-29982
https://bugs.gentoo.org/621036

it is still possible for GDB to be a bit more robust here and make
sure it just defines _FORTIFY_SOURCE if it hasn't been defined
already. This patch does that.

Tested by rebuilding and making sure the macro was defined.

gdb/ChangeLog:
2018-10-31 Sergio Durigan Junior <***@redhat.com>

PR gdb/23835
* common/common-defs.h: Don't redefine _FORTIFY_SOURCE if it's
already defined.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-31 21:45:02 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23835

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED

--- Comment #5 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
The issue should be fixed now. Please reopen this bug if you still face
problems. Thanks.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...