Skip to content

Commit 1eebb97

Browse files
committed
pgrx: use clang from nixpkgs-oldstable for old pgrx builds
Old pgrx versions (before 0.11.3) need an older clang to build on aarch64-linux. We got it by downloading the whole nixos-22.11 tarball during eval. That download was slow, could not come from our binary cache, and ran on every platform. Take clang 12 from nixpkgs-oldstable instead and only apply it on aarch64-linux like the comment implies. nixpkgs-oldstable's oldest clang is 12 while 22.11 defaulted to 11, but the build succeeds where a newer clang would fail. Assisted-by: Claude <noreply@anthropic.com>
1 parent 6246261 commit 1eebb97

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎nix/cargo-pgrx/mkPgrxExtension.nix‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
callPackage,
2+
lib,
33
pkgs,
4+
callPackage,
5+
clang_oldstable,
46
rustVersion,
57
pgrxVersion,
68
makeRustPlatform,
@@ -40,18 +42,10 @@ let
4042
bindgenHook =
4143
# Fix bindgen error on aarch64-linux for versions using pgrx with bindgen 0.68.1
4244
# This affects pgrx 0.6.1 through 0.11.2 which have issues with ARM NEON vector ABI
43-
if (builtins.compareVersions "0.11.3" pgrxVersion > 0) then
44-
let
45-
nixos2211 = (
46-
import (builtins.fetchTarball {
47-
url = "https://channels.nixos.org/nixos-22.11/nixexprs.tar.xz";
48-
sha256 = "1j7h75a9hwkkm97jicky5rhvzkdwxsv5v46473rl6agvq2sj97y1";
49-
}) { inherit (stdenv.hostPlatform) system; }
50-
);
51-
in
45+
if stdenv.hostPlatform.system == "aarch64-linux" && lib.versionOlder pgrxVersion "0.11.3" then
5246
rustPlatform.bindgenHook.overrideAttrs {
53-
libclang = nixos2211.clang.cc.lib;
54-
clang = nixos2211.clang;
47+
libclang = clang_oldstable.cc.lib;
48+
clang = clang_oldstable;
5549
}
5650
else
5751
rustPlatform.bindgenHook;

‎nix/nixpkgs.nix‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
in
105105
_final: _prev: {
106106
v8_oldstable = oldstable.v8;
107+
clang_oldstable = oldstable.llvmPackages_12.clang;
107108
}
108109
)
109110
];

0 commit comments

Comments
 (0)