From 9d4c4d4f7961768b16104ed306ae81c0e1f3b1b8 Mon Sep 17 00:00:00 2001 From: Benjamin Kaduk Date: Thu, 20 Aug 2015 13:55:02 -0400 Subject: [PATCH] Make setting of CFLAGS_NOSTRICT make sense Previously, we would set -fno-strict-aliasing only when --enable-checking was given to configure but not --enable-checking=all. The intent seems to have been to only warn about strict aliasing violations when --enable-checking=all is in use, but that there was no need to disable the strict-aliasing diagnostics when -Werror was not enabled. Unfortunately, -fno-strict-aliasing affects not only the diagnostics emitted by the compiler, but also the code generation! So we were leaving the normal (no --enable-checking) case with the compiler assuming C's strict aliasing rules. The OpenAFS codebase has historically not been strict-aliasing safe (for example, commit 15e8678661ec49f5eac3954defad84c06b3e0164 refers to a runtime crash using a certain compiler version, which is diagnosed as the compiler using the C strict aliasing rules to make optimizations that exposed the invalid program code. To avoid futher surprises due to new compiler optimizations that utilize the C strict aliasing rules, always disable strict aliasing except when --enable-checking=all is used. Reviewed-on: https://gerrit.openafs.org/11988 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 687b4d8af07dbcf187dea685e75b420884727efd) Change-Id: I03b64465a29243f2b4fdaa12e962f078c45ae344 Reviewed-on: https://gerrit.openafs.org/12308 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- src/cf/osconf.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 29bc00836..6450d8a22 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -796,7 +796,7 @@ else fi CFLAGS_NOERROR= -CFLAGS_NOSTRICT= +CFLAGS_NOSTRICT=-fno-strict-aliasing CFLAGS_NOUNUSED= CFLAGS_NOOLDSTYLE= @@ -808,10 +808,11 @@ if test "x$GCC" = "xyes"; then XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith" if test "x$enable_checking" != "xall"; then CFLAGS_NOERROR="-Wno-error" - CFLAGS_NOSTRICT="-fno-strict-aliasing" CFLAGS_NOUNUSED="-Wno-unused" CFLAGS_NOOLDSTYLE="-Wno-old-style-definition" AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode]) + else + CFLAGS_NOSTRICT= fi fi fi -- 2.39.5