Some notes on building Firefox from source on Ubuntu

June 21, 2021

I'm accustomed to being able to build an Ubuntu packaged program from its upstream source by doing 'apt-get build-dep <package>' and then following the upstream's build process (well, for the version that Ubuntu packages; later versions may have additional dependencies). Ubuntu packages the latest version of Firefox on all LTS releases because it has no real choice. This forces Ubuntu to update Rust to relatively current versions even on LTS releases, and in theory it should force Ubuntu to also package and update all of the other programs, which would let us just build from the upstream source of the current Firefox. As I've learned the hard way, this doesn't work, even if you've used rustup to have your own copy of Rust and Cargo. Today I spent a bit of time digging into the deb/* control files and patches in the Ubuntu 18.04 Firefox source package, and now I understand more about how to do this.

If you try to build Firefox from source on 18.04 even for Firefox 78 ESR, you will almost immediately run into an issue where the Ubuntu 18.04 version of nodejs is far too old (this isn't the only issue you'll hit if you try to build Firefox 78). There's also the problem that you can't build support for AV1 video because the 18.04 version of nasm is also too old. It turns out that Ubuntu has packaged special, more up to date versions of both of these just for building Firefox, as the nasm-mozilla and nodejs-mozilla packages. To tell your own Firefox build to use them, you need to set two options in your .mozconfig:

ac_add_options NODEJS=/usr/lib/nodejs-mozilla/bin/node
ac_add_options NASM=/usr/lib/nasm-mozilla/bin/nasm

(The Ubuntu 18.04 template mozconfig used in a source package build is mozconfig.in. You may find it interesting to look through, depending on what your objectives are in building Firefox from source on Ubuntu. The full Debian control directory is here.)

Ubuntu 18.04 has a further trick that's relevant if you haven't set up your own versions of Rust and Cargo, which is that in their relax-cargo-dep.patch they lower the necessary version of Cargo down to the version they package on 18.04, which is one version behind their Rust (currently Rust 1.47.0 but Cargo 1.46.0; the versions are normally in sync).

Ubuntu 20.04's mozconfig.in still uses the nodejs-mozilla version of nodejs, but it no longer needs a special NASM version (at least for now). It also still has the relax-cargo-dep.patch. The overall Ubuntu 20.04 Debian control directory is here. I'm a little bit surprised that Ubuntu hasn't yet been forced to update both Rust and Cargo on 18.04 and 20.04, but it's probably coming in some future Firefox release. Firefox is very enthusiastic about requiring quite current versions of both.

(Firefox Nightly recently switched to require Rust 1.51.0 (and thus the same version of Cargo). The current Firefox Beta source tree, here, still seems to only require 1.47.0; see python/mozboot/mozboot/util.py. The bump in Nightly is from bug #1715282, which has a discussion of what has triggered it.)

My personal view is that if you're building the current released version of Firefox from source, you should probably use your own Rust and Cargo (from Rustup). This spares you from having to patch in a special case to accept an older Cargo, so all you need is the build-deps and the one or two .mozconfig settings (two on 18.04, but just the nodejs on 20.04 for now).

(And in the future if Firefox stops building from source for me on whatever Ubuntu LTS I care about at the time, at least I now have written down some starting points for investigation.)

Written on 21 June 2021.
« A bit on ZFS's coming raidz expansion and ZFS DVAs
A realization about our VPN and IPv6 traffic »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Jun 21 00:09:58 2021
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.