build system: enable gcc's stack protection

Implements #1370.
This commit is contained in:
Moritz Bunkus 2015-08-11 15:02:58 +02:00
parent 25d6ac48ce
commit 94eb9af366
3 changed files with 9 additions and 1 deletions

View File

@ -108,6 +108,7 @@ def setup_globals
cflags_common += " #{c(:WNO_INCONSISTENT_MISSING_OVERRIDE)} #{c(:WNO_POTENTIALLY_EVALUATED_EXPRESSION)}"
cflags_common += " #{c(:OPTIMIZATION_CFLAGS)} -D_FILE_OFFSET_BITS=64"
cflags_common += " -DMTX_LOCALE_DIR=\\\"#{c(:localedir)}\\\" -DMTX_PKG_DATA_DIR=\\\"#{c(:pkgdatadir)}\\\" -DMTX_DOC_DIR=\\\"#{c(:docdir)}\\\""
cflags_common += " #{c(:FSTACK_PROTECTOR)}"
cflags_common += " -Ilib/libebml -Ilib/libmatroska" if c?(:EBML_MATROSKA_INTERNAL)
cflags_common += " #{c(:MATROSKA_CFLAGS)} #{c(:EBML_CFLAGS)} #{c(:EXTRA_CFLAGS)} #{c(:DEBUG_CFLAGS)} #{c(:PROFILING_CFLAGS)} #{c(:USER_CPPFLAGS)}"
cflags_common += " -mno-ms-bitfields -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 " if c?(:MINGW)

View File

@ -7,6 +7,7 @@ if test x"$ac_cv_compiler_is_clang" = xyes; then
QUNUSED_ARGUMENTS="-Qunused-arguments"
WNO_SELF_ASSIGN="-Wno-self-assign"
WNO_MISMATCHED_TAGS="-Wno-mismatched-tags"
FSTACK_PROTECTOR=""
ac_save_CXXFLAGS="$CXXFLAGS"
AC_LANG_PUSH(C++)
@ -22,12 +23,17 @@ if test x"$ac_cv_compiler_is_clang" = xyes; then
else
WNO_MAYBE_UNINITIALIZED="-Wno-maybe-uninitialized"
FSTACK_PROTECTOR="-fstack-protector"
if check_version 4.8.0 $ac_cv_gcc_version ; then
if check_version 4.9.0 $ac_cv_gcc_version ; then
FSTACK_PROTECTOR="-fstack-protector-strong"
elif check_version 4.8.0 $ac_cv_gcc_version ; then
WLOGICAL_OP="-Wlogical-op"
fi
fi
AC_SUBST(FSTACK_PROTECTOR)
AC_SUBST(QUNUSED_ARGUMENTS)
AC_SUBST(WNO_SELF_ASSIGN)
AC_SUBST(WNO_MISMATCHED_TAGS)

View File

@ -85,6 +85,7 @@ EBML_MATROSKA_INTERNAL = @EBML_MATROSKA_INTERNAL@
EGREP = @EGREP@
EXTRA_CFLAGS = @EXTRA_CFLAGS@
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
FSTACK_PROTECTOR = @FSTACK_PROTECTOR@
GTEST_TYPE = @GTEST_TYPE@
LDFLAGS_RPATHS = @LDFLAGS_RPATHS@
FLAC_LIBS = @FLAC_LIBS@