From 8fe69a3fb34945f94999bfe6c2d06385cbf0ab19 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Thu, 3 Jan 2019 15:35:59 +0100 Subject: [PATCH] Updated PGO/LTO setup --- firefox.spec | 14 +++++++++----- mozilla-1516081.patch | 38 ++++++++++++++++++++++++++++++++++++++ mozilla-1516803.patch | 16 ++++++++++++++++ pgo.patch | 25 ++++++++++++++++++++++--- 4 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 mozilla-1516081.patch create mode 100644 mozilla-1516803.patch diff --git a/firefox.spec b/firefox.spec index 69b8634..d9fe77d 100644 --- a/firefox.spec +++ b/firefox.spec @@ -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 diff --git a/mozilla-1516081.patch b/mozilla-1516081.patch new file mode 100644 index 0000000..174bbfb --- /dev/null +++ b/mozilla-1516081.patch @@ -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(new Options()); + const PRIntervalTime ticksDuration = PR_MillisecondsToInterval(1000); diff --git a/mozilla-1516803.patch b/mozilla-1516803.patch new file mode 100644 index 0000000..f1f37f4 --- /dev/null +++ b/mozilla-1516803.patch @@ -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() + diff --git a/pgo.patch b/pgo.patch index df18634..20eb98d 100644 --- a/pgo.patch +++ b/pgo.patch @@ -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'):