[GRASS-dev] [GRASS GIS] #2916: configure bug (?): FORTIFY_SOURCE in CPPFLAGS breaks configure on Arch Linux
GRASS GIS
trac at osgeo.org
Wed Feb 17 10:20:19 PST 2016
#2916: configure bug (?): FORTIFY_SOURCE in CPPFLAGS breaks configure on Arch
Linux
------------------------+-------------------------
Reporter: msieczka | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.4
Component: Compiling | Version: 7.0.3
Resolution: | Keywords:
CPU: All | Platform: Linux
------------------------+-------------------------
Comment (by glynn):
Replying to [comment:10 msieczka]:
> Thanks for the explanation. Do you know why this "_FORTIFY_SOURCE
requires compiling with optimization (-O)" warning is triggered? I think
it shouldn't be, because I do have optimization enabled in my build
environment:
Optimisation switches are normally in CFLAGS or CXXFLAGS, while -D
switches are normally in CPPFLAGS. The configure checks for the
preprocessor don't pass $(CFLAGS) or $(CXXFLAGS) because most of the
switches that they're likely to contain often aren't recognised by a
standalone preprocessor, and may result in an error. The comment in
autoconf/c.m4 says:
{{{
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
}}}
Apart from that, there are valid reasons for compiling without
optimisation (e.g. it often makes debugging significantly more difficult),
so forcibly enabling _FORTIFY_SOURCE doesn't appear to have been a
particularly wise move.
FWIW, on Gentoo this is implemented within the compiler:
{{{
$ gcc -E -dM -O2 -x c /dev/null | fgrep FORTIFY
#define _FORTIFY_SOURCE ((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 :
0)
}}}
I.e. _FORTIFY_SOURCE is enabled automatically if and only if optimisation
is enabled.
As for workarounds, the simplest to implement would be to have
configure.in check whether $(CPPFLAGS) contains -D_FORTIFY_SOURCE and
either attempt to remove it or generate an error telling the user to
remove it. It can always be added to CFLAGS and/or CXXFLAGS.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2916#comment:11>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list