From 847c4e1028a27d28d4972d91962d0975fc642ffd Mon Sep 17 00:00:00 2001 From: Yureka Date: Sat, 14 Dec 2024 20:10:17 +0100 Subject: [PATCH] buildMozillaMach: re-enable elf-hack with LTO/LLD, disable with musl (#365185) The elfhack was completely revamped and is now implemented with the "relrhack", which is compatible with LLD: https://glandium.org/blog/?p=4297 Exposes a new option elfhackSupport and sets reasonable default based on the properties of the new relrhack. Change-Id: I687d4ee68a8e836e5c51a1fde0d28d019c0c66b9 --- .../networking/browsers/firefox/common.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 6a46a8ec82d2..34b4e82d59d0 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -25,6 +25,10 @@ let # Rename the variables to prevent infinite recursion requireSigningDefault = requireSigning; allowAddonSideloadDefault = allowAddonSideload; + + # Specifying --(dis|en)able-elf-hack on a platform for which it's not implemented will give `--disable-elf-hack is not available in this configuration` + # This is declared here because it's used in the default value of elfhackSupport + isElfhackPlatform = stdenv: stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64; in { lib @@ -110,6 +114,7 @@ in , jemallocSupport ? !stdenv.hostPlatform.isMusl, jemalloc , ltoSupport ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.is64bit && !stdenv.hostPlatform.isRiscV), overrideCC, buildPackages , pgoSupport ? (stdenv.hostPlatform.isLinux && stdenv.hostPlatform == stdenv.buildPlatform), xvfb-run +, elfhackSupport ? isElfhackPlatform stdenv && !(stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64) , pipewireSupport ? waylandSupport && webrtcSupport , pulseaudioSupport ? stdenv.hostPlatform.isLinux, libpulseaudio , sndioSupport ? stdenv.hostPlatform.isLinux, sndio @@ -160,6 +165,7 @@ in assert stdenv.cc.libc or null != null; assert pipewireSupport -> !waylandSupport || !webrtcSupport -> throw "${pname}: pipewireSupport requires both wayland and webrtc support."; +assert elfhackSupport -> isElfhackPlatform stdenv; let inherit (lib) enableFeature; @@ -402,9 +408,7 @@ buildStdenv.mkDerivation { "--enable-lto=cross" # Cross-Language LTO "--enable-linker=lld" ] - # elf-hack is broken when using clang+lld: - # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204 - ++ lib.optional (ltoSupport && (buildStdenv.hostPlatform.isAarch32 || buildStdenv.hostPlatform.isi686 || buildStdenv.hostPlatform.isx86_64)) "--disable-elf-hack" + ++ lib.optional (isElfhackPlatform stdenv) (enableFeature elfhackSupport "elf-hack") ++ lib.optional (!drmSupport) "--disable-eme" ++ lib.optional (allowAddonSideload) "--allow-addon-sideload" ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [