Updated PGO/LTO setup

This commit is contained in:
Martin Stransky 2019-01-03 15:35:59 +01:00
parent 6cd2d4351d
commit 8fe69a3fb3
4 changed files with 85 additions and 8 deletions

View File

@ -77,7 +77,6 @@ ExcludeArch: armv7hl
Summary: Mozilla Firefox Web browser
Name: firefox
Version: 64.0
Release: 5%{?pre_tag}%{?dist}
URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+
@ -149,7 +148,10 @@ Patch586: firefox-wayland-crash-mozbz1507475.patch
# Debian patches
Patch500: mozilla-440908.patch
Patch501: pgo.patch
# PGO/LTO patches
Patch600: pgo.patch
Patch601: mozilla-1516081.patch
Patch602: mozilla-1516803.patch
%if %{?system_nss}
BuildRequires: pkgconfig(nspr) >= %{nspr_version}
@ -356,8 +358,10 @@ This package contains results of tests executed during build.
%patch585 -p1 -b .mozbz1507475
%patch586 -p1 -b .crash-mozbz1507475
%patch501 -p1 -b .pgo
# PGO patches
%patch600 -p1 -b .pgo
%patch601 -p1 -b .1516081
%patch602 -p1 -b .1516803
%{__rm} -f .mozconfig
%{__cp} %{SOURCE10} .mozconfig
@ -553,7 +557,7 @@ export MOZ_MAKE_FLAGS="$MOZ_SMP_FLAGS"
export MOZ_SERVICES_SYNC="1"
export STRIP=/bin/true
%if 0%{?build_with_pgo}
xvfb-run ./mach build
GDK_BACKEND=x11 xvfb-run ./mach build
%else
./mach build
%endif

38
mozilla-1516081.patch Normal file
View File

@ -0,0 +1,38 @@
diff -up firefox-64.0/build/moz.configure/toolchain.configure.1516081 firefox-64.0/build/moz.configure/toolchain.configure
--- firefox-64.0/build/moz.configure/toolchain.configure.1516081 2018-12-07 03:56:20.000000000 +0100
+++ firefox-64.0/build/moz.configure/toolchain.configure 2019-01-03 15:30:08.207368056 +0100
@@ -1304,7 +1304,7 @@ def pgo_flags(compiler, build_env, targe
if compiler.type == 'gcc':
return namespace(
- gen_cflags=['-fprofile-generate'],
+ gen_cflags=['-fprofile-generate', '-DMOZ_PROFILE_INSTRUMENTATION'],
gen_ldflags=['-fprofile-generate'],
use_cflags=['-fprofile-use', '-fprofile-correction',
'-Wcoverage-mismatch'],
@@ -1325,7 +1325,8 @@ def pgo_flags(compiler, build_env, targe
if gen_ldflags:
return namespace(
- gen_cflags=['-fprofile-instr-generate'],
+ gen_cflags=['-fprofile-instr-generate',
+ '-DMOZ_PROFILE_INSTRUMENTATION'],
gen_ldflags=gen_ldflags,
use_cflags=['-fprofile-instr-use=%s' % profdata,
'-Wno-error=profile-instr-out-of-date',
diff -up firefox-64.0/toolkit/components/terminator/nsTerminator.cpp.1516081 firefox-64.0/toolkit/components/terminator/nsTerminator.cpp
--- firefox-64.0/toolkit/components/terminator/nsTerminator.cpp.1516081 2019-01-03 15:30:08.207368056 +0100
+++ firefox-64.0/toolkit/components/terminator/nsTerminator.cpp 2019-01-03 15:31:33.445034029 +0100
@@ -441,6 +441,12 @@ nsTerminator::StartWatchdog()
}
}
# endif
+ // Disable watchdog for PGO train builds - writting profile information at
+ // exit may take time and it is better to make build hang rather than
+ // silently produce poorly performing binary.
+#ifdef MOZ_PROFILE_INSTRUMENTATION
+ crashAfterMS = INT32_MAX;
+#endif
UniquePtr<Options> options(new Options());
const PRIntervalTime ticksDuration = PR_MillisecondsToInterval(1000);

16
mozilla-1516803.patch Normal file
View File

@ -0,0 +1,16 @@
diff --git a/security/sandbox/linux/moz.build b/security/sandbox/linux/moz.build
--- a/security/sandbox/linux/moz.build
+++ b/security/sandbox/linux/moz.build
@@ -99,9 +99,8 @@
# gcc lto likes to put the top level asm in syscall.cc in a different partition
# from the function using it which breaks the build. Work around that by
# forcing there to be only one partition.
-for f in CONFIG['OS_CXXFLAGS']:
- if f.startswith('-flto') and CONFIG['CC_TYPE'] != 'clang':
- LDFLAGS += ['--param lto-partitions=1']
+if CONFIG['CC_TYPE'] != 'clang':
+ LDFLAGS += ['--param', 'lto-partitions=1']
DEFINES['NS_NO_XPCOM'] = True
DisableStlWrapping()

View File

@ -1,6 +1,25 @@
diff -up firefox-64.0/extensions/spellcheck/src/moz.build.old firefox-64.0/extensions/spellcheck/src/moz.build
--- firefox-64.0/extensions/spellcheck/src/moz.build.old 2018-12-20 12:23:16.103206546 +0100
+++ firefox-64.0/extensions/spellcheck/src/moz.build 2018-12-20 12:23:44.077140279 +0100
diff -up firefox-64.0/build/unix/mozconfig.unix.pgo firefox-64.0/build/unix/mozconfig.unix
--- firefox-64.0/build/unix/mozconfig.unix.pgo 2019-01-03 15:23:16.792980384 +0100
+++ firefox-64.0/build/unix/mozconfig.unix 2019-01-03 15:24:29.978693550 +0100
@@ -6,6 +6,15 @@ if [ -n "$FORCE_GCC" ]; then
CC="$TOOLTOOL_DIR/gcc/bin/gcc"
CXX="$TOOLTOOL_DIR/gcc/bin/g++"
+ if [ -n "$MOZ_PGO" ]; then
+ if [ -z "$USE_ARTIFACT" ]; then
+ ac_add_options --enable-lto
+ fi
+ export AR="$topsrcdir/gcc/bin/gcc-ar"
+ export NM="$topsrcdir/gcc/bin/gcc-nm"
+ export RANLIB="$topsrcdir/gcc/bin/gcc-ranlib"
+ fi
+
# We want to make sure we use binutils and other binaries in the tooltool
# package.
mk_add_options "export PATH=$TOOLTOOL_DIR/gcc/bin:$PATH"
diff -up firefox-64.0/extensions/spellcheck/src/moz.build.pgo firefox-64.0/extensions/spellcheck/src/moz.build
--- firefox-64.0/extensions/spellcheck/src/moz.build.pgo 2018-12-07 03:56:27.000000000 +0100
+++ firefox-64.0/extensions/spellcheck/src/moz.build 2019-01-03 15:21:32.793385074 +0100
@@ -28,3 +28,5 @@ EXPORTS.mozilla += [
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):