diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
commit | 99fcaeccb89621dd492203ce1f2d551c06f228ed (patch) | |
tree | 41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix | |
parent | 59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff) | |
parent | 75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff) | |
download | nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2 nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/nixos/modules/config/console.nix nixpkgs/nixos/modules/services/mail/mailman.nix nixpkgs/nixos/modules/services/mail/public-inbox.nix nixpkgs/nixos/modules/services/mail/rss2email.nix nixpkgs/nixos/modules/services/networking/ssh/sshd.nix nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix nixpkgs/pkgs/applications/networking/irc/weechat/default.nix nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/interpreters/python/default.nix nixpkgs/pkgs/development/node-packages/overrides.nix nixpkgs/pkgs/development/tools/b4/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix nixpkgs/pkgs/servers/mail/public-inbox/default.nix nixpkgs/pkgs/tools/security/pinentry/default.nix nixpkgs/pkgs/tools/text/unoconv/default.nix nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix')
-rw-r--r-- | nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix | 184 |
1 files changed, 90 insertions, 94 deletions
diff --git a/nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix b/nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix index fb4c326be5b3..ae7223ec721b 100644 --- a/nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix +++ b/nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix @@ -5,6 +5,7 @@ , binaryName ? "firefox" , application ? "browser" , applicationName ? "Mozilla Firefox" +, branding ? null , src , unpackPhase ? null , extraPatches ? [] @@ -22,12 +23,14 @@ , pkgs , stdenv , fetchpatch +, patchelf # build time , autoconf , cargo , dump_syms , makeWrapper +, mimalloc , nodejs , perl , pkg-config @@ -86,8 +89,8 @@ , ffmpegSupport ? true , gssSupport ? true, libkrb5 , jackSupport ? stdenv.isLinux, libjack2 -, jemallocSupport ? true, jemalloc -, ltoSupport ? (stdenv.isLinux && stdenv.is64bit), overrideCC, buildPackages +, jemallocSupport ? !stdenv.hostPlatform.isMusl, jemalloc +, ltoSupport ? (stdenv.isLinux && stdenv.is64bit && !stdenv.hostPlatform.isRiscV), overrideCC, buildPackages , pgoSupport ? (stdenv.isLinux && stdenv.hostPlatform == stdenv.buildPlatform), xvfb-run , pipewireSupport ? waylandSupport && webrtcSupport , pulseaudioSupport ? stdenv.isLinux, libpulseaudio @@ -101,11 +104,11 @@ # WARNING: NEVER set any of the options below to `true` by default. # Set to `!privacySupport` or `false`. -, crashreporterSupport ? !privacySupport +, crashreporterSupport ? !privacySupport && !stdenv.hostPlatform.isRiscV && !stdenv.hostPlatform.isMusl, curl , geolocationSupport ? !privacySupport , googleAPISupport ? geolocationSupport , mlsAPISupport ? geolocationSupport -, webrtcSupport ? !privacySupport +, webrtcSupport ? !privacySupport && !stdenv.hostPlatform.isRiscV # digital rights managemewnt @@ -141,7 +144,7 @@ assert stdenv.cc.libc or null != null; assert pipewireSupport -> !waylandSupport || !webrtcSupport -> throw "${pname}: pipewireSupport requires both wayland and webrtc support."; let - flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")]; + inherit (lib) enableFeature; # Target the LLVM version that rustc is built with for LTO. llvmPackages0 = rustc.llvmPackages; @@ -219,22 +222,30 @@ buildStdenv.mkDerivation ({ "profilingPhase" ]; - patches = lib.optionals (lib.versionOlder version "103") [ + patches = lib.optionals (lib.versionAtLeast version "112.0" && lib.versionOlder version "113.0") [ (fetchpatch { - # https://bugzilla.mozilla.org/show_bug.cgi?id=1773259 - name = "rust-cbindgen-0.24.2-compat.patch"; - url = "https://raw.githubusercontent.com/canonical/firefox-snap/5622734942524846fb0eb7108918c8cd8557fde3/patches/fix-ftbfs-newer-cbindgen.patch"; - hash = "sha256-+wNZhkDB3HSknPRD4N6cQXY7zMT/DzNXx29jQH0Gb1o="; + # Crash when desktop scaling does not divide window scale on Wayland + # https://bugzilla.mozilla.org/show_bug.cgi?id=1803016 + name = "mozbz1803016.patch"; + url = "https://hg.mozilla.org/mozilla-central/raw-rev/1068e0955cfb"; + hash = "sha256-iPqmofsmgvlFNm+mqVPbdgMKmP68ANuzYu+PzfCpoNA="; + }) + ] ++ lib.optionals (lib.versionOlder version "114.0") [ + # https://bugzilla.mozilla.org/show_bug.cgi?id=1830040 + # https://hg.mozilla.org/mozilla-central/rev/cddb250a28d8 + (fetchpatch { + url = "https://git.alpinelinux.org/aports/plain/community/firefox/avoid-redefinition.patch?id=2f620d205ed0f9072bbd7714b5ec1b7bf6911c12"; + hash = "sha256-fLUYaJwhrC/wF24HkuWn2PHqz7LlAaIZ1HYjRDB2w9A="; }) ] - ++ lib.optional (lib.versionAtLeast version "86") ./env_var_for_system_dir-ff86.patch - ++ lib.optional (lib.versionAtLeast version "90" && lib.versionOlder version "95") ./no-buildconfig-ffx90.patch + ++ 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 ++ lib.optional (lib.versionAtLeast version "96") ./no-buildconfig-ffx96.patch ++ extraPatches; postPatch = '' rm -rf obj-x86_64-pc-linux-gnu - patchShebangs mach + patchShebangs mach build '' + extraPostPatch; @@ -264,7 +275,7 @@ buildStdenv.mkDerivation ({ which wrapGAppsHook ] - ++ lib.optionals crashreporterSupport [ dump_syms ] + ++ lib.optionals crashreporterSupport [ dump_syms patchelf ] ++ lib.optionals pgoSupport [ xvfb-run ] ++ extraNativeBuildInputs; @@ -291,36 +302,43 @@ buildStdenv.mkDerivation ({ # https://bugzilla.mozilla.org/show_bug.cgi?id=1497286 unset AS - '' + lib.optionalString (lib.versionAtLeast version "100.0") '' # Use our own python export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system - '' + lib.optionalString (lib.versionOlder version "100.0") '' - # Use our own python - export MACH_USE_SYSTEM_PYTHON=1 - '' + lib.optionalString (lib.versionAtLeast version "95.0") '' # RBox WASM Sandboxing export WASM_CC=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}cc export WASM_CXX=${pkgsCross.wasi32.stdenv.cc}/bin/${pkgsCross.wasi32.stdenv.cc.targetPrefix}c++ - '' + lib.optionalString pgoSupport '' - if [ -e "$TMPDIR/merged.profdata" ]; then - echo "Configuring with profiling data" - for i in "''${!configureFlagsArray[@]}"; do - if [[ ''${configureFlagsArray[i]} = "--enable-profile-generate=cross" ]]; then - unset 'configureFlagsArray[i]' - fi - done - configureFlagsArray+=( - "--enable-profile-use=cross" - "--with-pgo-profile-path="$TMPDIR/merged.profdata"" - "--with-pgo-jarlog="$TMPDIR/jarlog"" - ) - else - echo "Configuring to generate profiling data" - configureFlagsArray+=( - "--enable-profile-generate=cross" - ) - fi + '' + lib.optionalString pgoSupport '' + if [ -e "$TMPDIR/merged.profdata" ]; then + echo "Configuring with profiling data" + for i in "''${!configureFlagsArray[@]}"; do + if [[ ''${configureFlagsArray[i]} = "--enable-profile-generate=cross" ]]; then + unset 'configureFlagsArray[i]' + fi + done + configureFlagsArray+=( + "--enable-profile-use=cross" + "--with-pgo-profile-path="$TMPDIR/merged.profdata"" + "--with-pgo-jarlog="$TMPDIR/jarlog"" + ) + ${lib.optionalString stdenv.hostPlatform.isMusl '' + LDFLAGS="$OLD_LDFLAGS" + unset OLD_LDFLAGS + ''} + else + echo "Configuring to generate profiling data" + configureFlagsArray+=( + "--enable-profile-generate=cross" + ) + ${lib.optionalString stdenv.hostPlatform.isMusl + # Set the rpath appropriately for the profiling run + # During the profiling run, loading libraries from $out would fail, + # since the profiling build has not been installed to $out + '' + OLD_LDFLAGS="$LDFLAGS" + LDFLAGS="-Wl,-rpath,$(pwd)/mozobj/dist/${binaryName}" + ''} + fi '' + lib.optionalString googleAPISupport '' # Google API key used by Chromium and Firefox. # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, @@ -337,6 +355,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 @@ -360,6 +381,7 @@ buildStdenv.mkDerivation ({ "--with-system-png" # needs APNG support "--with-system-webp" "--with-system-zlib" + "--with-wasi-sysroot=${wasiSysRoot}" # for firefox, host is buildPlatform, target is hostPlatform "--host=${buildStdenv.buildPlatform.config}" "--target=${buildStdenv.hostPlatform.config}" @@ -372,29 +394,28 @@ buildStdenv.mkDerivation ({ # elf-hack is broken when using clang+lld: # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204 ++ lib.optional (ltoSupport && (buildStdenv.isAarch32 || buildStdenv.isi686 || buildStdenv.isx86_64)) "--disable-elf-hack" - ++ lib.optional (lib.versionAtLeast version "95") "--with-wasi-sysroot=${wasiSysRoot}" - - ++ flag alsaSupport "alsa" - ++ flag jackSupport "jack" - ++ flag pulseaudioSupport "pulseaudio" - ++ lib.optional (lib.versionAtLeast version "100") (flag sndioSupport "sndio") - ++ flag ffmpegSupport "ffmpeg" - ++ flag jemallocSupport "jemalloc" - ++ flag geolocationSupport "necko-wifi" - ++ flag gssSupport "negotiateauth" - ++ flag webrtcSupport "webrtc" - ++ flag crashreporterSupport "crashreporter" ++ lib.optional (!drmSupport) "--disable-eme" - - ++ (if debugBuild then [ "--enable-debug" "--enable-profiling" ] - else [ "--disable-debug" "--enable-optimize" ]) - # --enable-release adds -ffunction-sections & LTO that require a big amount of - # RAM and the 32-bit memory space cannot handle that linking - ++ flag (!debugBuild && !stdenv.is32bit) "release" - ++ flag enableDebugSymbols "debug-symbols" + ++ [ + (enableFeature alsaSupport "alsa") + (enableFeature crashreporterSupport "crashreporter") + (enableFeature ffmpegSupport "ffmpeg") + (enableFeature geolocationSupport "necko-wifi") + (enableFeature gssSupport "negotiateauth") + (enableFeature jackSupport "jack") + (enableFeature jemallocSupport "jemalloc") + (enableFeature pulseaudioSupport "pulseaudio") + (enableFeature sndioSupport "sndio") + (enableFeature webrtcSupport "webrtc") + (enableFeature debugBuild "debug") + (if debugBuild then "--enable-profiling" else "--enable-optimize") + # --enable-release adds -ffunction-sections & LTO that require a big amount + # of RAM, and the 32-bit memory space cannot handle that linking + (enableFeature (!debugBuild && !stdenv.is32bit) "release") + (enableFeature enableDebugSymbols "debug-symbols") + ] ++ lib.optionals enableDebugSymbols [ "--disable-strip" "--disable-install-strip" ] - ++ lib.optional enableOfficialBranding "--enable-official-branding" + ++ lib.optional (branding != null) "--with-branding=${branding}" ++ extraConfigureFlags; buildInputs = [ @@ -434,11 +455,11 @@ buildStdenv.mkDerivation ({ zip zlib ] - ++ [ (if (lib.versionAtLeast version "92") then nss_latest else nss_esr) ] + ++ [ (if (lib.versionAtLeast version "103") then nss_latest else nss_esr) ] ++ lib.optional alsaSupport alsa-lib ++ lib.optional jackSupport libjack2 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed - ++ lib.optional (sndioSupport && lib.versionAtLeast version "100") sndio + ++ lib.optional sndioSupport sndio ++ lib.optional gssSupport libkrb5 ++ lib.optionals waylandSupport [ libxkbcommon libdrm ] ++ lib.optional jemallocSupport jemalloc @@ -476,6 +497,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; @@ -503,40 +530,8 @@ buildStdenv.mkDerivation ({ gappsWrapperArgs+=(--argv0 "$out/bin/.${binaryName}-wrapped") ''; - # Workaround: The separateDebugInfo hook skips artifacts whose build ID's length is not 40. - # But we got 16-length build ID here. The function body is mainly copied from pkgs/build-support/setup-hooks/separate-debug-info.sh - # Remove it when https://github.com/NixOS/nixpkgs/pull/146275 is merged. - preFixup = lib.optionalString enableDebugSymbols '' - _separateDebugInfo() { - [ -e "$prefix" ] || return 0 - - local dst="''${debug:-$out}" - if [ "$prefix" = "$dst" ]; then return 0; fi - - dst="$dst/lib/debug/.build-id" - - # Find executables and dynamic libraries. - local i - while IFS= read -r -d $'\0' i; do - if ! isELF "$i"; then continue; fi - - # Extract the Build ID. FIXME: there's probably a cleaner way. - local id="$($READELF -n "$i" | sed 's/.*Build ID: \([0-9a-f]*\).*/\1/; t; d')" - if [[ -z "$id" ]]; then - echo "could not find build ID of $i, skipping" >&2 - continue - fi - - # Extract the debug info. - header "separating debug info from $i (build ID $id)" - mkdir -p "$dst/''${id:0:2}" - $OBJCOPY --only-keep-debug "$i" "$dst/''${id:0:2}/''${id:2}.debug" - $STRIP --strip-debug "$i" - - # Also a create a symlink <original-name>.debug. - ln -sfn ".build-id/''${id:0:2}/''${id:2}.debug" "$dst/../$(basename "$i")" - done < <(find "$prefix" -type f -print0) - } + postFixup = lib.optionalString crashreporterSupport '' + patchelf --add-rpath "${lib.makeLibraryPath [ curl ]}" $out/lib/${binaryName}/crashreporter ''; doInstallCheck = true; @@ -546,6 +541,7 @@ buildStdenv.mkDerivation ({ ''; passthru = { + inherit application extraPatches; inherit updateScript; inherit version; inherit alsaSupport; |