From 8210ffbe79be631eaf04620c5ecbef64f4dbf8b5 Mon Sep 17 00:00:00 2001 From: Kevin Mihelich Date: Tue, 10 Nov 2020 19:27:56 +0000 Subject: [PATCH] extra/js78 to 78.4.1-1 --- extra/js78/PKGBUILD | 9 +++- extra/js78/lto-pgo.diff | 92 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 extra/js78/lto-pgo.diff diff --git a/extra/js78/PKGBUILD b/extra/js78/PKGBUILD index d8a19b124..8a5b0e19b 100644 --- a/extra/js78/PKGBUILD +++ b/extra/js78/PKGBUILD @@ -5,7 +5,7 @@ # - patch to fix build on ARM pkgname=js78 -pkgver=78.4.0 +pkgver=78.4.1 pkgrel=1 pkgdesc="JavaScript interpreter and libraries - Version 78" arch=(x86_64) @@ -16,9 +16,11 @@ makedepends=(zip autoconf2.13 python-setuptools python-psutil rust llvm clang ll checkdepends=(mercurial git) _relver=${pkgver}esr source=(https://archive.mozilla.org/pub/firefox/releases/$_relver/source/firefox-$_relver.source.tar.xz{,.asc} + lto-pgo.diff arm.patch) -sha256sums=('8e3cf0bbf1062768134db2eb10ab774731ca5ec6694b65def82234bb0a9170fc' +sha256sums=('1978eedd975b1cf95bd4a04b2381560d1ad9a4223032717f23fac26e3458a760' 'SKIP' + '7b3d631c20a8de8d0bfd4de77e8ebeffa0bd0aa536abed713c36931ea4810926' 'bc00516032330760444939c516a60c78f868631e1b37f075f0fe71a53737b966') validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases @@ -29,6 +31,9 @@ prepare() { cd firefox-$pkgver mkdir obj patch -p1 -i ../arm.patch + + # Post-78 fixes to fix LTO with LLVM 11 + patch -Np1 -i ../lto-pgo.diff } build() { diff --git a/extra/js78/lto-pgo.diff b/extra/js78/lto-pgo.diff new file mode 100644 index 000000000..3b71b9400 --- /dev/null +++ b/extra/js78/lto-pgo.diff @@ -0,0 +1,92 @@ +diff --git i/build/moz.configure/lto-pgo.configure w/build/moz.configure/lto-pgo.configure +index 366c6691f7d1..e5342a037ee9 100644 +--- i/build/moz.configure/lto-pgo.configure ++++ w/build/moz.configure/lto-pgo.configure +@@ -229,7 +229,10 @@ def lto(value, c_compiler, ld64_known_good, target, instrumented_build): + # instruction sets. + else: + num_cores = multiprocessing.cpu_count() +- cflags.append("-flto") ++ if len(value) and value[0].lower() == 'full': ++ cflags.append("-flto") ++ else: ++ cflags.append("-flto=thin") + cflags.append("-flifetime-dse=1") + + ldflags.append("-flto=%s" % num_cores) +@@ -258,6 +261,6 @@ set_config('MOZ_LTO', lto.enabled) + set_define('MOZ_LTO', lto.enabled) + set_config('MOZ_LTO_CFLAGS', lto.cflags) + set_config('MOZ_LTO_LDFLAGS', lto.ldflags) +-set_config('MOZ_LTO_RUST', lto.rust_lto) ++set_config('MOZ_LTO_RUST_CROSS', lto.rust_lto) + add_old_configure_assignment('MOZ_LTO_CFLAGS', lto.cflags) + add_old_configure_assignment('MOZ_LTO_LDFLAGS', lto.ldflags) +diff --git i/config/makefiles/rust.mk w/config/makefiles/rust.mk +index b5c7973104ce..079408b358ed 100644 +--- i/config/makefiles/rust.mk ++++ w/config/makefiles/rust.mk +@@ -59,17 +59,19 @@ cargo_rustc_flags = $(CARGO_RUSTCFLAGS) + ifndef DEVELOPER_OPTIONS + ifndef MOZ_DEBUG_RUST + # Enable link-time optimization for release builds, but not when linking +-# gkrust_gtest. ++# gkrust_gtest. And not when doing cross-language LTO. ++ifndef MOZ_LTO_RUST_CROSS + ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE))) + cargo_rustc_flags += -Clto + endif + # Versions of rust >= 1.45 need -Cembed-bitcode=yes for all crates when + # using -Clto. + ifeq (,$(filter 1.38.% 1.39.% 1.40.% 1.41.% 1.42.% 1.43.% 1.44.%,$(RUSTC_VERSION))) + RUSTFLAGS += -Cembed-bitcode=yes + endif + endif + endif ++endif + + ifdef CARGO_INCREMENTAL + export CARGO_INCREMENTAL +@@ -185,10 +187,19 @@ target_rust_ltoable := force-cargo-library-build + target_rust_nonltoable := force-cargo-test-run force-cargo-library-check $(foreach b,build check,force-cargo-program-$(b)) + + ifdef MOZ_PGO_RUST +-rust_pgo_flags := $(if $(MOZ_PROFILE_GENERATE),-C profile-generate=$(topobjdir)) $(if $(MOZ_PROFILE_USE),-C profile-use=$(PGO_PROFILE_PATH)) ++ifdef MOZ_PROFILE_GENERATE ++rust_pgo_flags := -C profile-generate=$(topobjdir) ++# The C compiler may be passed extra llvm flags for PGO that we also want to pass to rust as well. ++# In PROFILE_GEN_CFLAGS, they look like "-mllvm foo", and we want "-C llvm-args=foo", so first turn ++# "-mllvm foo" into "-mllvm:foo" so that it becomes a unique argument, that we can then filter for, ++# excluding other flags, and then turn into the right string. ++rust_pgo_flags += $(patsubst -mllvm:%,-C llvm-args=%,$(filter -mllvm:%,$(subst -mllvm ,-mllvm:,$(PROFILE_GEN_CFLAGS)))) ++else # MOZ_PROFILE_USE ++rust_pgo_flags := -C profile-use=$(PGO_PROFILE_PATH) ++endif + endif + +-$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST),-Clinker-plugin-lto) $(rust_pgo_flags) ++$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST_CROSS),-Clinker-plugin-lto) $(rust_pgo_flags) + $(target_rust_nonltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) + + TARGET_RECIPES := $(target_rust_ltoable) $(target_rust_nonltoable) +@@ -302,17 +313,19 @@ $(RUST_LIBRARY_FILE): force-cargo-library-build + # When we are building in --enable-release mode; we add an additional check to confirm + # that we are not importing any networking-related functions in rust code. This reduces + # the chance of proxy bypasses originating from rust code. +-# The check only works when rust code is built with -Clto. ++# The check only works when rust code is built with -Clto but without MOZ_LTO_RUST_CROSS. + # Sanitizers and sancov also fail because compiler-rt hooks network functions. + ifndef MOZ_PROFILE_GENERATE + ifeq ($(OS_ARCH), Linux) + ifeq (,$(rustflags_sancov)$(MOZ_ASAN)$(MOZ_TSAN)$(MOZ_UBSAN)) ++ifndef MOZ_LTO_RUST_CROSS + ifneq (,$(filter -Clto,$(cargo_rustc_flags))) + $(call py_action,check_binary,--target --networking $@) + endif + endif + endif + endif ++endif + + force-cargo-library-check: + $(call CARGO_CHECK) --lib $(cargo_target_flag) $(rust_features_flag)