From 3f8fbc831b7bc3a6cc8422c432f577596b4cf3df Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 2 Mar 2022 12:29:59 -0500 Subject: [PATCH] build-sys: Add probing for -fstack-protector Add probing for -fstack-protector to the existing -fstack-protector-strong since not all platforms support either one of them. Signed-off-by: Stefan Berger --- configure.ac | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 4f7ef9e..3fbdf67 100644 --- a/configure.ac +++ b/configure.ac @@ -284,10 +284,12 @@ AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [Disable hardening flags])) if test "x$enable_hardening" != "xno"; then - # Some versions of gcc fail with -Wstack-protector enabled - TMP="$($CC -fstack-protector-strong $srcdir/include/libtpms/tpm_error.h 2>&1)" - if echo $TMP | $GREP 'unrecognized command line option' >/dev/null; then - HARDENING_CFLAGS="-fstack-protector " + # Some versions of gcc fail with -Wstack-protector, + # some with -Wstack-protector-strong enabled + if ! $CC -fstack-protector-strong $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then + if $CC -fstack-protector $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then + HARDENING_CFLAGS="-fstack-protector " + fi else HARDENING_CFLAGS="-fstack-protector-strong " fi -- 2.39.5