From 2606d6a50cdcd4971b226fd06d58ef31f44b83cb Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Tue, 27 Jun 2023 21:23:28 +0200 Subject: [PATCH] PGO build fixes --- firefox.spec | 17 ++++++++++++----- mozilla-1516803.patch | 15 --------------- pgo.patch | 11 ----------- 3 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 mozilla-1516803.patch diff --git a/firefox.spec b/firefox.spec index dc01d45..b5f491e 100644 --- a/firefox.spec +++ b/firefox.spec @@ -61,7 +61,9 @@ ExcludeArch: ppc64le %global system_libvpx 0 %global system_jpeg 1 %global system_pixman 1 -%global use_bundled_cbindgen 1 +# Bundled cbindgen makes build slow. +# Enable only if system cbindgen is not available. +%global use_bundled_cbindgen 0 %if %{debug_build} %global release_build 0 %endif @@ -234,7 +236,6 @@ Patch407: mozilla-1667096.patch # PGO/LTO patches Patch600: pgo.patch -Patch602: mozilla-1516803.patch Patch603: firefox-gcc-always-inline.patch # tentative patch for RUSTFLAGS parsing issue: @@ -508,7 +509,6 @@ This package contains results of tests executed during build. %if %{build_with_pgo} %if !%{build_with_clang} %patch600 -p1 -b .pgo -%patch602 -p1 -b .1516803 %endif %endif %patch603 -p1 -b .inline @@ -625,7 +625,8 @@ chmod a-x third_party/rust/ash/src/extensions/nv/*.rs %build # Disable LTO to work around rhbz#1883904 -%define _lto_cflags %{nil} +# Is that already fixed? +# %define _lto_cflags %{nil} %if 0%{?use_bundled_cbindgen} mkdir -p my_rust_vendor @@ -643,6 +644,8 @@ EOL env CARGO_HOME=.cargo cargo install cbindgen export PATH=`pwd`/.cargo/bin:$PATH cd - +%else +export CBINDGEN=/usr/bin/cbindgen %endif mkdir %{_buildrootdir}/bin || : @@ -707,9 +710,13 @@ echo "export NM=\"gcc-nm\"" >> .mozconfig echo "export RANLIB=\"gcc-ranlib\"" >> .mozconfig %endif %if 0%{?build_with_pgo} -echo "ac_add_options MOZ_PGO=1" >> .mozconfig # PGO build doesn't work with ccache export CCACHE_DISABLE=1 +export GCOV_PREFIX=`pwd -P`/objdir +export GCOV_PREFIX_STRIP=$(( $(echo `pwd -P`|tr -c -d '/' |wc -c )+2 )) +env | grep GCOV +echo "ac_add_options --enable-lto" >> .mozconfig +echo "ac_add_options MOZ_PGO=1" >> .mozconfig %endif # Require 2 GB of RAM per CPU core diff --git a/mozilla-1516803.patch b/mozilla-1516803.patch deleted file mode 100644 index 30d1fdf..0000000 --- a/mozilla-1516803.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff -up firefox-84.0/security/sandbox/linux/moz.build.1516803 firefox-84.0/security/sandbox/linux/moz.build ---- firefox-84.0/security/sandbox/linux/moz.build.1516803 2020-12-10 16:17:55.425139545 +0100 -+++ firefox-84.0/security/sandbox/linux/moz.build 2020-12-10 16:29:21.945860841 +0100 -@@ -114,9 +114,8 @@ if CONFIG["CC_TYPE"] in ("clang", "gcc") - # 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 ac3694e..cae0648 100644 --- a/pgo.patch +++ b/pgo.patch @@ -59,17 +59,6 @@ diff -up firefox-112.0/build/pgo/profileserver.py.pgo firefox-112.0/build/pgo/pr with TemporaryDirectory() as profilePath: # TODO: refactor this into mozprofile -@@ -213,6 +226,10 @@ if __name__ == "__main__": - print("Firefox exited successfully, but produced a crashreport") - sys.exit(1) - -+ print('Copying profile data....') -+ os.system('pwd'); -+ os.system('tar cf profdata.tar.gz `find . -name "*.gcda"`; cd ..; tar xf instrumented/profdata.tar.gz;'); -+ - llvm_profdata = env.get("LLVM_PROFDATA") - if llvm_profdata: - profraw_files = glob.glob("*.profraw") diff -up firefox-112.0/build/unix/mozconfig.unix.pgo firefox-112.0/build/unix/mozconfig.unix --- firefox-112.0/build/unix/mozconfig.unix.pgo 2023-04-06 21:27:32.537089073 +0200 +++ firefox-112.0/build/unix/mozconfig.unix 2023-04-06 21:28:54.987949124 +0200