public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Hot to test for _FORTIFY_SOURCE with Autoconf
@ 2020-03-17 22:13 Jeffrey Walton
  2020-03-18  0:11 ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Jeffrey Walton @ 2020-03-17 22:13 UTC (permalink / raw)
  To: gcc-help

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-19  0:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 22:13 Hot to test for _FORTIFY_SOURCE with Autoconf Jeffrey Walton
2020-03-18  0:11 ` Jonathan Wakely
2020-03-18  0:16   ` Jeffrey Walton
2020-03-18  0:27     ` Jonathan Wakely
2020-03-18  1:49     ` Martin Sebor
2020-03-18 22:21       ` Jim Wilson
2020-03-18 22:17     ` Jim Wilson
2020-03-19  0:06       ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).