Skip to content

Commit

Permalink
buildMozillaMach: re-enable elf-hack with LTO/LLD, disable with musl (N…
Browse files Browse the repository at this point in the history
…ixOS#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
  • Loading branch information
yuyuyureka authored Dec 14, 2024
1 parent 210bae9 commit 847c4e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkgs/applications/networking/browsers/firefox/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) [
Expand Down

0 comments on commit 847c4e1

Please sign in to comment.