Compiled on PI4B4G with 5.10.77-piCore-v8 on SD card F2FS filesystem (10G clean partition, 6.5G available after extraction) References: Firefox options https://wiki.mozilla.org/Linux/Compiler_Options This FLAG helps in size, defined in mozxonfig (-finline-limit=64) https://pcxfirefox.wordpress.com/2016/04/16/firefox-on-android-some-compiler-and-linker-switch-onoff/ Tell Rust to optimize for size https://firefox-source-docs.mozilla.org/setup/configuring_build_options.html https://doc.rust-lang.org/rustc/codegen-options/index.html#opt-level Enable LTO with both C/C++ and Rust (Cross-language LTO) https://bugzilla.mozilla.org/show_bug.cgi?id=1546438 --> ERROR: Cross-language LTO is not supported with GCC What is Cross-language LTO https://blog.llvm.org/2019/09/closing-gap-cross-language-lto-between.html Increase the Ulimit for linker (not tested) https://hubicka.blogspot.com/2018/12/firefox-64-built-with-gcc-and-clang.html https://developers.redhat.com/blog/2020/03/18/cross-language-link-time-optimization-using-red-hat-developer-tools#example__firefox Compile Flags: CC='clang -march=armv8-a+crc -mtune=cortex-a72 -L/usr/local/lib' CXX='clang++ -march=armv8-a+crc -mtune=cortex-a72 -L/usr/local/lib' LDFLAGS='-Wl,-O1' export CC CXX LDFLAGS Dependencies: (pixz is optional, but tar is required) # before loading dependencies, block icu just in case $ touch /usr/local/tce.installed/icu $ tce-load -i ... alsa alsa-utils autoconf cbindgen compiletc clang curl-dev dbus-glib-dev libevent-dev lld llvm-dev gtk3-dev icu70-dev libXt-dev libasound-dev libnotify-dev libwebp-dev node-dev nss-dev pixz startup-notification-dev tar unzip zip Commands: # LLVM setup # check which LTO plugin we are using # not using the GCC one, liblto_plugin.so # 1 file only, remove any other plugins that might be picked up ls /usr/local/lib/bfd-plugins/ LLVMgold.so # replace strip with llvm sudo ln -sfv /usr/local/bin/llvm-strip /usr/local/bin/strip # make sure /usr/local/bin/llvm-config is a binary sudo cp /tmp/tcloop/llvm-dev/usr/local/bin/llvm-config /usr/local/bin/llvm-config # source code # F2FS partition root directory is writable by average user time tar -I pixz -xf /mnt/sda1/compile/firefox/firefox-91.7.0esr.source.tar.xz -C /mnt/mmcblk0p3/ real 3m 50.44s user 0m 59.99s sys 0m 43.21s mv /mnt/mmcblk0p3/firefox-91.7.0 /mnt/mmcblk0p3/firefox-lto cd /mnt/mmcblk0p3/firefox-lto time tar -I pixz -xf /mnt/mmcblk0p2/compile/firefox-aarch64/firefox-91.7.0esr.source.tar.xz -C /mnt/sda1/ real 15m 9.82s user 1m 3.72s sys 0m 53.28s mv /mnt/sda1/firefox-91.7.0 /mnt/sda1/firefox-cross cd /mnt/sda1/firefox-cross # This patch is required for LTO build patch -Np1 -i /tmp/firefox-91.7.0esr-disable_rust_test-1.patch # export variables # llvm binaries AR='llvm-ar' NM='llvm-nm' RANLIB='llvm-ranlib' export AR NM RANLIB # PATH and compile flags # you need to tell the mach build system to search library in /usr/local/lib PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' CC='clang -march=armv8-a+crc -mtune=cortex-a72 -L/usr/local/lib' CXX='clang++ -march=armv8-a+crc -mtune=cortex-a72 -L/usr/local/lib' LDFLAGS='-Wl,-O1' export CC CXX LDFLAGS PATH # Miscellaneous # Tell Rust to optimize for size RUSTC_OPT_LEVEL='s' MOZBUILD_STATE_PATH="${PWD}/mozbuild" MACH_USE_SYSTEM_PYTHON='1' export RUSTC_OPT_LEVEL MOZBUILD_STATE_PATH MACH_USE_SYSTEM_PYTHON # mozconfig cross language LTO cp /tmp/mozconfig.cross mozconfig # mach build # just in case, a 'make clean' equivalent time ./mach clobber real 0m 9.17s user 0m 6.46s sys 0m 1.45s # configure time ./mach configure 1:35.08 Total wall time: 45.57s; CPU time: 36.86s; Efficiency: 81%; Untracked: 1.27s Configure complete! Be sure to run |mach build| to pick up any changes real 1m 37.69s user 1m 8.45s sys 0m 21.97s # make # if you need verbose output --> time ./mach -v --log-file /tmp/firefox.log build time ./mach build real 10h 46m 03s user 29h 44m 06s sys 32m 4.55s DESTDIR=/tmp/packing-firefox time ./mach -v install real 0m 28.68s user 0m 13.87s sys 0m 6.11s # for future reference (might be affected by libpng) du -bhd0 /tmp/packing-firefox 185.8M /tmp/packing-firefox # success build with libpng du -bhd0 /tmp/packing-firefox/ 185.7M /tmp/packing-firefox/ # add a soft link so ondemand can load this directly cd /tmp/packing-firefox/usr/local/bin ln -s /usr/local/lib/firefox/firefox firefox-perf