summaryrefslogtreecommitdiff
path: root/gcc/configure.ac
diff options
context:
space:
mode:
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-03 11:48:57 +0000
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-03 11:48:57 +0000
commit605922af1deb447d85c56f66cf39ff08db156fad (patch)
tree8d1ac1de12fbb1cd572e93abe124add449ed32da /gcc/configure.ac
parent6cb66519c3fec915e5377e2b71c87bf65564fd9a (diff)
downloadgcc-605922af1deb447d85c56f66cf39ff08db156fad.tar.gz
gcc/ChangeLog:
* configure.ac: Set aliasing_flags to -fno-strict-aliasing if the host compiler is affected by placement new aliasing bug. * configure: Regenerate. * Makefile.in (ALIASING_FLAGS): New variable. (ALL_CXXFLAGS): Add $(ALIASING_FLAGS). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226499 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/configure.ac')
-rw-r--r--gcc/configure.ac26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/configure.ac b/gcc/configure.ac
index a192ad92129..767e288af2a 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -416,6 +416,32 @@ struct X<long long> { typedef long long t; };
]], [[X<int64_t>::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])])
fi
+# Check whether compiler is affected by placement new aliasing bug (PR 29286).
+# If the host compiler is affected by the bug, and we build with optimization
+# enabled (which happens e.g. when cross-compiling), the pool allocator may
+# get miscompiled. Use -fno-strict-aliasing to work around this problem.
+# Since there is no reliable feature check for the presence of this bug,
+# we simply use a GCC version number check. (This should never trigger for
+# stages 2 or 3 of a native bootstrap.)
+aliasing_flags=
+if test "$GCC" = yes; then
+ saved_CXXFLAGS="$CXXFLAGS"
+
+ # The following test compilation will succeed if and only if $CXX accepts
+ # -fno-strict-aliasing *and* is older than GCC 4.3.
+ CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+ AC_MSG_CHECKING([whether $CXX is affected by placement new aliasing bug])
+ AC_COMPILE_IFELSE([
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#error compiler not affected by placement new aliasing bug
+#endif
+],
+ [AC_MSG_RESULT([yes]); aliasing_flags='-fno-strict-aliasing'],
+ [AC_MSG_RESULT([no])])
+
+ CXXFLAGS="$saved_CXXFLAGS"
+fi
+AC_SUBST(aliasing_flags)