firefox/pgo.patch

108 lines
4.9 KiB
Diff
Raw Normal View History

2023-04-11 10:57:42 +00:00
diff -up firefox-112.0/build/moz.configure/lto-pgo.configure.pgo firefox-112.0/build/moz.configure/lto-pgo.configure
--- firefox-112.0/build/moz.configure/lto-pgo.configure.pgo 2023-04-06 17:27:38.000000000 +0200
+++ firefox-112.0/build/moz.configure/lto-pgo.configure 2023-04-06 21:27:32.537089073 +0200
2022-04-06 08:36:00 +00:00
@@ -247,8 +247,8 @@ def lto(
2021-12-03 15:08:19 +00:00
cflags.append("-flto")
ldflags.append("-flto")
else:
- cflags.append("-flto=thin")
- ldflags.append("-flto=thin")
+ cflags.append("-flto")
+ ldflags.append("-flto")
if target.os == "Android" and value == "cross":
# Work around https://github.com/rust-lang/rust/issues/90088
2022-04-06 08:36:00 +00:00
@@ -264,7 +264,7 @@ def lto(
2021-12-03 15:08:19 +00:00
if value == "full":
cflags.append("-flto")
else:
- cflags.append("-flto=thin")
+ cflags.append("-flto")
# With clang-cl, -flto can only be used with -c or -fuse-ld=lld.
# AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld.
cflags.append("-fuse-ld=lld")
2023-04-11 10:57:42 +00:00
diff -up firefox-112.0/build/pgo/profileserver.py.pgo firefox-112.0/build/pgo/profileserver.py
--- firefox-112.0/build/pgo/profileserver.py.pgo 2023-04-06 17:27:40.000000000 +0200
+++ firefox-112.0/build/pgo/profileserver.py 2023-04-06 21:29:33.772294479 +0200
@@ -11,7 +11,7 @@ import subprocess
import sys
2020-06-23 13:05:19 +00:00
import mozcrash
2023-04-11 10:57:42 +00:00
-from mozbuild.base import BinaryNotFoundException, MozbuildObject
+from mozbuild.base import BinaryNotFoundException, MozbuildObject, BuildEnvironmentNotFoundException
2020-06-23 13:05:19 +00:00
from mozfile import TemporaryDirectory
from mozhttpd import MozHttpd
from mozprofile import FirefoxProfile, Preferences
2020-12-10 19:02:09 +00:00
@@ -87,9 +87,22 @@ if __name__ == "__main__":
locations = ServerLocations()
locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged")
2020-06-23 13:05:19 +00:00
2020-12-10 19:02:09 +00:00
- old_profraw_files = glob.glob("*.profraw")
2020-06-23 13:05:19 +00:00
- for f in old_profraw_files:
- os.remove(f)
+ using_gcc = False
+ try:
+ if build.config_environment.substs.get('CC_TYPE') == 'gcc':
+ using_gcc = True
+ except BuildEnvironmentNotFoundException:
+ pass
+
+ if using_gcc:
+ for dirpath, _, filenames in os.walk('.'):
+ for f in filenames:
+ if f.endswith('.gcda'):
+ os.remove(os.path.join(dirpath, f))
+ else:
+ old_profraw_files = glob.glob('*.profraw')
+ for f in old_profraw_files:
+ os.remove(f)
with TemporaryDirectory() as profilePath:
# TODO: refactor this into mozprofile
2023-04-11 10:57:42 +00:00
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
2021-04-20 07:11:49 +00:00
@@ -4,6 +4,15 @@ if [ -n "$FORCE_GCC" ]; then
2019-10-18 18:43:19 +00:00
CC="$MOZ_FETCHES_DIR/gcc/bin/gcc"
CXX="$MOZ_FETCHES_DIR/gcc/bin/g++"
2019-01-03 14:35:59 +00:00
+ 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.
2023-04-11 10:57:42 +00:00
mk_add_options "export PATH=$MOZ_FETCHES_DIR/gcc/bin:$MOZ_FETCHES_DIR/binutils/bin:$PATH"
diff -up firefox-112.0/toolkit/components/terminator/nsTerminator.cpp.pgo firefox-112.0/toolkit/components/terminator/nsTerminator.cpp
--- firefox-112.0/toolkit/components/terminator/nsTerminator.cpp.pgo 2023-04-06 17:27:57.000000000 +0200
+++ firefox-112.0/toolkit/components/terminator/nsTerminator.cpp 2023-04-06 21:27:32.538089108 +0200
@@ -460,6 +460,11 @@ void 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.
+ crashAfterMS = INT32_MAX;
+
UniquePtr<Options> options(new Options());
2022-04-06 08:36:00 +00:00
// crashAfterTicks is guaranteed to be > 0 as
// crashAfterMS >= ADDITIONAL_WAIT_BEFORE_CRASH_MS >> HEARTBEAT_INTERVAL_MS
2023-06-22 11:14:14 +00:00
diff -up firefox-114.0.2/build/moz.configure/lto-pgo.configure.pgo firefox-114.0.2/build/moz.configure/lto-pgo.configure
--- firefox-114.0.2/build/moz.configure/lto-pgo.configure.pgo 2023-06-22 11:17:37.428552356 +0200
+++ firefox-114.0.2/build/moz.configure/lto-pgo.configure 2023-06-22 11:17:51.476033691 +0200
@@ -86,7 +86,7 @@ def pgo_flags(compiler, profdata, target
return namespace(
gen_cflags=["-fprofile-generate"],
gen_ldflags=["-fprofile-generate"],
- use_cflags=["-fprofile-use", "-fprofile-correction", "-Wcoverage-mismatch"],
+ use_cflags=["-fprofile-use", "-fprofile-correction", "-Wno-coverage-mismatch"],
use_ldflags=["-fprofile-use"],
)