@@ -2,9 +2,9 @@
22, src, unpackPhase ? null, patches ? []
33, extraNativeBuildInputs ? [], extraConfigureFlags ? [], extraMakeFlags ? [] }:
44
5−{ lib, stdenv, pkgconfig, pango, perl, python2, python3, zip
5+{ lib, stdenv, pkgconfig, pango, perl, python3, zip
66, libjpeg, zlib, dbus, dbus-glib, bzip2, xorg
7−, freetype, fontconfig, file, nspr, nss, nss_3_53, libnotify
7+, freetype, fontconfig, file, nspr, nss, nss_3_53
88, yasm, libGLU, libGL, sqlite, unzip, makeWrapper
99, hunspell, libXdamage, libevent, libstartup_notification
1010, libvpx_1_8
@@ -23,8 +23,7 @@
2323, ffmpegSupport ? true
2424, gtk3Support ? true, gtk2, gtk3, wrapGAppsHook
2525, waylandSupport ? true, libxkbcommon
26−# LTO is disabled since it caused segfaults on wayland see https://github.com/NixOS/nixpkgs/issues/101429
27−, ltoSupport ? false, overrideCC, buildPackages
26+, ltoSupport ? stdenv.isLinux, overrideCC, buildPackages
2827, gssSupport ? true, kerberos
2928, pipewireSupport ? waylandSupport && webrtcSupport, pipewire
3029
@@ -91,11 +90,19 @@ let
9190 then "/Applications/${binaryNameCapitalized}.app/Contents/MacOS"
9291 else "/bin";
9392
93+ # 78 ESR won't build with rustc 1.47
94+ inherit (if lib.versionAtLeast ffversion "82" then rustPackages else rustPackages_1_45)
95+ rustc cargo;
96+
9497 # Darwin's stdenv provides the default llvmPackages version, match that since
9598 # clang LTO on Darwin is broken so the stdenv is not being changed.
99+ # Target the LLVM version that rustc -Vv reports it is built with for LTO.
100+ # rustPackages_1_45 -> LLVM 10, rustPackages -> LLVM 11
96101 llvmPackages = if stdenv.isDarwin
97102 then buildPackages.llvmPackages
98− else buildPackages.llvmPackages_10;
103+ else if lib.versionAtLeast rustc.llvm.version "11"
104+ then buildPackages.llvmPackages_11
105+ else buildPackages.llvmPackages_10;
99106
100107 # When LTO for Darwin is fixed, the following will need updating as lld
101108 # doesn't work on it. For now it is fine since ltoSupport implies no Darwin.
@@ -103,10 +110,6 @@ let
103110 then overrideCC stdenv llvmPackages.lldClang
104111 else stdenv;
105112
106− # 78 ESR won't build with rustc 1.47
107− inherit (if lib.versionAtLeast ffversion "82" then rustPackages else rustPackages_1_45)
108− rustc cargo;
109−
110113 nss_pkg = if lib.versionOlder ffversion "83" then nss_3_53 else nss;
111114in
112115
@@ -121,13 +124,19 @@ buildStdenv.mkDerivation ({
121124 ] ++
122125 lib.optional (lib.versionOlder ffversion "83") ./no-buildconfig-ffx76.patch ++
123126 lib.optional (lib.versionAtLeast ffversion "84") ./no-buildconfig-ffx84.patch ++
127+ lib.optional (ltoSupport && lib.versionOlder ffversion "84") ./lto-dependentlibs-generation-ffx83.patch ++
128+ lib.optional (ltoSupport && lib.versionAtLeast ffversion "84" && lib.versionOlder ffversion "86")
129+ (fetchpatch {
130+ url = "https://hg.mozilla.org/mozilla-central/raw-rev/fdff20c37be3";
131+ sha256 = "135n9brliqy42lj3nqgb9d9if7x6x9nvvn0z4anbyf89bikixw48";
132+ })
124133
125134 # there are two flavors of pipewire support
126135 # The patches for the ESR release and the patches for the current stable
127136 # release.
128137 # Until firefox upstream stabilizes pipewire support we will have to continue
129138 # tracking multiple versions here.
130− lib.optional (pipewireSupport && lib.versionOlder ffversion "83")
139+ ++ lib.optional (pipewireSupport && lib.versionOlder ffversion "83")
131140 (fetchpatch {
132141 # https://src.fedoraproject.org/rpms/firefox/blob/master/f/firefox-pipewire-0-3.patch
133142 url = "https://src.fedoraproject.org/rpms/firefox/raw/e99b683a352cf5b2c9ff198756859bae408b5d9d/f/firefox-pipewire-0-3.patch";
@@ -157,7 +166,7 @@ buildStdenv.mkDerivation ({
157166 gtk2 perl zip libjpeg zlib bzip2
158167 dbus dbus-glib pango freetype fontconfig xorg.libXi xorg.libXcursor
159168 xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
160− libnotify xorg.pixman yasm libGLU libGL
169+ xorg.pixman yasm libGLU libGL
161170 xorg.xorgproto
162171 xorg.libXext unzip makeWrapper
163172 libevent libstartup_notification /* cairo */
@@ -173,24 +182,17 @@ buildStdenv.mkDerivation ({
173182 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
174183 ++ lib.optional gtk3Support gtk3
175184 ++ lib.optional gssSupport kerberos
176− ++ lib.optional ltoSupport llvmPackages.libunwind
177− ++ lib.optionals waylandSupport [ libxkbcommon ]
178− ++ lib.optionals pipewireSupport [ pipewire ]
179− ++ lib.optionals (lib.versionAtLeast ffversion "82") [ gnum4 ]
185+ ++ lib.optional waylandSupport libxkbcommon
186+ ++ lib.optional pipewireSupport pipewire
187+ ++ lib.optional (lib.versionAtLeast ffversion "82") gnum4
180188 ++ lib.optionals buildStdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
181189 AVFoundation MediaToolbox CoreLocation
182190 Foundation libobjc AddressBook cups ];
183191
184192 NIX_LDFLAGS = lib.optionalString ltoSupport ''
185− -rpath ${placeholder "out"}/lib/${binaryName}
186193 -rpath ${llvmPackages.libunwind.out}/lib
187194 '';
188195
189− NIX_CFLAGS_COMPILE = toString [
190− "-I${glib.dev}/include/gio-unix-2.0"
191− "-I${nss_pkg.dev}/include/nss"
192− ];
193−
194196 MACH_USE_SYSTEM_PYTHON = "1";
195197
196198 postPatch = ''
@@ -202,7 +204,7 @@ buildStdenv.mkDerivation ({
202204 substituteInPlace \
203205 media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build \
204206 --replace /usr/include ${pipewire.dev}/include
205− '' + lib.optionalString (lib.versionAtLeast ffversion "80") ''
207+ '' + lib.optionalString (lib.versionAtLeast ffversion "80" && lib.versionOlder ffversion "81") ''
206208 substituteInPlace dom/system/IOUtils.h \
207209 --replace '#include "nspr/prio.h"' '#include "prio.h"'
208210
@@ -221,7 +223,6 @@ buildStdenv.mkDerivation ({
221223 nodejs
222224 perl
223225 pkgconfig
224− python2
225226 python3
226227 rust-cbindgen
227228 rustc
@@ -323,6 +324,13 @@ buildStdenv.mkDerivation ({
323324 "MOZILLA_OFFICIAL=1"
324325 "BUILD_OFFICIAL=1"
325326 ]
327+ ++ lib.optionals ltoSupport [
328+ "AR=${llvmPackages.bintools}/bin/llvm-ar"
329+ "LLVM_OBJDUMP=${llvmPackages.bintools}/bin/llvm-objdump"
330+ "NM=${llvmPackages.bintools}/bin/llvm-nm"
331+ "RANLIB=${llvmPackages.bintools}/bin/llvm-ranlib"
332+ "STRIP=${llvmPackages.bintools}/bin/llvm-strip"
333+ ]
326334 ++ extraMakeFlags;
327335
328336 enableParallelBuilding = true;
@@ -341,18 +349,6 @@ buildStdenv.mkDerivation ({
341349 gappsWrapperArgs+=(--argv0 "$out/bin/.${binaryName}-wrapped")
342350 '';
343351
344− postFixup = lib.optionalString buildStdenv.isLinux ''
345− # Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
346− patchelf --set-rpath "${lib.getLib libnotify
347− }/lib:$(patchelf --print-rpath "$out"/lib/${binaryName}*/libxul.so)" \
348− "$out"/lib/${binaryName}*/libxul.so
349− patchelf --add-needed ${xorg.libXScrnSaver.out}/lib/libXss.so $out/lib/${binaryName}/${binaryName}
350− ${lib.optionalString (pipewireSupport && lib.versionAtLeast ffversion "83") ''
351− patchelf --add-needed "${lib.getLib pipewire}/lib/libpipewire-0.3.so" \
352− "$out"/lib/${binaryName}/${binaryName}
353− ''}
354− '';
355−
356352 doInstallCheck = true;
357353 installCheckPhase = ''
358354 # Some basic testing
@@ -365,6 +361,7 @@ buildStdenv.mkDerivation ({
365361 isFirefox3Like = true;
366362 gtk = gtk2;
367363 inherit alsaSupport;
364+ inherit pipewireSupport;
368365 inherit nspr;
369366 inherit ffmpegSupport;
370367 inherit gssSupport;