gcc supports -fstack-protector-strong since v4.9 only. Add a "poor man's autoconf" test to check whether the option is supported on the given build system. Fixes: 596f51f3 "multipath-tools: Replace -fstack-protector with -fstack-protector-strong" Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- Makefile.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 8361e6c4..3ef134f6 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -69,10 +69,23 @@ RM = rm -f LN = ln -sf INSTALL_PROGRAM = install +# $(call TEST_CC_OPTION,option,fallback) +# Test if the C compiler supports the option. +# Evaluates to "option" if yes, and "fallback" otherwise. +TEST_CC_OPTION = $(shell \ + if $(CC) -o /dev/null -c "$(1)" -xc - <<<'int main(void){return 0;}' &>/dev/null; \ + then \ + echo "$(1)"; \ + else \ + echo "$(2)"; \ + fi) + +STACKPROT = $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) + OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \ -Werror=implicit-function-declaration -Werror=format-security \ -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \ - -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong \ + -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \ --param=ssp-buffer-size=4 CFLAGS = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" -- 2.12.2 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel