From af4a917d9242b881d1171104468cfd69c813989d Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Fri, 18 Sep 2026 13:11:04 -0400 Subject: [PATCH] overlays: consolidate Abseil BMI2 workaround under patches Extract the header fix into a standalone patch and colocate the Electron, Deno, and Signal overrides in patches/abseil. Preserve the x86-64-v3 restriction and document the accepted upstream fix while waiting for bundled dependency updates. Import the Abseil overrides through the patches overlay and register the torchcodec override. Leave PostgreSQL output checks in x86-64-v3-workarounds.nix. --- .../patches/abseil/bmi2-public-header.patch | 20 +++++++++ overlays/patches/abseil/default.nix | 38 +++++++++++++++++ overlays/patches/default.nix | 5 ++- overlays/x86-64-v3-workarounds.nix | 42 +------------------ 4 files changed, 63 insertions(+), 42 deletions(-) create mode 100644 overlays/patches/abseil/bmi2-public-header.patch create mode 100644 overlays/patches/abseil/default.nix diff --git a/overlays/patches/abseil/bmi2-public-header.patch b/overlays/patches/abseil/bmi2-public-header.patch new file mode 100644 index 0000000..c6f3b30 --- /dev/null +++ b/overlays/patches/abseil/bmi2-public-header.patch @@ -0,0 +1,20 @@ +Subject: [PATCH] abseil: include BMI2 intrinsics through the public header + +GCC and Clang reject direct inclusion of bmi2intrin.h. Include immintrin.h +instead so that the compiler supplies the required intrinsic setup when +BMI2 is enabled, including builds targeting x86-64-v3. + +This patch is shared by the vendored Abseil copies in Electron, rusty_v8 +(Deno), and Signal's WebRTC build. + +--- a/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h ++++ b/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +@@ -226,7 +226,7 @@ + #endif + + #ifdef __BMI2__ +-#include ++#include + #endif // __BMI2__ + + namespace absl { diff --git a/overlays/patches/abseil/default.nix b/overlays/patches/abseil/default.nix new file mode 100644 index 0000000..fe87a2f --- /dev/null +++ b/overlays/patches/abseil/default.nix @@ -0,0 +1,38 @@ +# Abseil accepted the upstream fix: https://github.com/abseil/abseil-cpp/pull/2071 +# Keep this workaround until Electron, Deno's rusty_v8, and Signal's WebRTC +# update their bundled Abseil copies to include it. +{ prev }: +let + patchAbseilBmi2Include = + package: + package.overrideAttrs (old: { + # GCC and Clang require the public umbrella header for BMI2 intrinsics. + patches = (old.patches or [ ]) ++ [ ./bmi2-public-header.patch ]; + }); + + electron43Unwrapped = patchAbseilBmi2Include prev.electron_43.unwrapped; + electron43 = prev.electron_43.override { + electron-unwrapped = electron43Unwrapped; + }; + + signalCallPackage = + path: args: + let + package = prev.callPackage path args; + in + if builtins.baseNameOf path == "webrtc.nix" then patchAbseilBmi2Include package else package; +in +prev.lib.optionalAttrs ((prev.stdenv.hostPlatform.gcc.arch or null) == "x86-64-v3") { + deno = + let + librusty_v8 = patchAbseilBmi2Include prev.deno.passthru.librusty_v8; + in + prev.deno.override { inherit librusty_v8; }; + + electron_43 = electron43; + + signal-desktop = prev.signal-desktop.override { + electron_43 = electron43; + callPackage = signalCallPackage; + }; +} diff --git a/overlays/patches/default.nix b/overlays/patches/default.nix index df32fe5..88b544f 100644 --- a/overlays/patches/default.nix +++ b/overlays/patches/default.nix @@ -1,9 +1,12 @@ -_final: prev: { +_final: prev: +(import ./abseil { inherit prev; }) +// { gnutls = import ./gnutls { inherit (prev) gnutls; }; pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ (_pythonFinal: pythonPrev: { scipy = import ./scipy { inherit (pythonPrev) scipy; }; + torchcodec = import ./torchcodec { inherit (pythonPrev) torchcodec; }; }) ]; } diff --git a/overlays/x86-64-v3-workarounds.nix b/overlays/x86-64-v3-workarounds.nix index c1e0bd0..1796d20 100644 --- a/overlays/x86-64-v3-workarounds.nix +++ b/overlays/x86-64-v3-workarounds.nix @@ -1,22 +1,6 @@ -# Compatibility fixes for packages rebuilt with x86-64-v3. -# -# The v3 baseline enables instructions that expose source assumptions hidden -# by the generic x86-64 build. Keep compile fixes here, separate from test -# exclusions, until upstream or nixpkgs incorporates them. +# Output-validation workarounds for packages rebuilt with x86-64-v3. _final: prev: let - patchAbseilBmi2Include = - package: - package.overrideAttrs (old: { - # GCC and Clang prohibit including their internal BMI2 header directly. - # The public umbrella provides the same intrinsics with the required - # compiler setup. - postPatch = (old.postPatch or "") + '' - substituteInPlace third_party/abseil-cpp/absl/container/internal/raw_hash_set.h \ - --replace-fail "#include " "#include " - ''; - }); - removeSiblingOutputChecks = package: package.overrideAttrs (old: { @@ -29,32 +13,8 @@ let ) (old.outputChecks or { }); }); - electron43Unwrapped = patchAbseilBmi2Include prev.electron_43.unwrapped; - electron43 = prev.electron_43.override { - electron-unwrapped = electron43Unwrapped; - }; - - signalCallPackage = - path: args: - let - package = prev.callPackage path args; - in - if builtins.baseNameOf path == "webrtc.nix" then patchAbseilBmi2Include package else package; in prev.lib.optionalAttrs ((prev.stdenv.hostPlatform.gcc.arch or null) == "x86-64-v3") { - deno = - let - librusty_v8 = patchAbseilBmi2Include prev.deno.passthru.librusty_v8; - in - prev.deno.override { inherit librusty_v8; }; - - electron_43 = electron43; - postgresql = removeSiblingOutputChecks prev.postgresql; postgresql_18 = removeSiblingOutputChecks prev.postgresql_18; - - signal-desktop = prev.signal-desktop.override { - electron_43 = electron43; - callPackage = signalCallPackage; - }; }