summary refs log tree commit diff
path: root/pkgs/applications/networking/browsers/firefox/common.nix
diff options
context:
space:
mode:
authorYureka <yuka@yuka.dev>2022-08-15 11:50:26 +0200
committerYureka <yuka@yuka.dev>2023-04-26 16:30:41 +0200
commit94ccd5fdf85adbedf1284cc0b2dccb093bea1377 (patch)
treea535fc7964ca128819cb76f4d29c899392595507 /pkgs/applications/networking/browsers/firefox/common.nix
parent5298406accd79af5e12f13a46f0805eaf78f1d55 (diff)
downloadnixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar.gz
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar.bz2
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar.lz
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar.xz
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.tar.zst
nixpkgs-94ccd5fdf85adbedf1284cc0b2dccb093bea1377.zip
pkgsMusl.firefox: fix build
Diffstat (limited to 'pkgs/applications/networking/browsers/firefox/common.nix')
-rw-r--r--pkgs/applications/networking/browsers/firefox/common.nix22
1 files changed, 19 insertions, 3 deletions
diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix
index ce69742a3f6..510893c9141 100644
--- a/pkgs/applications/networking/browsers/firefox/common.nix
+++ b/pkgs/applications/networking/browsers/firefox/common.nix
@@ -30,6 +30,7 @@
 , cargo
 , dump_syms
 , makeWrapper
+, mimalloc
 , nodejs
 , perl
 , pkg-config
@@ -88,9 +89,9 @@
 , ffmpegSupport ? true
 , gssSupport ? true, libkrb5
 , jackSupport ? stdenv.isLinux, libjack2
-, jemallocSupport ? true, jemalloc
+, jemallocSupport ? !stdenv.hostPlatform.isMusl, jemalloc
 , ltoSupport ? (stdenv.isLinux && stdenv.is64bit && !stdenv.hostPlatform.isRiscV), overrideCC, buildPackages
-, pgoSupport ? (stdenv.isLinux && stdenv.hostPlatform == stdenv.buildPlatform), xvfb-run
+, pgoSupport ? (stdenv.isLinux && stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.hostPlatform.isMusl), xvfb-run
 , pipewireSupport ? waylandSupport && webrtcSupport
 , pulseaudioSupport ? stdenv.isLinux, libpulseaudio
 , sndioSupport ? stdenv.isLinux, sndio
@@ -103,7 +104,7 @@
 # WARNING: NEVER set any of the options below to `true` by default.
 # Set to `!privacySupport` or `false`.
 
-, crashreporterSupport ? !privacySupport && !stdenv.hostPlatform.isRiscV, curl
+, crashreporterSupport ? !privacySupport && !stdenv.hostPlatform.isRiscV && !stdenv.hostPlatform.isMusl, curl
 , geolocationSupport ? !privacySupport
 , googleAPISupport ? geolocationSupport
 , mlsAPISupport ? geolocationSupport
@@ -229,6 +230,12 @@ buildStdenv.mkDerivation ({
       url = "https://hg.mozilla.org/mozilla-central/raw-rev/1068e0955cfb";
       hash = "sha256-iPqmofsmgvlFNm+mqVPbdgMKmP68ANuzYu+PzfCpoNA=";
     })
+  ] ++ [
+    # https://bugzilla.mozilla.org/show_bug.cgi?id=1830040
+    (fetchpatch {
+      url = "https://git.alpinelinux.org/aports/plain/community/firefox/avoid-redefinition.patch?id=2f620d205ed0f9072bbd7714b5ec1b7bf6911c12";
+      hash = "sha256-fLUYaJwhrC/wF24HkuWn2PHqz7LlAaIZ1HYjRDB2w9A=";
+    })
   ]
   ++ lib.optional (lib.versionOlder version "111") ./env_var_for_system_dir-ff86.patch
   ++ lib.optional (lib.versionAtLeast version "111") ./env_var_for_system_dir-ff111.patch
@@ -335,6 +342,9 @@ buildStdenv.mkDerivation ({
     configureFlagsArray+=("--with-mozilla-api-keyfile=$TMPDIR/mls-api-key")
   '' + lib.optionalString (enableOfficialBranding && !stdenv.is32bit) ''
     export MOZILLA_OFFICIAL=1
+  '' + lib.optionalString stdenv.hostPlatform.isMusl ''
+    # linking firefox hits the vm.max_map_count kernel limit with the default musl allocator
+    export LD_PRELOAD=${mimalloc}/lib/libmimalloc.so
   '';
 
   # firefox has a different definition of configurePlatforms from nixpkgs, see configureFlags
@@ -474,6 +484,12 @@ buildStdenv.mkDerivation ({
   makeFlags = extraMakeFlags;
   separateDebugInfo = enableDebugSymbols;
   enableParallelBuilding = true;
+  env = lib.optionalAttrs stdenv.hostPlatform.isMusl {
+    # Firefox relies on nonstandard behavior of the glibc dynamic linker. It re-uses
+    # previously loaded libraries even though they are not in the rpath of the newly loaded binary.
+    # On musl we have to explicity set the rpath to include these libraries.
+    LDFLAGS = "-Wl,-rpath,${placeholder "out"}/lib/${binaryName}";
+  };
 
   # tests were disabled in configureFlags
   doCheck = false;