configure: Test for _FORTIFY_SOURCE=3 support.
authorMark Wielaard <mark@klomp.org>
Thu, 10 Mar 2022 16:03:36 +0000 (17:03 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 14 Mar 2022 11:55:22 +0000 (12:55 +0100)
commit29859f2e79ef3c650ee9712cae990c6a7f787a7d
tree0b3873885e7842d9282264c9a670c2e2f37b77fc
parent52d72316e0d0274b2d717142601c0fff3a77f0ba
configure: Test for _FORTIFY_SOURCE=3 support.

_FORTIFY_SOURCE=3 adds extra glibc (dynamic) fortification checks
when using GCC 12.

This adds a configure check to see if -D_FORTIFY_SOURCE=3 can be used.
If not, configure will fall back to -D_FORTIFY_SOURCE=2.

On some older glibc versions (glibc 2.17) using -D_FORTIFY_SOURCE=3
provides the same fortification as _FORTIFY_SOURCE=2. On some newer
glibc versions and older GCC (glibc 2.34 amd gcc 11) using
-D_FORTIFY_SOURCE=3 produces a not supported warning (and we fall
back to -D_FORTIFY_SOURCE=2). With newer glibc and newer GCC versions
(glibc 2.35 and gcc 12) -D_FORTIFY_SOURCE=3 will use the newer dynamic
fortification checks.

This patch also makes sure that AC_PROG_CXX is used earlier so that
CXXFLAGS is always setup correctly (even if we then don't use it).
And it outputs both the CFLAGS and CXXFLAGS as used at the end.

Signed-off-by: Mark Wielaard <mark@klomp.org>
ChangeLog
configure.ac