From 1ed61918a93f0fdef1f66d72faccf25b61d75cff Mon Sep 17 00:00:00 2001 From: Diogo Correia Date: Mon, 6 Jul 2026 16:58:41 +0100 Subject: [PATCH 1/2] postgresqlPackages.vectorchord: disable avx512vnni support Due to a bug in LLVM 21, build fails on x86_64 with: `rustc-LLVM ERROR: Cannot select: intrinsic %llvm.x86.avx512.vpdpbusd.512`. This has been fixed in Rust's build of LLVM and LLVM 22 [1] but this is not reflected in nixpkgs' packaging of rustc. For this reason, we temporarily disable avx512vnni support until this is fixed in nixpkgs. This might cause a performance penalty, but should not affect correctness. See https://github.com/NixOS/nixpkgs/pull/537113#issuecomment-4846239887 [1]: https://github.com/rust-lang/llvm-project/commit/94e2c19f86a699d7a19ff0f4130b696699189c8d --- .../vectorchord/0001-disable-avx512vnni.patch | 29 +++++++++++++++++++ .../postgresql/ext/vectorchord/package.nix | 13 +++++++++ 2 files changed, 42 insertions(+) create mode 100644 pkgs/servers/sql/postgresql/ext/vectorchord/0001-disable-avx512vnni.patch diff --git a/pkgs/servers/sql/postgresql/ext/vectorchord/0001-disable-avx512vnni.patch b/pkgs/servers/sql/postgresql/ext/vectorchord/0001-disable-avx512vnni.patch new file mode 100644 index 000000000000..093663c162dd --- /dev/null +++ b/pkgs/servers/sql/postgresql/ext/vectorchord/0001-disable-avx512vnni.patch @@ -0,0 +1,29 @@ +diff --git a/crates/simd/src/byte.rs b/crates/simd/src/byte.rs +index 0c7c4be..87737d4 100644 +--- a/crates/simd/src/byte.rs ++++ b/crates/simd/src/byte.rs +@@ -389,7 +389,7 @@ mod reduce_sum_of_xy { + } + } + +- #[crate::multiversion(@"v4:avx512vnni", @"v4", @"v3", @"v2", @"a2:dotprod", @"a2", "z17", "z16", "z15", "z14", "z13", "p9", "p8", "p7", "r1")] ++ #[crate::multiversion(@"v4", @"v3", @"v2", @"a2:dotprod", @"a2", "z17", "z16", "z15", "z14", "z13", "p9", "p8", "p7", "r1")] + pub fn reduce_sum_of_xy(s: &[u8], t: &[u8]) -> u32 { + assert_eq!(s.len(), t.len()); + let n = s.len(); +diff --git a/crates/simd/src/halfbyte.rs b/crates/simd/src/halfbyte.rs +index e1aa016..f7dc3dc 100644 +--- a/crates/simd/src/halfbyte.rs ++++ b/crates/simd/src/halfbyte.rs +@@ -411,7 +411,7 @@ mod reduce_sum_of_xy { + } + } + +- #[crate::multiversion(@"v4:avx512vnni", @"v4", @"v3", @"v2", @"a2:dotprod", @"a2", "z17", "z16", "z15", "z14", "z13", "p9", "p8", "p7", "r1")] ++ #[crate::multiversion(@"v4", @"v3", @"v2", @"a2:dotprod", @"a2", "z17", "z16", "z15", "z14", "z13", "p9", "p8", "p7", "r1")] + pub fn reduce_sum_of_xy(s: &[u8], t: &[u8]) -> u32 { + assert_eq!(s.len(), t.len()); + let n = s.len(); +-- +2.54.0 + diff --git a/pkgs/servers/sql/postgresql/ext/vectorchord/package.nix b/pkgs/servers/sql/postgresql/ext/vectorchord/package.nix index 1dd1d6283a81..7d40097abf6a 100644 --- a/pkgs/servers/sql/postgresql/ext/vectorchord/package.nix +++ b/pkgs/servers/sql/postgresql/ext/vectorchord/package.nix @@ -6,6 +6,8 @@ nix-update-script, postgresql, postgresqlTestExtension, + rustc, + stdenv, }: buildPgrxExtension (finalAttrs: { inherit postgresql; @@ -23,6 +25,17 @@ buildPgrxExtension (finalAttrs: { cargoHash = "sha256-IXOCzKJArNOcb/2TcJbLz1XdCquUpyF/cLHYU5vmlko="; + patches = lib.optional (lib.versionOlder rustc.llvm.version "22.0.0" && stdenv.isx86_64) [ + # Due to a bug in LLVM 21, build fails on x86_64 with: + # `rustc-LLVM ERROR: Cannot select: intrinsic %llvm.x86.avx512.vpdpbusd.512`. + # This has been fixed in Rust's build of LLVM and LLVM 22 with https://github.com/rust-lang/llvm-project/commit/94e2c19f86a699d7a19ff0f4130b696699189c8d, + # but this is not reflected in nixpkgs' packaging of rustc. + # For this reason, we temporarily disable avx512vnni support until this is fixed in nixpkgs. + # This might cause a performance penalty, but should not affect correctness. + # See https://github.com/NixOS/nixpkgs/pull/537113#issuecomment-4846239887 + ./0001-disable-avx512vnni.patch + ]; + # Include upgrade scripts in the final package # https://github.com/supervc-stack/VectorChord/blob/0.5.0/crates/make/src/main.rs#L366 postInstall = '' From 6b46cf6c6bcb106522c11ff59d317e616fa24230 Mon Sep 17 00:00:00 2001 From: Diogo Correia Date: Mon, 6 Jul 2026 19:12:06 +0100 Subject: [PATCH 2/2] nixos/tests/immich-vectorchord-reindex: do not patch vectorchord 1.0.0 The patches in the vectorchord package are for 1.1.1 only and do not cleanly apply to 1.0.0. Regardless, the latter does not need them to successfully build and run. --- nixos/tests/web-apps/immich-vectorchord-reindex.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/tests/web-apps/immich-vectorchord-reindex.nix b/nixos/tests/web-apps/immich-vectorchord-reindex.nix index 65308d11838f..da808cf64a8e 100644 --- a/nixos/tests/web-apps/immich-vectorchord-reindex.nix +++ b/nixos/tests/web-apps/immich-vectorchord-reindex.nix @@ -37,6 +37,10 @@ hash = "sha256-+BOuiinbKPZZaDl9aYsIoZPgvLZ4FA6Rb4/W+lAz4so="; }; + # Remove the patches currently used for vectorchord 1.1.1, + # as vectorchord 1.0.0 does not need them. + patches = [ ]; + cargoDeps = pkgs.rustPlatform.fetchCargoVendor { inherit (finalAttrs) src; hash = "sha256-kwe2x7OTjpdPonZsvnR1C/89D5W/R5JswYF79YcSFEA=";