From eacd934cf3cf693bbf08c27a2761b00f29359bc2 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Fri, 23 Feb 2024 19:31:52 +0100 Subject: [PATCH] Fixed & enabled PGO builds --- firefox.spec | 35 ++++++++++++++--------------------- pgo.patch | 36 +++++++++++++++++++++++++++--------- run-wayland-compositor | 22 ++++++++++++++-------- 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/firefox.spec b/firefox.spec index 4acb082..d74abe6 100644 --- a/firefox.spec +++ b/firefox.spec @@ -28,7 +28,6 @@ ExcludeArch: i686 %global system_nss 1 %global system_libevent 1 %global build_with_asan 0 -%global test_on_wayland 0 %ifarch x86_64 %{ix86} %global enable_replace_malloc 1 %else @@ -85,7 +84,7 @@ ExcludeArch: i686 %global build_with_pgo 0 %ifarch x86_64 %if %{release_build} -%global build_with_pgo 0 +%global build_with_pgo 1 %endif %endif %if 0%{?flatpak} @@ -107,10 +106,10 @@ ExcludeArch: i686 %endif %global launch_wayland_compositor 0 -%if %{build_with_pgo} && %{test_on_wayland} +%if %{build_with_pgo} %global launch_wayland_compositor 1 %endif -%if %{run_firefox_tests} && %{test_on_wayland} +%if %{run_firefox_tests} %global launch_wayland_compositor 1 %endif @@ -390,7 +389,7 @@ BuildRequires: libasan-static %endif BuildRequires: perl-interpreter BuildRequires: fdk-aac-free-devel -%if 0%{?test_on_wayland} +%if 0%{?launch_wayland_compositor} BuildRequires: mutter BuildRequires: gsettings-desktop-schemas BuildRequires: gnome-settings-daemon @@ -841,7 +840,7 @@ echo "mk_add_options MOZ_MAKE_FLAGS=\"-j%{_smp_build_ncpus}\"" >> .mozconfig echo "mk_add_options MOZ_SERVICES_SYNC=1" >> .mozconfig echo "export STRIP=/bin/true" >> .mozconfig -%if %{launch_wayland_compositor} +%if %{build_with_pgo} cp %{SOURCE45} . . ./run-wayland-compositor %endif @@ -857,15 +856,10 @@ tar xf %{SOURCE37} #Use python 3.11 for mach sed -i -e 's|#!/usr/bin/env python3|#!/usr/bin/env python3.11|' mach -%if %{build_with_pgo} -%if %{test_on_wayland} -env | grep "WAYLAND" -MOZ_ENABLE_WAYLAND=1 ./mach build -v 2>&1 | cat - || exit 1 -%else -xvfb-run ./mach build -v 2>&1 | cat - || exit 1 -%endif -%else ./mach build -v 2>&1 | cat - || exit 1 + +%if %{build_with_pgo} +kill $MUTTER_PID %endif #--------------------------------------------------------------------- @@ -873,21 +867,17 @@ xvfb-run ./mach build -v 2>&1 | cat - || exit 1 # run Firefox test suite # Do we need it? # export MACH_NATIVE_PACKAGE_SOURCE=system -%if %{launch_wayland_compositor} +%if %{run_firefox_tests} cp %{SOURCE45} . . ./run-wayland-compositor -%endif -%if 0%{?run_firefox_tests} cp %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE38} %{SOURCE39} %{SOURCE43} %{SOURCE44} . mkdir -p test_results -%if %{test_on_wayland} ./run-tests-wayland || true -%else -./run-tests-x11 || true -%endif ./print_results > test_summary.txt 2>&1 || true ./print_failures || true + +kill $MUTTER_PID %endif # set up our default bookmarks @@ -1202,6 +1192,9 @@ fi #--------------------------------------------------------------------- %changelog +* Fri Feb 23 2024 Martin Stransky - 123.0-2 +- Fixed PGO builds and enabled it again. + * Wed Feb 21 2024 Daniel Rusek - 123.0-2 - Add matching AppStream metadata for org.mozilla.firefox.desktop diff --git a/pgo.patch b/pgo.patch index 5a092bf..6499434 100644 --- a/pgo.patch +++ b/pgo.patch @@ -1,7 +1,25 @@ diff -up firefox-123.0/build/moz.configure/lto-pgo.configure.pgo firefox-123.0/build/moz.configure/lto-pgo.configure ---- firefox-123.0/build/moz.configure/lto-pgo.configure.pgo 2024-02-14 08:18:40.000000000 +0100 -+++ firefox-123.0/build/moz.configure/lto-pgo.configure 2024-02-19 10:51:40.900650193 +0100 -@@ -130,7 +130,7 @@ def pgo_flags(compiler, linker, profdata +--- firefox-123.0/build/moz.configure/lto-pgo.configure.pgo 2024-02-22 10:53:12.608509264 +0100 ++++ firefox-123.0/build/moz.configure/lto-pgo.configure 2024-02-22 10:56:14.911881765 +0100 +@@ -90,12 +90,16 @@ set_config("PGO_PROFILE_PATH", pgo_profi + + @depends( + "--enable-profile-use", ++ c_compiler, + pgo_profile_path, + llvm_profdata, + llvm_profdata_order, + build_environment, + ) +-def orderfile_path(profile_use, path, profdata, profdata_order, build_env): ++def orderfile_path(profile_use, compiler, path, profdata, profdata_order, build_env): ++ if compiler.type == "gcc": ++ return None ++ + if not profile_use: + return None + +@@ -130,7 +134,7 @@ def pgo_flags(compiler, linker, profdata return namespace( gen_cflags=["-fprofile-generate"], gen_ldflags=["-fprofile-generate"], @@ -12,7 +30,7 @@ diff -up firefox-123.0/build/moz.configure/lto-pgo.configure.pgo firefox-123.0/b diff -up firefox-123.0/build/pgo/profileserver.py.pgo firefox-123.0/build/pgo/profileserver.py --- firefox-123.0/build/pgo/profileserver.py.pgo 2024-02-14 08:18:40.000000000 +0100 -+++ firefox-123.0/build/pgo/profileserver.py 2024-02-19 10:51:40.900650193 +0100 ++++ firefox-123.0/build/pgo/profileserver.py 2024-02-22 10:06:42.665963053 +0100 @@ -11,7 +11,7 @@ import subprocess import sys @@ -49,8 +67,8 @@ diff -up firefox-123.0/build/pgo/profileserver.py.pgo firefox-123.0/build/pgo/pr with TemporaryDirectory() as profilePath: # TODO: refactor this into mozprofile diff -up firefox-123.0/gfx/2d/moz.build.pgo firefox-123.0/gfx/2d/moz.build ---- firefox-123.0/gfx/2d/moz.build.pgo 2024-02-19 10:51:40.900650193 +0100 -+++ firefox-123.0/gfx/2d/moz.build 2024-02-19 10:57:34.770832810 +0100 +--- firefox-123.0/gfx/2d/moz.build.pgo 2024-02-14 08:18:41.000000000 +0100 ++++ firefox-123.0/gfx/2d/moz.build 2024-02-22 10:06:42.665963053 +0100 @@ -134,11 +134,11 @@ if CONFIG["INTEL_ARCHITECTURE"]: # The file uses SSE2 intrinsics, so it needs special compile flags on some # compilers. @@ -67,7 +85,7 @@ diff -up firefox-123.0/gfx/2d/moz.build.pgo firefox-123.0/gfx/2d/moz.build elif CONFIG["TARGET_CPU"].startswith("mips"): diff -up firefox-123.0/gfx/skia/generate_mozbuild.py.pgo firefox-123.0/gfx/skia/generate_mozbuild.py --- firefox-123.0/gfx/skia/generate_mozbuild.py.pgo 2024-02-14 08:18:42.000000000 +0100 -+++ firefox-123.0/gfx/skia/generate_mozbuild.py 2024-02-19 10:51:40.901650227 +0100 ++++ firefox-123.0/gfx/skia/generate_mozbuild.py 2024-02-22 10:06:42.665963053 +0100 @@ -54,10 +54,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind if CONFIG['INTEL_ARCHITECTURE']: SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-Dskvx=skvx_ssse3', '-mssse3'] @@ -84,7 +102,7 @@ diff -up firefox-123.0/gfx/skia/generate_mozbuild.py.pgo firefox-123.0/gfx/skia/ diff -up firefox-123.0/gfx/skia/moz.build.pgo firefox-123.0/gfx/skia/moz.build --- firefox-123.0/gfx/skia/moz.build.pgo 2024-02-14 08:18:42.000000000 +0100 -+++ firefox-123.0/gfx/skia/moz.build 2024-02-19 10:51:40.901650227 +0100 ++++ firefox-123.0/gfx/skia/moz.build 2024-02-22 10:06:42.666963088 +0100 @@ -564,10 +564,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind if CONFIG['INTEL_ARCHITECTURE']: SOURCES['skia/src/opts/SkOpts_ssse3.cpp'].flags += ['-Dskvx=skvx_ssse3', '-mssse3'] @@ -101,7 +119,7 @@ diff -up firefox-123.0/gfx/skia/moz.build.pgo firefox-123.0/gfx/skia/moz.build diff -up firefox-123.0/toolkit/components/terminator/nsTerminator.cpp.pgo firefox-123.0/toolkit/components/terminator/nsTerminator.cpp --- firefox-123.0/toolkit/components/terminator/nsTerminator.cpp.pgo 2024-02-14 08:18:56.000000000 +0100 -+++ firefox-123.0/toolkit/components/terminator/nsTerminator.cpp 2024-02-19 10:51:40.901650227 +0100 ++++ firefox-123.0/toolkit/components/terminator/nsTerminator.cpp 2024-02-22 10:06:42.666963088 +0100 @@ -460,6 +460,11 @@ void nsTerminator::StartWatchdog() { } #endif diff --git a/run-wayland-compositor b/run-wayland-compositor index 0480ed2..7290d5c 100755 --- a/run-wayland-compositor +++ b/run-wayland-compositor @@ -26,15 +26,19 @@ if [ -z "$XDG_RUNTIME_DIR" ]; then export XDG_RUNTIME_DIR=$HOME fi -. xvfb-run -s "-screen 0 1600x1200x24" -n 80 mutter --display=:80 --wayland --nested & -export DISPLAY=:80 +export WAYLAND_DISPLAY=firefox-wayland-0 -if [ -z "$WAYLAND_DISPLAY" ] ; then - export WAYLAND_DISPLAY=wayland-0 -else - export WAYLAND_DISPLAY=wayland-1 +if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then + rm -f $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY fi -sleep 10 + +echo "Launch mutter for $WAYLAND_DISPLAY" +mutter --wayland --wayland-display=$WAYLAND_DISPLAY --headless --virtual-monitor=1600x1200 & MUTTER_PID=$! +export MUTTER_PID +echo "Mutter PID $MUTTER_PID" + +echo "Waiting for mutter to start..." +sleep 5 retry_count=0 max_retries=5 until [ $retry_count -gt $max_retries ]; do @@ -47,4 +51,6 @@ until [ $retry_count -gt $max_retries ]; do fi done -env | grep "DISPLAY" +if [ -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then + echo "Mutter is running, $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY is here." +fi