Hot to test for _FORTIFY_SOURCE with Autoconf
Jeffrey Walton
noloader@gmail.com
Tue Mar 17 22:13:19 GMT 2020
Hi Everyone,
I'm not sure if this is a GCC or Autoconf question. Please point me in
the right direction.
I'm trying to test for availability of _FORTIFY_SOURCE=2. Setting a
CPPFLAG is not enough since the compiler will happily pass it down.
Does the compiler make the information available anywhere?
Here's a small Autoconf test, but I'm not sure how to craft the program.
OLD_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
AC_MSG_CHECKING([for -D_FORTIFY_SOURCE=2])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([int main(void) {return 0;}])],
[AC_MSG_RESULT([yes]); MY_CPPFLAGS="$MY_CPPFLAGS -D_FORTIFY_SOURCE=2"],
[AC_MSG_RESULT([no])]
)
How do I check for _FORTIFY_SOURCE=2?
More information about the Gcc-help
mailing list