From: Andrew Price Date: Thu, 30 Jun 2016 11:55:36 +0100 Subject: [Cluster-devel] [PATCH 2/2] gfs2-utils: Build with -D_FORTIFY_SOURCE=2 In-Reply-To: <1467284136-15380-1-git-send-email-anprice@redhat.com> References: <1467284136-15380-1-git-send-email-anprice@redhat.com> Message-ID: <1467284136-15380-2-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit A survey of popular Linux distros shows that they all compile their packages with _FORTIFY_SOURCE=2 defined so it makes sense to enable it upstream too, in order to fix any issues it highlights before they reach the distros. It will also allow us to factor the overhead it adds into perf measurements. Briefly, using this flag adds buffer overflow detection to some functions, and enables -Wunused-result warnings. It requires the optimization level to be -O1 or higher so it is only added to CPPFLAGS when --enable-debug is not used. Signed-off-by: Andrew Price --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b421fbe..cc49642 100644 --- a/configure.ac +++ b/configure.ac @@ -143,8 +143,10 @@ ENV_LDFLAGS="$LDFLAGS" if test "x${enable_debug}" = xyes; then AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code]) OPT_CFLAGS="-O0" + OPT_CPPFLAGS="" else OPT_CFLAGS="-O2" + OPT_CPPFLAGS="-D_FORTIFY_SOURCE=2" fi # gdb flags @@ -203,7 +205,7 @@ for j in $WARNLIST; do done CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS $EXTRA_WARNINGS $WERROR_CFLAGS" -CPPFLAGS="-I\$(top_builddir)/make -I\$(top_srcdir)/make -I. $ENV_CPPFLAGS" +CPPFLAGS="-I\$(top_builddir)/make -I\$(top_srcdir)/make -I. $ENV_CPPFLAGS $OPT_CPPFLAGS" LDFLAGS="$ENV_LDFLAGS" AC_CONFIG_TESTDIR([tests], [gfs2/libgfs2:gfs2/mkfs:gfs2/fsck:gfs2/edit:gfs2/convert:gfs2/tune:tests]) -- 2.7.4