emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#15663: closed (_FORTIFY_SOURCE compilation error:


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#15663: closed (_FORTIFY_SOURCE compilation error: Redefinition with GCC 4.7.3 under Gentoo)
Date: Sun, 20 Oct 2013 22:08:02 +0000

Your message dated Sun, 20 Oct 2013 15:06:57 -0700
with message-id <address@hidden>
and subject line Re: bug#15663: _FORTIFY_SOURCE compilation error: Redefinition 
with GCC 4.7.3 under Gentoo
has caused the debbugs.gnu.org bug report #15663,
regarding _FORTIFY_SOURCE compilation error: Redefinition with GCC 4.7.3 under 
Gentoo
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
15663: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15663
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: _FORTIFY_SOURCE compilation error: Redefinition with GCC 4.7.3 under Gentoo Date: Sun, 20 Oct 2013 17:54:51 +1030 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130911 Thunderbird/17.0.9
G'day,

I've been building the latest Git sources for GNU Grep on a Gentoo
system.  Using GCC-4.6.3, the update/reload command:

        git pull ; ./bootstrap ; ./configure ; make ; make check

works fine.  However, if I switch to GCC-4.7.3, the compilation
fails when compiling lib/argmatch.o:

        make  all-am
        make[3]: Entering directory `/home/grep-2.14/grep/lib'
          CC     argmatch.o
        In file included from argmatch.c:22:0:
        ../config.h:72:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
        argmatch.c:1:0: note: this is the location of the previous definition
        cc1: all warnings being treated as errors
        make[3]: *** [argmatch.o] Error 1
        make[3]: Leaving directory `/home/grep-2.14/grep/lib'
        make[2]: *** [all] Error 2

Scrounging around on the 'net a bit, it seems that Debian and others are now
"#defining _FORTIFY_SOURCE 2" as a default preprocessor definition in the
latest releases of gcc, and this has flowed on to the Gentoo 4.7.3 version.
(I haven't checked intervening gcc versions.)

The collision happens because of a rule in configure.ac, where, if __OPTIMIZE__ 
is
defined and is true, then _FORTIFY_SOURCE=2 is defined.  The code injected into
config.h does not expect that an earlier definition is present, and this causes
the conflict:

          AH_VERBATIM([FORTIFY_SOURCE],
          [/* Enable compile-time and run-time bounds-checking, and some 
warnings,
              without upsetting glibc 2.15+. */
           #if defined __OPTIMIZE__ && __OPTIMIZE__
           # define _FORTIFY_SOURCE 2
           #endif
          ])

I can suggest two ways of dealing with this: Either respect any previous 
definition:

           #if defined __OPTIMIZE__ && __OPTIMIZE__ && ! defined _FORTIFY_SOURCE
           # define _FORTIFY_SOURCE 2
           #endif

or, discard any previous directive and enforce fortification regardless:

           #if defined __OPTIMIZE__ && __OPTIMIZE__
           # undef _FORTIFY_SOURCE
           # define _FORTIFY_SOURCE 2
           #endif

It's probably worth sorting this out before releasing 2.15.

cheers,

behoffski (Brenton Hoff)
Programmer, Grouse Software



--- End Message ---
--- Begin Message --- Subject: Re: bug#15663: _FORTIFY_SOURCE compilation error: Redefinition with GCC 4.7.3 under Gentoo Date: Sun, 20 Oct 2013 15:06:57 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0
behoffski wrote:
> I can suggest two ways of dealing with this: Either respect any previous 
> definition:

That's what Emacs does, so I changed 'grep' to do that, as follows.
Thanks for reporting the bug.

>From 15e16023b8318b6eece1325eb2ea9d3fcfbc77ad Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sun, 20 Oct 2013 15:05:14 -0700
Subject: [PATCH] build: port to platforms that predefine _FORTIFY_SOURCE

Problem reported by Brenton Hoff (Bug#15663).
* configure.ac (_FORTIFY_SOURCE): Don't define if already defined.
This is what Emacs does.
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 5c93d04..6ce7237 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,7 +159,7 @@ if test "$gl_gcc_warnings" = yes; then
   AH_VERBATIM([FORTIFY_SOURCE],
   [/* Enable compile-time and run-time bounds-checking, and some warnings,
       without upsetting glibc 2.15+. */
-   #if defined __OPTIMIZE__ && __OPTIMIZE__
+   #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
    # define _FORTIFY_SOURCE 2
    #endif
   ])
-- 
1.8.3.1




--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]