]> granicus.if.org Git - gc/commitdiff
Fix configure to disable GCC aliasing optimization unless forced to
authorIvan Maidanski <ivmai@mail.ru>
Thu, 15 Dec 2011 13:42:01 +0000 (17:42 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 15 Dec 2011 13:43:34 +0000 (17:43 +0400)
* configure.ac (ac_cv_fno_strict_aliasing): New variable (set to
"skipped" if the client passed "-fstrict-aliasing" option to CFLAGS
else set to "yes" if GCC supports "-fno-strict-aliasing" option,
otherwise set to "no").
* configure.ac (CFLAGS): Append "-fno-strict-aliasing" if
ac_cv_fno_strict_aliasing is "yes" (only if GCC).

configure.ac

index 6778fa423be530306ceae454e5488a838b3f3b88..9e7b9dcc2eb64c436bf8d087d277d8acb585c07d 100644 (file)
@@ -336,6 +336,30 @@ if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
   AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See doc/README.macros.])
 fi
 
+if test "$GCC" == yes; then
+  # Disable aliasing optimization unless forced to.
+  AC_MSG_CHECKING([whether gcc supports -fno-strict-aliasing])
+  ac_cv_fno_strict_aliasing=no
+  for cflag in $CFLAGS; do
+    case "$cflag" in
+      -fstrict-aliasing)
+        # Opposite option already present
+        ac_cv_fno_strict_aliasing=skipped
+        break
+        ;;
+    esac
+  done
+  if test "$ac_cv_fno_strict_aliasing" != skipped; then
+    old_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -fno-strict-aliasing"
+    AC_TRY_COMPILE([],[], [ac_cv_fno_strict_aliasing=yes], [])
+    CFLAGS="$old_CFLAGS"
+    AS_IF([test "$ac_cv_fno_strict_aliasing" = yes],
+          [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
+  fi
+  AC_MSG_RESULT($ac_cv_fno_strict_aliasing)
+fi
+
 case "$host" in
 # While IRIX 6 has libdl for the O32 and N32 ABIs, it's missing for N64
 # and unnecessary everywhere.