Bug 1368649 - Default to -O2 when building on Linux without PGO. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 31 May 2017 06:19:38 +0900
changeset 587987 41224b687a4351fd9f5bd2ced998ebfa64131e9c
parent 587906 b138d2f271fdb598bf8a66c2dcb7fe391ca2a96f
child 588118 44a12d582fb21d9632af9a91d6c9c7e295d4e4be
push id61878
push userbmo:mh+mozilla@glandium.org
push dateFri, 02 Jun 2017 01:31:10 +0000
reviewersgps
bugs1368649
milestone55.0a1
Bug 1368649 - Default to -O2 when building on Linux without PGO. r?gps -Os generates smaller code, at the expense of performance. On desktop, this tradeoff is not necessarily the best, especially when considering the vast performance difference. Most downstream redistributors also don't do PGO and don't override defaults, so they would tend to ship slower builds as a consequence. We however keep -Os as default for debug builds for now, because -O2 triggers -Werror=strict-overflow failures somehow.
build/moz.configure/warnings.configure
old-configure.in
--- a/build/moz.configure/warnings.configure
+++ b/build/moz.configure/warnings.configure
@@ -93,18 +93,18 @@ check_and_add_gcc_warning('-Wno-error=ma
 check_and_add_gcc_warning('-Wno-error=deprecated-declarations')
 
 # false positives depending on optimization
 check_and_add_gcc_warning('-Wno-error=array-bounds')
 
 # can't get rid of those PGO warnings
 check_and_add_gcc_warning('-Wno-error=coverage-mismatch', when='MOZ_PGO')
 
-# false positives during PGO
-check_and_add_gcc_warning('-Wno-error=free-nonheap-object', when='MOZ_PGO')
+# false positives depending on optimizations
+check_and_add_gcc_warning('-Wno-error=free-nonheap-object')
 
 # catches format/argument mismatches with printf
 check_and_add_gcc_warning('-Wformat')
 
 # We use mix of both POSIX and Win32 printf format across the tree, so format
 # warnings are useless on mingw.
 check_and_add_gcc_warning('-Wno-format',
                           when=depends(target)(lambda t: t.kernel == 'WINNT'))
--- a/old-configure.in
+++ b/old-configure.in
@@ -883,17 +883,21 @@ case "$target" in
     if test -z "$CLANG_CC"; then
        MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
     fi
     ;;
 
 *-*linux*)
     if test "$GNU_CC" -o "$GNU_CXX"; then
         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
-        MOZ_OPTIMIZE_FLAGS="-Os"
+        if test -n "$MOZ_DEBUG"; then
+            MOZ_OPTIMIZE_FLAGS="-Os"
+        else
+            MOZ_OPTIMIZE_FLAGS="-O2"
+        fi
         if test -z "$CLANG_CC"; then
            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
         fi
     fi
 
     case "${target_cpu}" in
     alpha*)
         CFLAGS="$CFLAGS -mieee"