commit: 352d3c1982a73e40da5dd7161207e6973c001413 Author: Joonas Niilola <juippis <AT> gentoo <DOT> org> AuthorDate: Sat Nov 16 12:27:41 2024 +0000 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org> CommitDate: Sat Nov 16 13:11:49 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=352d3c19
www-client/firefox: enable wasm on 132.0.2 - Adds "wasm" support to compile certain third-party libraries with WebAssembly using Mozilla's RLBox. - It requires an external wasi toolchain which is not packaged in Gentoo (and I didn't wish to become a maintainer of a new toolchain), therefore the ebuild currently downloads and uses a pre-built package directly from upstream. They only provide pre-built packages for amd64 (x86_64) and arm64. This is the first step to getting wasm sandboxed libraries to work in Gentoo, work isn't finished but good enough to be shipped. Currently system-graphite2 doesn't work with wasm, but building Firefox doesn't require any user action related to this. - Also disconnect clang pgo toolchain check from lld - it's probably a remnant from times when lto was required to build with pgo. Closes: https://bugs.gentoo.org/940031 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/39343 www-client/firefox/Manifest | 3 ++ www-client/firefox/firefox-132.0.2.ebuild | 60 ++++++++++++++++++++++++------- www-client/firefox/metadata.xml | 3 +- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/www-client/firefox/Manifest b/www-client/firefox/Manifest index 8515a056fb76..65609c71063c 100644 --- a/www-client/firefox/Manifest +++ b/www-client/firefox/Manifest @@ -202,6 +202,7 @@ DIST firefox-128.4.0esr-zh-TW.xpi 672066 BLAKE2B 3e90953b69d12ad01f0a4aa7d48d187 DIST firefox-128.4.0esr.source.tar.xz 558619512 BLAKE2B 1f0528c8806bb034af623f2022740bb5056ea11817b9cb7154a60b87f04051ba5ae06b0daf55e6b03b7531c369deb871d3d3579a86f3ca19f3ab71ccb45243f9 SHA512 e720b1f993926d73f5a5727648f753176ac2fd093fb0b71393946bbc5919ce5fc7b88b82960bd1aa427b5663c7f659828dc6702485fc0c1e7a6961571c67faa3 DIST firefox-128esr-patches-04.tar.xz 14416 BLAKE2B 0ffe3fd568480e37fe28fe71d5304e51028dcb8cb2d5fc1d838d725bdd36971696d7152c37bd90f7802c75e696aef0b1b075d386a906b40635f25083a6a58239 SHA512 adbac956dc2d6c1c29fb6641a42096bfd033a662f69e177f8d75a928f46d30fbc811e8a9ca24de8c7eb675ee80f6c1187f1a13dbca8e75782abfd54e276f5854 DIST firefox-132-patches-02.tar.xz 14984 BLAKE2B 9ae56d19ba391bbc53a6babc72bf956c7bfda293aec52f5b1af3994238494d9c311e943593f6d8c2b89f7b24a50281f07248e684a6a6ec4a3f54ba1792125faf SHA512 9299d41830d91ebe558229149afbf66ade18f3925d5d30a603eec6115a16ce4d5e6c0a03193e0967ecad35fe4bfc1bc639f858a6df44372132541fd1aff149b3 +DIST firefox-132-patches-04.tar.xz 15164 BLAKE2B a485bd2f57220727ec4447def964d2fba0f2d3421e35644906dc20fdf5aa086d13952d4270b16a8268518ae21ff77c7e47c6093559b901c3542cc0e5bc1ced57 SHA512 1077439c4db0dbd7f415fcbb74a37d535483c1f9953c66770cbc4ed221f8e68c17d2cd897f3a07736924e9b17d18f2a1b8be6336b9e61a42dc69d54b7b469fcb DIST firefox-132.0.1-ach.xpi 467451 BLAKE2B cad4ed35bfd827d5e629cf478d46b85b9547728555aeccc684238caab763149eabed9771f05e4906923f1b7119190022e39e32fbe3ef0d41a95c1604a6582764 SHA512 6a1a50a19dbdc9198dd6336b53ca9e906a48e3f880d176a3e3d9b29559c0780868b18a2002c57dccaff901b651978c2cc6a4a7f3373dfe4a4ef77be630e0ebd3 DIST firefox-132.0.1-af.xpi 420465 BLAKE2B 7b03a69f9f0181c196e3abf7e34d21c377d1fdf7f6b88c78b651447afbdfc73c8552185196dfc7d8c9228295c4db703a85e59646ff1aa134b7a5e66543c570f9 SHA512 b512c7a8f003733b1aea47ec3f7a85e91ece4cea381dc254da07a5cbc9c5dab0036d2fa11043754f97fa25dc112c545aac42c396c60cbfaa054119e0e053d9df DIST firefox-132.0.1-an.xpi 509134 BLAKE2B dfbf3a030c2e7771676828253d2f6afc0f8f3b03afbab29a2141941ebb3638eb7fd9bcab09c1500181e997f77394fb3dcc740bbdfc0794edb13d9a26f1765744 SHA512 401323ffd2319dc50e06b2e923971b8f14dfc99e3623d06f196069f015b46b7eacfdb21f6bd57d59125db1eca2be4409804f88ab2b0d682c2ef21b727beb4505 @@ -404,3 +405,5 @@ DIST firefox-132.0.2-xh.xpi 420611 BLAKE2B d4bcbd524706fcc5a75d94854f9890bc7ae90 DIST firefox-132.0.2-zh-CN.xpi 676660 BLAKE2B 1887a9b7c49de2b8da5b30325b6d1b84e2b10fdddc90063cf0e84ecf39808ff0dab0ac5037456427b1c617e7d8c76bad3cafcbfc81d781be6232edf0f1d19c3f SHA512 bbbac92eec43da48674d2b693a19e8f1c839a08214971b7d90f1fc196165240cc9f1d723506146adecc4286b8b897a52332242a57c32a3e256018859169472ba DIST firefox-132.0.2-zh-TW.xpi 680268 BLAKE2B c421f438fec53fcc1851f076e0394a7ca5559511dd9d35da0ac85aabffa9acf57cfe00ff2174c83fe83e2a58c626bbff474591778b8ac18d0965e6524b9a07bc SHA512 65ed54c87a62ccd4253f115752f1c2d4d276156306624f2d24f010015dfbb0e26a5a18755bbb9d44124f5a0dd483a1819a72edcdd06f69b6ca67d50eefc87f0d DIST firefox-132.0.2.source.tar.xz 570535648 BLAKE2B d71b0e074ad2f299dc5b4291e9af012f54e52d71f029648aa4367a17227e7a9d4c22fc6ab3b834c4adc1c82e155a4cefeedce84f04045c56b03a0ca1689340a4 SHA512 9ea95d9fb1a941ac5a5b50da67e224f3ccf8c401f26cb61bb74ad7f4e1e8706d469c4b6325714f2cb9cdf50c32710377d6bca18dd65b55db2c39ef2b27a57fae +DIST wasi-sdk-24.0-arm64-linux.tar.gz 119660865 BLAKE2B 5067fe0d63a8be0e3466131a7f1e0a92185e09879e5256b8d12428606920fb074198d7c5b4f949466f5179852f53911333baf8fb2409068de4a9a6c4d62bbd96 SHA512 412df3d066ef4a175bc5a10353d4bf853c6aee101a024b84b2fc10c1e2a48c0dde1b7162c08a56726861a5b5b9838c05da75c5069d3454513ed862ba3f4629bc +DIST wasi-sdk-24.0-x86_64-linux.tar.gz 118879731 BLAKE2B 385dced143f463427e48839b4c9a810161b2791f0a1a335ad53b1cff9e20fd004b1c24c80443ec213f448dc31a5b1748f447569161c88ca8fc01b3bf35421aa6 SHA512 e320e1d3965324dcc435aab15e0ec3597dae914fae9634af4e7181a76609d35fd01cdca07621f39a6c894b528055e2d014ce0c1fcfe23a154343f51fb48928bc diff --git a/www-client/firefox/firefox-132.0.2.ebuild b/www-client/firefox/firefox-132.0.2.ebuild index 339d343491f9..d20c7fd48226 100644 --- a/www-client/firefox/firefox-132.0.2.ebuild +++ b/www-client/firefox/firefox-132.0.2.ebuild @@ -3,7 +3,7 @@ EAPI=8 -FIREFOX_PATCHSET="firefox-132-patches-02.tar.xz" +FIREFOX_PATCHSET="firefox-132-patches-04.tar.xz" LLVM_COMPAT=( 17 18 19 ) @@ -20,6 +20,11 @@ WANT_AUTOCONF="2.1" VIRTUALX_REQUIRED="manual" +# Information about the bundled wasm toolchain from +# https://github.com/WebAssembly/wasi-sdk/ +WASI_SDK_VER=24.0 +WASI_SDK_LLVM_VER=18 + MOZ_ESR= MOZ_PV=${PV} @@ -63,7 +68,12 @@ PATCH_URIS=( DESCRIPTION="Firefox Web Browser" SRC_URI="${MOZ_SRC_BASE_URI}/source/${MOZ_P}.source.tar.xz -> ${MOZ_P_DISTFILES}.source.tar.xz - ${PATCH_URIS[@]}" + ${PATCH_URIS[@]} + wasm? ( + amd64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-x86_64-linux.tar.gz ) + arm64? ( https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER/.*/}/wasi-sdk-${WASI_SDK_VER}-arm64-linux.tar.gz ) + )" + S="${WORKDIR}/${PN}-${PV%_*}" LICENSE="MPL-2.0 GPL-2 LGPL-2.1" KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86" @@ -74,7 +84,7 @@ IUSE+=" +system-jpeg +system-libevent +system-libvpx system-png +system-webp val IUSE+=" wifi +X" # Firefox-only IUSE -IUSE+=" +gmp-autoupdate gnome-shell +telemetry" +IUSE+=" +gmp-autoupdate gnome-shell +telemetry wasm" REQUIRED_USE="|| ( X wayland ) debug? ( !system-av1 ) @@ -224,13 +234,13 @@ llvm_check_deps() { einfo "sys-devel/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 return 1 fi + fi - if use pgo ; then - if ! has_version -b "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then - einfo "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 - einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 - return 1 - fi + if use pgo ; then + if ! has_version -b "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then + einfo "=sys-libs/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!" >&2 + einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2 + return 1 fi fi @@ -609,10 +619,28 @@ src_prepare() { elif use ppc64 ; then export RUST_TARGET="powerpc64le-unknown-linux-musl" else - die "Unknown musl chost, please post your rustc -vV along with emerge --info on Gentoo's bug #915651" + die "Unknown musl chost, please post a new bug with your rustc -vV along with emerge --info" fi fi + # Pre-built wasm path manipulation. + if use wasm ; then + if use amd64 ; then + export wasi_arch="x86_64" + elif use arm64 ; then + export wasi_arch="arm64" + else + die "wasm enabled on unknown/unsupported arch!" + fi + + sed -i \ + -e "s:%%PORTAGE_WORKDIR%%:${WORKDIR}:" \ + -e "s:%%WASI_ARCH%%:${wasi_arch}:" \ + -e "s:%%WASI_SDK_VER%%:${WASI_SDK_VER}:" \ + -e "s:%%WASI_SDK_LLVM_VER%%:${WASI_SDK_LLVM_VER}:" \ + toolkit/moz.configure || die "Failed to update wasi-related paths." + fi + # Make LTO respect MAKEOPTS sed -i -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \ "${S}"/build/moz.configure/lto-pgo.configure || die "Failed sedding multiprocessing.cpu_count" @@ -778,7 +806,6 @@ src_configure() { --prefix="${EPREFIX}/usr" \ --target="${CHOST}" \ --without-ccache \ - --without-wasm-sandboxed-libraries \ --with-intl-api \ --with-libclang-path="$(llvm-config --libdir)" \ --with-system-nspr \ @@ -852,7 +879,6 @@ src_configure() { mozconfig_use_with system-av1 mozconfig_use_with system-harfbuzz - mozconfig_use_with system-harfbuzz system-graphite2 mozconfig_use_with system-icu mozconfig_use_with system-jpeg mozconfig_use_with system-libevent @@ -894,6 +920,16 @@ src_configure() { mozconfig_add_options_ac '+x11' --enable-default-toolkit=cairo-gtk3-x11-only fi + # wasm + # +system-graphite2 doesn't currently play nice with wasm. + if use wasm ; then + mozconfig_add_options_ac '+wasm' --with-wasi-sysroot="${WORKDIR}/wasi-sdk-${WASI_SDK_VER}-${wasi_arch}-linux/share/wasi-sysroot/" + else + mozconfig_add_options_ac 'no wasm-sandbox' --without-wasm-sandboxed-libraries + mozconfig_use_with system-harfbuzz system-graphite2 + fi + + if [[ ${use_lto} == "yes" ]] ; then if use clang ; then # Upstream only supports lld or mold when using clang. diff --git a/www-client/firefox/metadata.xml b/www-client/firefox/metadata.xml index 2e477393e06d..a24bfdb7d8de 100644 --- a/www-client/firefox/metadata.xml +++ b/www-client/firefox/metadata.xml @@ -25,7 +25,7 @@ <flag name="system-av1">Use the system-wide <pkg>media-libs/dav1d</pkg> and <pkg>media-libs/libaom</pkg> library instead of bundled</flag> <flag name="system-harfbuzz">Use the system-wide <pkg>media-libs/harfbuzz</pkg> - and <pkg>media-gfx/graphite2</pkg> instead of bundled</flag> + instead of bundled and <pkg>media-gfx/graphite2</pkg> in most cases</flag> <flag name="system-icu">Use the system-wide <pkg>dev-libs/icu</pkg> instead of bundled</flag> <flag name="system-jpeg">Use the system-wide <pkg>media-libs/libjpeg-turbo</pkg> @@ -39,6 +39,7 @@ <flag name="system-python-libs">Use system's python site instead of bundled python libraries</flag> <flag name="system-webp">Use the system-wide <pkg>media-libs/libwebp</pkg> instead of bundled</flag> + <flag name="wasm">Sandbox certain third-party libraries through WebAssembly using RLBox</flag> <flag name="wifi">Enable necko-wifi for NetworkManager integration, and access point MAC address scanning for better precision with opt-in geolocation services</flag> </use>
