configure: check for hardening compiler options
If no CFLAGS are specified, check if common security hardening options are supported and add them to the CFLAGS/LDFLAGS. These are typically enabled in downstream packages, but users compiling chrony from sources with default CFLAGS should get hardened binaries too.
This commit is contained in:
parent
ccb94ac5fb
commit
1c277a8850
1 changed files with 16 additions and 0 deletions
16
configure
vendored
16
configure
vendored
|
@ -518,6 +518,22 @@ fi
|
|||
|
||||
if [ "x$MYCFLAGS" = "x" ]; then
|
||||
MYCFLAGS="-O2 -g"
|
||||
|
||||
TESTCFLAGS="-D_FORTIFY_SOURCE=2 -fPIE"
|
||||
TESTLDFLAGS="-pie -Wl,-z,relro,-z,now"
|
||||
if test_code 'hardening compiler options' '' "$TESTCFLAGS" "$TESTLDFLAGS" ''; then
|
||||
MYCFLAGS="$MYCFLAGS $TESTCFLAGS"
|
||||
MYLDFLAGS="$MYLDFLAGS $TESTLDFLAGS"
|
||||
fi
|
||||
TESTCFLAGS="-fstack-protector-strong --param=ssp-buffer-size=4"
|
||||
if test_code '-fstack-protector-strong' '' "$TESTCFLAGS" '' ''; then
|
||||
MYCFLAGS="$MYCFLAGS $TESTCFLAGS"
|
||||
else
|
||||
TESTCFLAGS="-fstack-protector --param=ssp-buffer-size=4"
|
||||
if test_code '-fstack-protector' '' "$TESTCFLAGS" '' ''; then
|
||||
MYCFLAGS="$MYCFLAGS $TESTCFLAGS"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$MYCC" = "xgcc" ] || [ "x$MYCC" = "xclang" ]; then
|
||||
|
|
Loading…
Reference in a new issue