Bug 1321579 - Add -fno-lifetime-dse when building with GCC >= 5.0. r=froydnj, a=lizzard
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 03 Feb 2017 17:01:17 +0900
changeset 375980 5254b7f0b149e82b04a8d7fd027d4cd92b0c9448
parent 375979 05fac47f4f7da5f34cebaa962e2ab7009776801e
child 375981 e41566424f2fee04c45e0a685ebd3cf41270e52e
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, lizzard
bugs1321579
milestone53.0a2
Bug 1321579 - Add -fno-lifetime-dse when building with GCC >= 5.0. r=froydnj, a=lizzard
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],