2020-12-10 19:02:09 +00:00
|
|
|
diff -up firefox-84.0/build/moz.configure/lto-pgo.configure.pgo firefox-84.0/build/moz.configure/lto-pgo.configure
|
|
|
|
--- firefox-84.0/build/moz.configure/lto-pgo.configure.pgo 2020-12-10 15:55:41.932635998 +0100
|
|
|
|
+++ firefox-84.0/build/moz.configure/lto-pgo.configure 2020-12-10 16:01:24.674052547 +0100
|
|
|
|
@@ -228,13 +228,13 @@ def lto(value, c_compiler, ld64_known_go
|
2020-10-01 21:12:24 +00:00
|
|
|
cflags.append("-flto")
|
|
|
|
ldflags.append("-flto")
|
|
|
|
else:
|
|
|
|
- cflags.append("-flto=thin")
|
|
|
|
- ldflags.append("-flto=thin")
|
|
|
|
+ cflags.append("-flto")
|
|
|
|
+ ldflags.append("-flto")
|
2020-12-10 19:02:09 +00:00
|
|
|
elif c_compiler.type == "clang-cl":
|
|
|
|
if len(value) and value[0].lower() == "full":
|
2020-10-01 21:12:24 +00:00
|
|
|
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.
|
2020-12-10 19:02:09 +00:00
|
|
|
cflags.append("-fuse-ld=lld")
|
|
|
|
@@ -268,7 +268,7 @@ def lto(value, c_compiler, ld64_known_go
|
|
|
|
if len(value) and value[0].lower() == "full":
|
2020-10-01 21:12:24 +00:00
|
|
|
cflags.append("-flto")
|
|
|
|
else:
|
|
|
|
- cflags.append("-flto=thin")
|
|
|
|
+ cflags.append("-flto")
|
|
|
|
cflags.append("-flifetime-dse=1")
|
|
|
|
|
|
|
|
ldflags.append("-flto=%s" % num_cores)
|
2020-12-10 19:02:09 +00:00
|
|
|
diff -up firefox-84.0/build/pgo/profileserver.py.pgo firefox-84.0/build/pgo/profileserver.py
|
|
|
|
--- firefox-84.0/build/pgo/profileserver.py.pgo 2020-12-07 23:32:58.000000000 +0100
|
|
|
|
+++ firefox-84.0/build/pgo/profileserver.py 2020-12-10 16:05:16.278668657 +0100
|
2020-06-23 13:05:19 +00:00
|
|
|
@@ -11,7 +11,7 @@ import glob
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import mozcrash
|
|
|
|
-from mozbuild.base import MozbuildObject, BinaryNotFoundException
|
|
|
|
+from mozbuild.base import MozbuildObject, BinaryNotFoundException, BuildEnvironmentNotFoundException
|
|
|
|
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
|
2020-12-10 19:02:09 +00:00
|
|
|
@@ -212,6 +225,10 @@ if __name__ == "__main__":
|
2020-06-23 13:05:19 +00:00
|
|
|
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;');
|
|
|
|
+
|
2020-12-10 19:02:09 +00:00
|
|
|
llvm_profdata = env.get("LLVM_PROFDATA")
|
2020-06-23 13:05:19 +00:00
|
|
|
if llvm_profdata:
|
2020-12-10 19:02:09 +00:00
|
|
|
profraw_files = glob.glob("*.profraw")
|
|
|
|
diff -up firefox-84.0/build/unix/mozconfig.unix.pgo firefox-84.0/build/unix/mozconfig.unix
|
|
|
|
--- firefox-84.0/build/unix/mozconfig.unix.pgo 2020-12-07 23:32:58.000000000 +0100
|
|
|
|
+++ firefox-84.0/build/unix/mozconfig.unix 2020-12-10 15:55:41.933636031 +0100
|
2019-01-03 14:35:59 +00:00
|
|
|
@@ -6,6 +6,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.
|
2019-10-18 18:43:19 +00:00
|
|
|
mk_add_options "export PATH=$MOZ_FETCHES_DIR/gcc/bin:$PATH"
|
2020-12-10 19:02:09 +00:00
|
|
|
diff -up firefox-84.0/extensions/spellcheck/src/moz.build.pgo firefox-84.0/extensions/spellcheck/src/moz.build
|
|
|
|
--- firefox-84.0/extensions/spellcheck/src/moz.build.pgo 2020-12-10 15:55:41.933636031 +0100
|
|
|
|
+++ firefox-84.0/extensions/spellcheck/src/moz.build 2020-12-10 16:16:05.897011122 +0100
|
2019-10-18 18:43:19 +00:00
|
|
|
@@ -31,3 +31,5 @@ EXPORTS.mozilla += [
|
2018-12-21 09:38:41 +00:00
|
|
|
|
2020-12-10 19:02:09 +00:00
|
|
|
if CONFIG["CC_TYPE"] in ("clang", "gcc"):
|
|
|
|
CXXFLAGS += ["-Wno-error=shadow"]
|
2018-12-21 09:38:41 +00:00
|
|
|
+
|
|
|
|
+CXXFLAGS += ['-fno-devirtualize']
|
2020-12-10 19:02:09 +00:00
|
|
|
diff -up firefox-84.0/python/mozbuild/mozbuild/build_commands.py.pgo firefox-84.0/python/mozbuild/mozbuild/build_commands.py
|
|
|
|
--- firefox-84.0/python/mozbuild/mozbuild/build_commands.py.pgo 2020-12-10 15:55:41.933636031 +0100
|
|
|
|
+++ firefox-84.0/python/mozbuild/mozbuild/build_commands.py 2020-12-10 16:14:30.017272529 +0100
|
|
|
|
@@ -126,9 +126,8 @@ class Build(MachCommandBase):
|
2020-06-23 13:05:19 +00:00
|
|
|
return status
|
|
|
|
|
|
|
|
pgo_env = os.environ.copy()
|
2020-12-10 19:02:09 +00:00
|
|
|
- pgo_env["LLVM_PROFDATA"] = instr.config_environment.substs.get(
|
|
|
|
- "LLVM_PROFDATA"
|
|
|
|
- )
|
2020-06-23 13:05:19 +00:00
|
|
|
+ if instr.config_environment.substs.get('CC_TYPE') != 'gcc':
|
2020-12-10 19:02:09 +00:00
|
|
|
+ pgo_env["LLVM_PROFDATA"] = instr.config_environment.substs.get("LLVM_PROFDATA")
|
|
|
|
pgo_env["JARLOG_FILE"] = mozpath.join(orig_topobjdir, "jarlog/en-US.log")
|
2020-06-23 13:05:19 +00:00
|
|
|
pgo_cmd = [
|
|
|
|
instr.virtualenv_manager.python_path,
|
2020-12-10 19:02:09 +00:00
|
|
|
diff -up firefox-84.0/toolkit/components/terminator/nsTerminator.cpp.pgo firefox-84.0/toolkit/components/terminator/nsTerminator.cpp
|
|
|
|
--- firefox-84.0/toolkit/components/terminator/nsTerminator.cpp.pgo 2020-12-07 23:33:08.000000000 +0100
|
|
|
|
+++ firefox-84.0/toolkit/components/terminator/nsTerminator.cpp 2020-12-10 15:55:41.933636031 +0100
|
2020-10-07 08:22:49 +00:00
|
|
|
@@ -418,6 +418,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());
|
|
|
|
const PRIntervalTime ticksDuration = PR_MillisecondsToInterval(1000);
|
|
|
|
options->crashAfterTicks = crashAfterMS / ticksDuration;
|