Firefox 95 on POWER

Date: 2021-12-09T21:34:00-08:00


Firefox 95 is released,

screenshot at right

. The big new feature, besides speculative AOT JIT which doesn't apply to us yet, is RLBox, which compiles certain third-party libraries into safe WebAssembly, and then compiles them back into C, so they can be compiled a third time into pre-sanitized native code. This has obvious security benefits and the performance impact shouldn't be especially large, but it adds yet another build-time prerequisite: the WASI SDK. This kind of really sucks because now you have to have a third toolchain (it builds one whether you like it or not) besides


and our preferred compiler,


. Pending internal package support, some distros have chosen simply to disable this for the immediate future, even including Fedora.

Besides the inconvenience the other main issue with this is while it's clearly safer native code, it's also slower native code by some non-zero factor, however small in a well-optimized PGO-LTO build. As such I've chosen to test to make sure it works but my "official" PGO-LTO build configs will have it turned off for the time being with --without-wasm-sandboxed-libraries. While it was very easy to build the smaller WASI libc, it doesn't have C++ headers, so the build goes bang if you try to use it as a WASI sysroot. Fortunately you can download a pre-built copy of the SDK and just pull out the system-independent wasi-sysroot and feed that to the Firefox build system with --with-wasi-sysroot=/where/it/at/wasi-sysroot. Then, to get the built-ins for linking pull out libclang_rt.builtins-wasm32.a and copy it to /usr/lib64/clang/13.0.0/lib/wasi (or wherever your clang libraries reside), and ensure you have wasm-lld. You may have to install lld to get wasm-ld; I had to, but Fedora has a package for it already. Now that you've looted the archive, you can just trash the rest of it and use your system version of clang assuming it's version 8+. This works and makes a functional version of Firefox but I can totally understand why this is unacceptable if you want to build from the raw source code.

After all that, though, I'm running Firefox 95 without RLBox simply because we need to wring all the performance out of the executable that we can. As such, here are the current .mozconfigs.


export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

mk_add_options MOZ_MAKE_FLAGS="-j24" # or as you like
ac_add_options --enable-application=browser
ac_add_options --enable-optimize="-Og -mcpu=power9 -fpermissive"
ac_add_options --enable-debug
ac_add_options --enable-linker=bfd
ac_add_options --without-wasm-sandboxed-libraries

export GN=/home/censored/bin/gn # if you haz


export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

mk_add_options MOZ_MAKE_FLAGS="-j24"
ac_add_options --enable-application=browser
ac_add_options --enable-optimize="-O3 -mcpu=power9 -fpermissive"
ac_add_options --enable-release
ac_add_options --enable-linker=bfd
ac_add_options --enable-lto=full
ac_add_options --without-wasm-sandboxed-libraries
ac_add_options MOZ_PGO=1

export GN=/home/censored/bin/gn

The PGO-LTO build patch is also updated.

Oh, by the way, in JIT news, I've mounted a debug browser and OpenPOWER Firefox can now run Doom. (Firefox 91 ESR shown.)

Still some glitches to work out, some of which I suspect aren't anything to do with Wasm support, but you couldn't do this on Firefox on OpenPOWER before. Does this count as a "Tonight's Game on OpenPOWER" entry? (*Firefox on Windows 95 screenshot from Beta Archive.)