From 580f5d0e1d053d10b92d5375469724ede7a37846 Mon Sep 17 00:00:00 2001 From: jc_gargma Date: Sat, 26 Sep 2020 00:00:17 -0700 Subject: Updated to 81.0-2 Some test code for pgo --- ...e-remoting-name-for-GDK-application-names.patch | 13 ++-- ...-Support-the-fstat-like-subset-of-fstatat.patch | 46 +++++++++++++ ...-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch | 31 +++++++++ PKGBUILD | 72 ++++++++++++++++++-- arc4_enable-lto-for-gcc.patch | 15 +++++ arc4_enable-pgo-for-gcc.patch | 25 ++++--- mozconfig.in | 5 +- mozconfig.in.pgo | 77 ++++++++++++++++++++++ 8 files changed, 254 insertions(+), 30 deletions(-) create mode 100644 0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch create mode 100644 0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch create mode 100644 arc4_enable-lto-for-gcc.patch create mode 100644 mozconfig.in.pgo diff --git a/0001-Use-remoting-name-for-GDK-application-names.patch b/0001-Use-remoting-name-for-GDK-application-names.patch index 73ae042..b1dcee5 100644 --- a/0001-Use-remoting-name-for-GDK-application-names.patch +++ b/0001-Use-remoting-name-for-GDK-application-names.patch @@ -1,4 +1,4 @@ -From 5025aab61517c8608b555ba929c61eb0706bd6bd Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Mon, 25 Mar 2019 20:30:11 +0100 Subject: [PATCH] Use remoting name for GDK application names @@ -9,10 +9,10 @@ Subject: [PATCH] Use remoting name for GDK application names 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp -index da8289200e72..452195b146f3 100644 +index 49e2c73986ab..43ebcac381c7 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp -@@ -3785,11 +3785,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { +@@ -3822,11 +3822,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { // consistently. // Set program name to the one defined in application.ini. @@ -26,7 +26,7 @@ index da8289200e72..452195b146f3 100644 // Initialize GTK here for splash. diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp -index 163a93e2d1a4..4b6d45217671 100644 +index cfe022e65d82..06325264dbb1 100644 --- a/widget/gtk/nsAppShell.cpp +++ b/widget/gtk/nsAppShell.cpp @@ -24,6 +24,7 @@ @@ -37,7 +37,7 @@ index 163a93e2d1a4..4b6d45217671 100644 #include "ScreenHelperGTK.h" #include "HeadlessScreenHelper.h" #include "mozilla/widget/ScreenManager.h" -@@ -175,13 +176,9 @@ nsresult nsAppShell::Init() { +@@ -159,13 +160,9 @@ nsresult nsAppShell::Init() { // See https://bugzilla.gnome.org/show_bug.cgi?id=747634 // // Only bother doing this for the parent process, since it's the one @@ -54,6 +54,3 @@ index 163a93e2d1a4..4b6d45217671 100644 } } } --- -2.26.1 - diff --git a/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch b/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch new file mode 100644 index 0000000..427dfcd --- /dev/null +++ b/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jed Davis +Date: Fri, 28 Aug 2020 09:23:58 +0000 +Subject: [PATCH] Bug 1660901 - Support the fstat-like subset of fstatat in the + Linux sandbox policies. r=gcp + +Differential Revision: https://phabricator.services.mozilla.com/D88499 +--- + security/sandbox/linux/SandboxFilter.cpp | 6 ++++++ + security/sandbox/linux/broker/SandboxBrokerUtils.h | 2 ++ + 2 files changed, 8 insertions(+) + +diff --git a/security/sandbox/linux/SandboxFilter.cpp b/security/sandbox/linux/SandboxFilter.cpp +index e522d61e065c..4087bdc07e01 100644 +--- a/security/sandbox/linux/SandboxFilter.cpp ++++ b/security/sandbox/linux/SandboxFilter.cpp +@@ -243,6 +243,12 @@ class SandboxPolicyCommon : public SandboxPolicyBase { + auto path = reinterpret_cast(aArgs.args[1]); + auto buf = reinterpret_cast(aArgs.args[2]); + auto flags = static_cast(aArgs.args[3]); ++ ++ if (fd != AT_FDCWD && (flags & AT_EMPTY_PATH) != 0 && ++ strcmp(path, "") == 0) { ++ return ConvertError(fstatsyscall(fd, buf)); ++ } ++ + if (fd != AT_FDCWD && path[0] != '/') { + SANDBOX_LOG_ERROR("unsupported fd-relative fstatat(%d, \"%s\", %p, %d)", + fd, path, buf, flags); +diff --git a/security/sandbox/linux/broker/SandboxBrokerUtils.h b/security/sandbox/linux/broker/SandboxBrokerUtils.h +index 85a006740c2c..db33b5028e77 100644 +--- a/security/sandbox/linux/broker/SandboxBrokerUtils.h ++++ b/security/sandbox/linux/broker/SandboxBrokerUtils.h +@@ -19,10 +19,12 @@ + typedef struct stat64 statstruct; + # define statsyscall stat64 + # define lstatsyscall lstat64 ++# define fstatsyscall fstat64 + #elif defined(__NR_stat) + typedef struct stat statstruct; + # define statsyscall stat + # define lstatsyscall lstat ++# define fstatsyscall fstat + #else + # error Missing stat syscall include. + #endif diff --git a/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch b/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch new file mode 100644 index 0000000..dd5a535 --- /dev/null +++ b/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Julien Cristau +Date: Sun, 6 Sep 2020 20:20:39 +0000 +Subject: [PATCH] Bug 1660901 - ignore AT_NO_AUTOMOUNT in fstatat system call. + r=jld + +Per the manpage "Both stat() and lstat() act as though AT_NO_AUTOMOUNT +was set.", so don't bail if it's set in a call to fstatat. + +Differential Revision: https://phabricator.services.mozilla.com/D89121 +--- + security/sandbox/linux/SandboxFilter.cpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/security/sandbox/linux/SandboxFilter.cpp b/security/sandbox/linux/SandboxFilter.cpp +index 4087bdc07e01..c4f6c318ad1c 100644 +--- a/security/sandbox/linux/SandboxFilter.cpp ++++ b/security/sandbox/linux/SandboxFilter.cpp +@@ -254,9 +254,10 @@ class SandboxPolicyCommon : public SandboxPolicyBase { + fd, path, buf, flags); + return BlockedSyscallTrap(aArgs, nullptr); + } +- if ((flags & ~AT_SYMLINK_NOFOLLOW) != 0) { ++ if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT)) != 0) { + SANDBOX_LOG_ERROR("unsupported flags %d in fstatat(%d, \"%s\", %p, %d)", +- (flags & ~AT_SYMLINK_NOFOLLOW), fd, path, buf, flags); ++ (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT)), fd, ++ path, buf, flags); + return BlockedSyscallTrap(aArgs, nullptr); + } + return (flags & AT_SYMLINK_NOFOLLOW) == 0 ? broker->Stat(path, buf) diff --git a/PKGBUILD b/PKGBUILD index 00716d5..1a1fdbb 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -16,10 +16,11 @@ _modclang=0 #_modclang=1 # FIXME +_testgcc=0 pkgname=firefox -pkgver=80.0 -pkgrel=1 +pkgver=81.0 +pkgrel=2 pkgdesc="Standalone web browser from mozilla.org" arch=(x86_64 aarch64) license=(MPL GPL LGPL) @@ -28,7 +29,7 @@ depends=(gtk3 libxt mime-types dbus-glib ffmpeg ttf-font libpulse alsa-lib bzip2 libffi icu libjpeg-turbo libevent libvpx nspr nss pixman libpng sqlite libwebp zlib) makedepends=(unzip zip diffutils yasm mesa imake inetutils xorg-server-xvfb autoconf2.13 rust clang llvm jack gtk2 nodejs cbindgen nasm - python-setuptools python-psutil lld) + python-setuptools python-psutil python-zstandard lld) optdepends=('networkmanager: Location detection via available WiFi networks' 'libnotify: Notification integration' 'alsa-utils: ALSA support' @@ -43,26 +44,34 @@ conflicts=(firefox-esr) source=( "https://archive.mozilla.org/pub/$pkgname/releases/$pkgver/source/$pkgname-$pkgver.source.tar.xz"{,.asc} 0001-Use-remoting-name-for-GDK-application-names.patch + 0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch + 0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch $pkgname.desktop distribution.ini mozconfig.in + mozconfig.in.pgo mozconfig.in.clang mozconfig.in.clang.pgo mozconfig.common.override + arc4_enable-lto-for-gcc.patch arc4_enable-pgo-for-gcc.patch arc4_remove-health-reporting.patch arc4_remove-system-addons.patch ) -b2sums=('3099426b27cd3c89b63be7d796c8c5a87d0ee9bd8252e5bde23ed3a61f71d611e7427ffee506224e81a88ef109eefe944f2cf3367bd636a6ed46b7351d0a4b1b' +b2sums=('0546bad15aa89a7e4d2ca0cc000fed2170b9529f8f2cc1c1c4907649ffbcf72e8ee800083b63a767fc07b643cacb298b424ebc1ce827de209f366716e3a5135b' 'SKIP' - 'e4cf5d0ddd2c7271f1723b5c313f0aa8a7bf2242fb301ceba1ab5a4dca655ca7b9461d0aaebe5eaccf84b2f7a4c4199cbb0c18eab2bdaff273fcb730ec27219e' + '870f33f4dcb411e3aa2f94c5068bccad0f07a5c4a6b5356fc55ba363bdc2ff8ba8b76d507618b7349ae190ed09deadf4c0b8b500a6692f76cd01e7f83411a2db' + '799ff9c88aafde5c60d852c9c9006090adce002f558985c95d5759e34aec9f6713298d3ff7e9220183053f932d8c7d849d0b715d66315ae58bc21aef891d136a' + '32b1b153c3affb5a6b92425813d565124603e09a654f23347206f2cbf6f928377385917312c100b8c19a556fe75066499fb5b2fe15a2fd2cf569963df12ff1c3' 'e18f2c22e394ca3b6758bc130245b254947e4d15921be3da443d6d7c3c4b0d22ead1b39fbc10a4f896edd19e2a1dffbd1cbb34dc4beb0621a6ddb70ccc53b3a7' '877eda442eb4730600dccf209a6e961ad3122ab456bbfda4ff041e8493ebaaf96224ac218360931259ff4214482f6bf65b3a3052f977ade1a274f38ffd859535' - '83eb896637669476878c45c68ce5c30da106cc60b41eb4944f39007f6b4a37e6b70e5ca0afedb7dba6e5fc765b4dc10c12960cd4e449a6c4e864e4179bbfb166' + 'f8b01cf39b9e149f1acfd1c68ab55028f758a139f972138dbd51a423633f31bdaaa08acf785e81e16a4c2353f322a8917cd07a0fb706093b4019ecca0bd7673f' + '08d4e0768c2323b4905b3ba539594e88132b487a4eac2ab61df36020fe6f933c338afba918aea0becd10ecf29795bf94146cefc4f6b111ea658a20fdf6e899cd' 'aa87016dabc182a4da3db1f29f4a6b274095be883febf848ddbe86615639b6a85f12b2c78ce6b18bba18516982330fb775083f4bab330738d95ee26d70f02dfa' 'ffb7ca117004a084b1bd7baed6a11b0914ec391459d662fc8887edc3206eb25c41b09f713e9bfe0ed474333d9537295842b0617dd29e9ce222fde548cd9111aa' '1c7ac58af8b817067c7d79ffef8d9100f513d77f4fc1a2bce2684ff8d8d3cbc3d37b31865c7e5d873fd71d4649374bbd25ca08166d8afb25ffbd597759655063' '087ea758132905cab848e3a13a13537b42f70ba3a8bfd1ef4e2933d3e874e94038b50ee583b9e7e0c7b7cc7c2cf570f7f613b661f47121b7bf207f433b939f3d' + '1250b2d4a713b241d9768dc386ecf9130d295587efd5070c2e494185436ca9d99a465b97ed80fe23ab14d6d07ecde8537a3a3d11ba843c4e3791b4df52e08f27' '020695637162ce981929f54ea556100bf17e92931179a5849ca8265dfc0016f1b6599d9f77e9f71f192a1a4bb3b2d1eadbf5d5554e6c33bfa3f9388b0a3c7c6e' '635a84c64ea9dccf41fbde33b58a72a8123ecd841995ad045bd329e23855f56ffce05670fe2d69a12c4cef7a7399bc6becfc5f40bfd8cea9a4006074672a634d') validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases @@ -74,14 +83,27 @@ prepare() { # https://bugzilla.mozilla.org/show_bug.cgi?id=1530052 patch -Np1 -i ../0001-Use-remoting-name-for-GDK-application-names.patch + # https://bugs.archlinux.org/task/67978 + # https://bugzilla.mozilla.org/show_bug.cgi?id=1660901 + patch -Np1 -i ../0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch + patch -Np1 -i ../0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch + if [ "${_modclang}" != "1" ]; then + # Apply gcc pgo patches + patch -p0 $srcdir/${pkgname}-${pkgver}/security/sandbox/linux/moz.build $srcdir/arc4_enable-lto-for-gcc.patch + fi + + if [ "${_testgcc}" == "1" ]; then # Apply gcc pgo patches patch -p0 $srcdir/${pkgname}-${pkgver}/security/sandbox/linux/moz.build $srcdir/arc4_enable-pgo-for-gcc.patch fi if [ "${_modclang}" == "1" ]; then - # Add the custom mozconfig for pgo + # Add the custom mozconfig for clang pgo cp $srcdir/mozconfig.in.clang.pgo $srcdir/${pkgname}-${pkgver}/.mozconfig + elif [ "${_testgcc}" == "1" ]; then + # Add the custom mozconfig for gcc pgo + cp $srcdir/mozconfig.in.pgo $srcdir/${pkgname}-${pkgver}/.mozconfig else # Add the custom mozconfig cp $srcdir/mozconfig.in $srcdir/${pkgname}-${pkgver}/.mozconfig @@ -115,13 +137,16 @@ build() { export MOZ_NOSPAM=1 export MOZBUILD_STATE_PATH="$srcdir/mozbuild" + export MACH_USE_SYSTEM_PYTHON=1 + # -flto breaks cargo export CFLAGS="$CFLAGS -O3 -fstack-protector-all -fPIC" export CXXFLAGS="$CXXFLAGS -O3 -fstack-protector-all -fPIC" # LTO needs more open files ulimit -n 4096 + if [ "${_modclang}" == "1" ]; then # clang does not support -fstack-clash-protection, so remove it export CFLAGS="$(echo $CFLAGS | sed 's/ -fstack-clash-protection//' - )" @@ -156,6 +181,39 @@ ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog mk_add_options MOZ_OBJDIR=${PWD@Q}/obj END ./mach build + + elif [ "${_testgcc}" == "1" ]; then + + # Do 3-tier PGO + echo "Building instrumented browser..." + ./mach build + + echo "Profiling instrumented browser..." + ./mach package + LLVM_PROFDATA=llvm-profdata \ + JARLOG_FILE="$PWD/jarlog" \ + xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \ + ./mach python build/pgo/profileserver.py + + stat -c "Profile data found (%s bytes)" merged.profdata + test -s merged.profdata + + stat -c "Jar log found (%s bytes)" jarlog + test -s jarlog + + echo "Removing instrumented browser..." + ./mach clobber + + echo "Building optimized browser..." + # Add the custom mozconfig + cp $srcdir/mozconfig.in $srcdir/${pkgname}-${pkgver}/.mozconfig + cat >.mozconfig - <