Skip to content

Commit

Permalink
Sam/plv8 version update (#1226)
Browse files Browse the repository at this point in the history
* feat: wip plv8 update on aarch64-linux

* feat: bring back to 3.1.10 to both support pg 16 and retain plcoffee/plls

* feat: update to latest that retain plcoffee and plls and pg16

---------

Co-authored-by: Sam Rose <[email protected]>
  • Loading branch information
samrose and samrose authored Sep 24, 2024
1 parent 64c0dea commit 9b5146e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion nix/ext/0001-build-Allow-using-V8-from-system.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ index 38879cc..6e78eeb 100644
@@ -20,6 +20,7 @@ OBJS = $(SRCS:.cc=.o)
MODULE_big = plv8-$(PLV8_VERSION)
EXTENSION = plv8
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql)
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql
+USE_SYSTEM_V8 = 0


Expand Down
57 changes: 22 additions & 35 deletions nix/ext/plv8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@
, v8
, perl
, postgresql
# For test
# For passthru test on various systems, and local development on macos
# not we are not currently using passthru tests but retaining for possible contrib
# to nixpkgs
, runCommand
, coreutils
, gnugrep
, clang
, patchelf
, xcbuild
, darwin
, patchelf
}:

stdenv.mkDerivation (finalAttrs: {
pname = "plv8";
version = "3.1.5";
version = "3.1.10";

src = fetchFromGitHub {
owner = "plv8";
repo = "plv8";
rev = "v${finalAttrs.version}";
hash = "sha256-LodC2eQJSm5fLckrjm2RuejZhmOyQMJTv9b0iPCnzKQ=";
hash = "sha256-g1A/XPC0dX2360Gzvmo9/FSQnM6Wt2K4eR0pH0p9fz4=";
};

patches = [
# Allow building with system v8.
# https://github.com/plv8/plv8/pull/505 (rejected)
./0001-build-Allow-using-V8-from-system.patch
];

Expand All @@ -37,9 +41,7 @@ stdenv.mkDerivation (finalAttrs: {
];

buildInputs = [
(v8.overrideAttrs (oldAttrs: {
version = "9.7.106.18";
}))
v8
postgresql
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
Expand All @@ -49,15 +51,16 @@ stdenv.mkDerivation (finalAttrs: {
buildFlags = [ "all" ];

makeFlags = [
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
"USE_SYSTEM_V8=1"
"V8_OUTDIR=${v8}/lib"
"PG_CONFIG=${postgresql}/bin/pg_config"
"PG_CONFIG=${postgresql}/bin/pg_config"
] ++ lib.optionals stdenv.isDarwin [
"CC=${clang}/bin/clang"
"CXX=${clang}/bin/clang++"
"SHLIB_LINK=-L${v8}/lib -lv8_monolith -Wl,-rpath,${v8}/lib"
] ++ lib.optionals (!stdenv.isDarwin) [
"SHLIB_LINK=-L${v8}/lib -lv8_monolith -Wl,-rpath,${v8}/lib"
"SHLIB_LINK=-lv8"
];

NIX_LDFLAGS = (lib.optionals stdenv.isDarwin [
Expand All @@ -73,45 +76,31 @@ stdenv.mkDerivation (finalAttrs: {
"-framework" "Kerberos"
"-undefined" "dynamic_lookup"
"-flat_namespace"
]) ++ (lib.optionals (!stdenv.isDarwin) [
"-L${postgresql}/lib"
"-L${v8}/lib"
"-lv8_monolith"
"-lpq"
"-lpgcommon"
"-lpgport"
]);

NIX_CFLAGS_COMPILE = [
"-I${v8}/include"
"-I${postgresql}/include"
"-I${postgresql}/include/server"
"-I${postgresql}/include/internal"
];
]);

installFlags = [
# PGXS only supports installing to postgresql prefix so we need to redirect this
"DESTDIR=${placeholder "out"}"
];

# No configure script.
dontConfigure = true;

postPatch = ''
patchShebangs ./generate_upgrade.sh
substituteInPlace generate_upgrade.sh \
--replace " 2.3.10 " " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 "
${lib.optionalString stdenv.isDarwin ''
# Replace g++ with clang++ in Makefile
sed -i 's/g++/clang++/g' Makefile
''}
'';

preBuild = lib.optionalString stdenv.isDarwin ''
export CC=${clang}/bin/clang
export CXX=${clang}/bin/clang++
'';

postInstall = ''
# Move the redirected to proper directory.
# There appear to be no references to the install directories
# so changing them does not cause issues.
mv "$out/nix/store"/*/* "$out"
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
Expand All @@ -133,9 +122,8 @@ stdenv.mkDerivation (finalAttrs: {
postgresqlWithSelf = postgresql.withPackages (_: [
finalAttrs.finalPackage
]);
in
{
smoke = runCommand "plv8-smoke-test" { } ''
in {
smoke = runCommand "plv8-smoke-test" {} ''
export PATH=${lib.makeBinPath [
postgresqlWithSelf
coreutils
Expand Down Expand Up @@ -198,6 +186,5 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with maintainers; [ samrose ];
platforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
license = licenses.postgresql;
#broken = postgresql.jitSupport;
};
})
})

0 comments on commit 9b5146e

Please sign in to comment.