diff -up firefox-115.0.2/build/moz.configure/lto-pgo.configure.pgo firefox-115.0.2/build/moz.configure/lto-pgo.configure --- firefox-115.0.2/build/moz.configure/lto-pgo.configure.pgo 2023-07-10 21:29:37.000000000 +0200 +++ firefox-115.0.2/build/moz.configure/lto-pgo.configure 2023-07-17 12:14:11.504155850 +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"], ) diff -up firefox-115.0.2/build/pgo/profileserver.py.pgo firefox-115.0.2/build/pgo/profileserver.py --- firefox-115.0.2/build/pgo/profileserver.py.pgo 2023-07-10 21:29:38.000000000 +0200 +++ firefox-115.0.2/build/pgo/profileserver.py 2023-07-17 12:14:11.503155816 +0200 @@ -11,7 +11,7 @@ import subprocess import sys import mozcrash -from mozbuild.base import BinaryNotFoundException, MozbuildObject +from mozbuild.base import BinaryNotFoundException, MozbuildObject, BuildEnvironmentNotFoundException from mozfile import TemporaryDirectory from mozhttpd import MozHttpd from mozprofile import FirefoxProfile, Preferences @@ -87,9 +87,22 @@ if __name__ == "__main__": locations = ServerLocations() locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged") - old_profraw_files = glob.glob("*.profraw") - 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 diff -up firefox-115.0.2/gfx/2d/moz.build.pgo firefox-115.0.2/gfx/2d/moz.build --- firefox-115.0.2/gfx/2d/moz.build.pgo 2023-07-17 12:37:49.532499847 +0200 +++ firefox-115.0.2/gfx/2d/moz.build 2023-07-17 12:38:16.378433587 +0200 @@ -136,11 +136,11 @@ if CONFIG["INTEL_ARCHITECTURE"]: # The file uses SSE2 intrinsics, so it needs special compile flags on some # compilers. SOURCES["BlurSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"] - SOURCES["ConvolutionFilterAVX2.cpp"].flags += ["-mavx2"] + SOURCES["ConvolutionFilterAVX2.cpp"].flags += ["-mavx2", "-fno-lto"] SOURCES["ConvolutionFilterSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"] SOURCES["FilterProcessingSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"] SOURCES["ImageScalingSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"] - SOURCES["SwizzleAVX2.cpp"].flags += ["-mavx2"] + SOURCES["SwizzleAVX2.cpp"].flags += ["-mavx2", "-fno-lto"] SOURCES["SwizzleSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"] SOURCES["SwizzleSSSE3.cpp"].flags += CONFIG["SSSE3_FLAGS"] SOURCES["ssse3-scaler.c"].flags += CONFIG["SSSE3_FLAGS"] diff -up firefox-115.0.2/gfx/skia/generate_mozbuild.py.pgo firefox-115.0.2/gfx/skia/generate_mozbuild.py --- firefox-115.0.2/gfx/skia/generate_mozbuild.py.pgo 2023-07-10 21:29:41.000000000 +0200 +++ firefox-115.0.2/gfx/skia/generate_mozbuild.py 2023-07-17 12:35:46.651225829 +0200 @@ -54,10 +54,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind if CONFIG['INTEL_ARCHITECTURE']: SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3'] SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += ['-msse4.2'] - SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx'] - SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma'] + SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx', '-fno-lto'] + SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma', '-fno-lto'] if not CONFIG["MOZ_CODE_COVERAGE"]: - SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl'] + SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl', '-fno-lto'] elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'): SOURCES['skia/src/opts/SkOpts_crc32.cpp'].flags += ['-march=armv8-a+crc'] diff -up firefox-115.0.2/gfx/skia/moz.build.pgo firefox-115.0.2/gfx/skia/moz.build --- firefox-115.0.2/gfx/skia/moz.build.pgo 2023-07-10 21:29:41.000000000 +0200 +++ firefox-115.0.2/gfx/skia/moz.build 2023-07-17 12:37:21.626529230 +0200 @@ -565,10 +565,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind if CONFIG['INTEL_ARCHITECTURE']: SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-mssse3'] SOURCES['skia/src/opts/SkOpts_sse42.cpp'].flags += ['-msse4.2'] - SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx'] - SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma'] + SOURCES['skia/src/opts/SkOpts_avx.cpp'].flags += ['-mavx', '-fno-lto'] + SOURCES['skia/src/opts/SkOpts_hsw.cpp'].flags += ['-mavx2', '-mf16c', '-mfma', '-fno-lto'] if not CONFIG["MOZ_CODE_COVERAGE"]: - SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl'] + SOURCES['skia/src/opts/SkOpts_skx.cpp'].flags += ['-mavx512f', '-mavx512dq', '-mavx512cd', '-mavx512bw', '-mavx512vl', '-fno-lto'] elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'): SOURCES['skia/src/opts/SkOpts_crc32.cpp'].flags += ['-march=armv8-a+crc'] diff -up firefox-115.0.2/toolkit/components/terminator/nsTerminator.cpp.pgo firefox-115.0.2/toolkit/components/terminator/nsTerminator.cpp --- firefox-115.0.2/toolkit/components/terminator/nsTerminator.cpp.pgo 2023-07-10 21:29:58.000000000 +0200 +++ firefox-115.0.2/toolkit/components/terminator/nsTerminator.cpp 2023-07-17 12:14:11.503155816 +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(new Options()); // crashAfterTicks is guaranteed to be > 0 as // crashAfterMS >= ADDITIONAL_WAIT_BEFORE_CRASH_MS >> HEARTBEAT_INTERVAL_MS