Firefox is a stand-alone browser based on the Mozilla codebase.
Development versions of BLFS may not build or run some packages properly if LFS or dependencies have been updated since the most recent stable versions of the books.
Download (HTTP): https://archive.mozilla.org/pub/firefox/releases/115.5.0esr/source/firefox-115.5.0esr.source.tar.xz
Download MD5 sum: d85e552e25f6fdd8ef38c9bc7fbf44f9
Download size: 489 MB
Estimated disk space required: 6.1 GB (209 MB installed) without tests
Estimated build time: 11 SBU using -j8, without tests
The directory name is firefox-115.5.0
Extracting the tarball
will reset the permissions of the current directory to 0755 if you
have permission to do that. If you do this in a directory where
the sticky bit is set, such
as /tmp
it will end with error
messages:
tar: .: Cannot utime: Operation not permitted
tar: .: Cannot change mode to rwxr-xr-t: Operation not permitted
tar: Exiting with failure status due to previous errors
This does finish with non-zero status, but it does
NOT mean there is a real problem.
Do not untar as the root
user
in a directory where the sticky bit is set - that will unset it.
As with other large packages which use C++ (or rust), the SBU times to build this vary more widely than you might expect. The build times will increase significantly if your machine has to swap.
Although upstream prefer to use PulseAudio, for the moment Alsa can still be used. Both may need runtime configuration to get sound working.
Cbindgen-0.26.0, dbus-glib-0.112, GTK+-3.24.38, libnotify-0.8.3, LLVM-17.0.1 (with clang, used for bindgen even if using gcc), nodejs-20.10.0, PulseAudio-16.1 (or alsa-lib-1.2.10 if you edit the mozconfig; now deprecated by mozilla), in either case please read the Configuration Information, Python-3.12.0 (rebuilt after installing SQLite-3.44.2), six-1.16.0, startup-notification-0.12, and UnZip-6.0
ICU-74.1, libevent-2.1.12, libvpx-1.13.1, libwebp-1.3.2, NASM-2.16.01, and nss-3.94
If you don't install recommended dependencies, then internal copies of those packages will be used. They might be tested to work, but they can be out of date or contain security holes.
cURL-8.4.0, Doxygen-1.9.8, FFmpeg-6.1 (runtime, to play mov, mp3 or mp4 files), liboauth-1.0.3, pciutils-3.10.0 (runtime), Valgrind-3.22.0, Wget-1.21.4, Wireless Tools-29, yasm-1.3.0, libproxy
Editor Notes: https://wiki.linuxfromscratch.org/blfs/wiki/firefox
The building system ships several internal copies of the Python 3
modules setuptools and
six.py
. The shipped copies are too old
to work well with Python 3.12 or later. Replace them with the
symlinks to the LFS setuptools package and
six-1.16.0 already installed on the system, and adapt the
building system for these updated Python modules. We also need to
rewrite the code based on the imp
module removed
in Python 3.12 and later using the importlib
module:
(for i in $(find -name six.py); do ln -sfv /usr/lib/python3.12/site-packages/six.py $i [ $? = 0 ] || exit $? done) && sed '/ConfigParser/s/Safe//' \ -i testing/mozbase/mozprofile/mozprofile/prefs.py && (for i in setuptools distutils-precedence.pth \ pkg_resources _distutils_hack; do rm -rf third_party/python/setuptools/$i && ln -sv /usr/lib/python3.12/site-packages/$i \ third_party/python/setuptools [ $? = 0 ] || exit $? done) && sed 's/distutils/setuptools._&/' \ -i python/mozbuild/mozbuild/nodeutil.py && sed -e '/^import/s/imp$/importlib.util/' \ -e 's/imp.new_module/__import__/' \ -e "s/imp.load_source\(.*\)/spec = \ importlib.util.spec_from_file_location\1; \ mod = importlib.util.module_from_spec(spec); \ spec.loader.exec_module(mod)/" -i python/mach/mach/main.py && sed '/import imp/d' -i netwerk/dns/prepare_tlds.py
If building with system ICU, adapt the line break mapping for ICU 74 or later:
(for i in {43..47}; do sed '/ZWJ/s/}/,CLASS_CHARACTER&/' -i intl/lwbrk/LineBreaker.cpp || exit $? done)
The configuration of Firefox is accomplished
by creating a mozconfig
file containing the desired
configuration options. A default mozconfig
is
created below. To see the entire list of available configuration options
(and an abbreviated description of some of them), issue ./mach
configure -- --help | less. You may also
wish to review the entire file and uncomment any other desired options.
Create the file by issuing the following command:
cat > mozconfig << "EOF"
# If you have a multicore machine, all cores will be used by default.
# If you have installed (or will install) wireless-tools, and you wish
# to use geolocation web services, comment out this line
ac_add_options --disable-necko-wifi
# API Keys for geolocation APIs - necko-wifi (above) is required for MLS
# Uncomment the following line if you wish to use Mozilla Location Service
#ac_add_options --with-mozilla-api-keyfile=$PWD/mozilla-key
# Uncomment the following line if you wish to use Google's geolocation API
# (needed for use with saved maps with Google Maps)
#ac_add_options --with-google-location-service-api-keyfile=$PWD/google-key
# startup-notification is required since firefox-78
# Uncomment the following option if you have not installed PulseAudio and
# want to use alsa instead
#ac_add_options --enable-audio-backends=alsa
# Comment out following options if you have not installed
# recommended dependencies:
ac_add_options --with-system-icu
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-webp
# Unlike with thunderbird, although using the gold linker can
# save four megabytes in the installed file it does not make
# the build faster.
# The libdav1d library (av1 decoder) requires nasm. Uncomment this
# if nasm has not been installed. Do not uncomment this if you have
# ffmpeg installed.
#ac_add_options --disable-av1
# You cannot distribute the binary if you do this.
ac_add_options --enable-official-branding
# Stripping is now enabled by default.
# Uncomment these lines if you need to run a debugger:
#ac_add_options --disable-strip
#ac_add_options --disable-install-strip
# Disabling debug symbols makes the build much smaller and a little
# faster. Comment this if you need to run a debugger. Note: This is
# required for compilation on i686.
ac_add_options --disable-debug-symbols
# The elf-hack is reported to cause failed installs (after successful builds)
# on some machines. It is supposed to improve startup time and it shrinks
# libxul.so by a few MB. With recent Binutils releases the linker already
# supports a much safer and generic way for this.
ac_add_options --disable-elf-hack
export LDFLAGS="$LDFLAGS -Wl,-z,pack-relative-relocs"
# The BLFS editors recommend not changing anything below this line:
ac_add_options --prefix=/usr
ac_add_options --enable-application=browser
ac_add_options --disable-crashreporter
ac_add_options --disable-updater
# Enabling the tests will use a lot more space and significantly
# increase the build time, for no obvious benefit.
ac_add_options --disable-tests
# This enables SIMD optimization in the shipped encoding_rs crate.
ac_add_options --enable-rust-simd
ac_add_options --enable-system-ffi
ac_add_options --enable-system-pixman
ac_add_options --with-system-jpeg
ac_add_options --with-system-png
ac_add_options --with-system-zlib
# Sandboxing works well on x86_64 but might cause issues on other
# platforms. If not on x86_64, e.g. i686, it is recommended to
# uncomment the following switch.
#ac_add_options --disable-sandbox
# Using sandboxed wasm libraries has been moved to all builds instead
# of only mozilla automation builds. It requires extra llvm packages
# and was reported to seriously slow the build. Disable it.
ac_add_options --without-wasm-sandboxed-libraries
# The following option unsets Telemetry Reporting. With the Addons Fiasco,
# Mozilla was found to be collecting user's data, including saved passwords and
# web form data, without users consent. Mozilla was also found shipping updates
# to systems without the user's knowledge or permission.
# As a result of this, use the following command to permanently disable
# telemetry reporting in Firefox.
unset MOZ_TELEMETRY_REPORTING
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-build-dir
EOF
Compile Firefox by issuing the following commands:
If the geolocation APIs are needed:
The Google and Mozilla API Keys below are specific to LFS. If using these instructions for another distro, or if you intend to distribute binary copies of the software using these instructions, please obtain your own keys following the instructions located at https://www.chromium.org/developers/how-tos/api-keys and https://location.services.mozilla.com/api respectively.
echo "AIzaSyDxKL42zsPjbke5O8_rPVpVrLrJ8aeE9rQ" > google-key echo "613364a7-9418-4c86-bcee-57e32fd70c23" > mozilla-key
If you are compiling this package in chroot you must
ensure that /dev/shm
is mounted. If you do not
do this, the Python configuration will fail
with a traceback report referencing
/usr/lib/pythonN.N/multiprocessing/synchronize.py
.
As the root
user, run:
mountpoint -q /dev/shm || mount -t tmpfs devshm /dev/shm
Now invoke the Python mach script to compile the package.
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none && export MOZBUILD_STATE_PATH=${PWD}/mozbuild && ./mach configure && ./mach build
The mozconfig
above disables the tests because
they use a lot more time and disk space for no obvious benefit. If
you have nevertheless enabled them, you can run the tests by executing
./mach gtest. This will require a network connection,
and to be run from within an Xorg session - there is a popup dialog
when it fails to connect to ALSA (that does not create a failed test).
One or two tests will fail. To see the details of the failure(s) you
will need to log the output from that command so that you can review it.
Now, as the root
user:
MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none ./mach install
Empty the environment variables which were set above:
unset MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE MOZBUILD_STATE_PATH
export MOZBUILD_STATE_PATH=${PWD}/mozbuild: The build
is now supposed to tell you that it intends to create ~/.mozbuild
, and offer you an option to
press <ENTER> to accept this, or Ctrl-C to cancel and restart the
build after specifying the directory. In practice, the message may not
appear until after <ENTER> is keyed, i.e. the build stalls.
That directory is used for a (probably random) telemetry identifier.
Creating this in the build directory, and deleting that after the
installation, prevents it being used. If you wish to participate in
telemetry, export MOZBUILD_STATE_PATH to point to its default directory
and remove the entry from the mozconfig
.
MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none: Use the system python to create a virtual environment for mach without downloading any python wheels nor using the system python modules. This prevents version mismatches between system modules and bundled ones.
./mach configure: This validates the supplied
dependencies and the mozconfig
.
./mach build --verbose
: Use this alternative if you
need details of which files are being compiled, together with any C or
C++ flags being used. But do not add '--verbose' to the install command
since it is not accepted there.
./mach build -jN
: The build should, by default, use
all the online CPU cores. If using all the cores causes the build to swap
because you have insufficient memory, using fewer cores can be faster.
: BLFS used to
prefer to use gcc and g++ instead of upstream's defaults of the
clang programs. With the release of
gcc-12 the build takes longer with gcc and g++, primarily because
of extra warnings, and is bigger. Set these environment variables
before you run the configure script
if you wish to continue to use gcc, g++. Building
with GCC on i?86 is currently broken.
CC=gcc CXX=g++
If you use a desktop environment like Gnome or
KDE you may want to create a
firefox.desktop
file so that
Firefox appears in the panel's menus.
As the root
user:
mkdir -pv /usr/share/applications &&
mkdir -pv /usr/share/pixmaps &&
MIMETYPE="text/xml;text/mml;text/html;" &&
MIMETYPE+="application/xhtml+xml;application/vnd.mozilla.xul+xml;" &&
MIMETYPE+="x-scheme-handler/http;x-scheme-handler/https" &&
cat > /usr/share/applications/firefox.desktop << EOF &&
[Desktop Entry]
Encoding=UTF-8
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Exec=firefox %u
Terminal=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=$MIMETYPE
StartupNotify=true
EOF
unset MIMETYPE &&
ln -sfv /usr/lib/firefox/browser/chrome/icons/default/default128.png \
/usr/share/pixmaps/firefox.png
The application settings for firefox are accessible by keying about:config in the address bar.
Occasionally, getting working sound in firefox can be a problem. Although upstream prefers pulseaudio, on balance using Alsa may be easier.
If you enabled Alsa for sound, you may need to alter one variable to get working sound. If you run firefox from a terminal and try to play something with sound you might encounter error messages like:
Sandbox: seccomp sandbox violation: pid 3941, tid 4030,
syscall 16, args 48 2147767296 139909894784796 0 0 0.
That was on x86_64, on i686 the syscall number is 54. To allow this syscall, in about:config change security.sandbox.content.syscall_whitelist to 16 (or 54 if using i686).
If you use pulseaudio in a Desktop Environment, it
might already be started by that DE. But if it is not, although
firefox-57 managed to start it, firefox-58 did not. If you run
firefox from a terminal and this problem is present,
trying to play sound will
encounter error messages warning Can't get cubeb
context!
The fix for this is to close firefox, start pulseaudio to check it
does start (if not, read the information on Configuring in PulseAudio-16.1) and restart firefox to check it is working.
If it now works, add the following to your ~/.xinitrc
:
pulseaudio --verbose --log-target=journald&
(unfortunately, on some systems this does not work).
You may wish to use multiple profiles within firefox. To do that, invoke firefox as firefox --ProfileManager. You can also check which profile is currently in use from about:profiles.
Although WebRender (using the GPU for compositing) is not used by default, it now appears to work well on supported hardware (ATI, Nvidia and Intel GPUs with Mesa-18 or later). For an explanation, please see hacks.mozilla.org. The only downside seems to be that on a machine with limited RAM it might use more RAM.
To check if WebRender is being used, look in about:support. In the Graphics section, Compositing will either show 'Basic' (i.e. not in use) or 'WebRender'. To enable it, go to about:config and change gfx.webrender.all to True. You will need to restart firefox.
It may be useful to mention the processes from firefox which can appear in top - as well as firefox itself, there may be multiple Web Content processes, and now an RDD Process (Remote Data Decoder) which appears when playing web videos encoded with av1 (libdav1d). If WebRender has been enabled, a GPU Process will also appear when firefox has to repaint (e.g. scrolling, opening a new tab, or playing a video).