Bug 1321579 - Add -fno-lifetime-dse when building with GCC >= 5.0. r?froydnj draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 03 Feb 2017 17:01:17 +0900
changeset 470145 3d4d15e4018b453b3f2809ac7dc0e6fed498e350
parent 470090 2a51c94218f262a01e95ff10323598c206626947
child 544408 ea90996c4b2517e6f00a24cedf595bd27c196932
push id43953
push userbmo:mh+mozilla@glandium.org
push dateFri, 03 Feb 2017 09:30:08 +0000
reviewersfroydnj
bugs1321579
milestone54.0a1
Bug 1321579 - Add -fno-lifetime-dse when building with GCC >= 5.0. r?froydnj
build/autoconf/compiler-opts.m4
--- a/build/autoconf/compiler-opts.m4
+++ b/build/autoconf/compiler-opts.m4
@@ -173,16 +173,34 @@ AC_SUBST([LD_IS_BFD])
 
 if test "$GNU_CC"; then
     if test -z "$DEVELOPER_OPTIONS"; then
         CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
         CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
     fi
     CFLAGS="$CFLAGS -fno-math-errno"
     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno"
+
+    if test -z "$CLANG_CC"; then
+        case "$CC_VERSION" in
+        4.*)
+            ;;
+        *)
+            # Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko.
+            # Ideally, we'd use -flifetime-dse=1, but that means we'd forcefully
+            # enable it on optimization levels where it would otherwise not be enabled.
+            # So we disable it entirely. But since that would mean inconsistency with
+            # GCC5, which has level 1 depending on optimization level, disable it on
+            # GCC5 as well, because better safe than sorry.
+            # Add it first so that a mozconfig can override by setting CFLAGS/CXXFLAGS.
+            CFLAGS="-fno-lifetime-dse $CFLAGS"
+            CXXFLAGS="-fno-lifetime-dse $CXXFLAGS"
+            ;;
+        esac
+    fi
 fi
 
 dnl ========================================================
 dnl = Identical Code Folding
 dnl ========================================================
 
 MOZ_ARG_DISABLE_BOOL(icf,
 [  --disable-icf          Disable Identical Code Folding],