Skip to content

Commit 9242eba

Browse files
committed
feat: wip plv8 update on aarch64-linux
1 parent 020186a commit 9242eba

File tree

2 files changed

+50
-114
lines changed

2 files changed

+50
-114
lines changed
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
diff --git a/Makefile b/Makefile
2-
index 38879cc..6e78eeb 100644
2+
index a705c11..08b952b 100644
33
--- a/Makefile
44
+++ b/Makefile
5-
@@ -20,6 +20,7 @@ OBJS = $(SRCS:.cc=.o)
5+
@@ -13,11 +13,14 @@ OBJS = $(SRCS:.cc=.o)
66
MODULE_big = plv8-$(PLV8_VERSION)
77
EXTENSION = plv8
8-
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql)
8+
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql
99
+USE_SYSTEM_V8 = 0
1010

11-
12-
# Platform detection
13-
@@ -41,6 +42,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
14-
PG_VERSION_NUM := $(shell cat `$(PG_CONFIG) --includedir-server`/pg_config*.h \
15-
| perl -ne 'print $$1 and exit if /PG_VERSION_NUM\s+(\d+)/')
11+
ifeq ($(OS),Windows_NT)
12+
# noop for now
13+
else
14+
+ ifeq ($(USE_SYSTEM_V8),0)
15+
SHLIB_LINK += -Ldeps/v8-cmake/build
16+
+ endif
17+
UNAME_S := $(shell uname -s)
18+
ifeq ($(UNAME_S),Darwin)
19+
CCFLAGS += -stdlib=libc++
20+
@@ -34,6 +37,7 @@ ifeq ($(NUMPROC),0)
21+
NUMPROC = 1
22+
endif
1623

1724
+ifeq ($(USE_SYSTEM_V8),0)
18-
AUTOV8_DIR = build/v8
19-
AUTOV8_OUT = build/v8/out.gn/obj
20-
AUTOV8_STATIC_LIBS = -lv8_libplatform -lv8_libbase
21-
@@ -66,6 +68,7 @@ v8:
22-
make -f Makefiles/Makefile.macos v8
23-
endif
24-
endif
25+
SHLIB_LINK += -Ldeps/v8-cmake/build
26+
27+
all: v8 $(OBJS)
28+
@@ -46,11 +50,16 @@ deps/v8-cmake/build/libv8_libbase.a:
29+
@cd deps/v8-cmake && mkdir -p build && cd build && cmake -Denable-fPIC=ON -DCMAKE_BUILD_TYPE=Release ../ && make -j $(NUMPROC)
30+
31+
v8: deps/v8-cmake/build/libv8_libbase.a
32+
+else
33+
+all: $(OBJS)
2534
+endif
2635

2736
# enable direct jsonb conversion by default
2837
CCFLAGS += -DJSONB_DIRECT_CONVERSION
29-
@@ -83,6 +86,7 @@ ifdef BIGINT_GRACEFUL
30-
endif
31-
3238

3339
+ifeq ($(USE_SYSTEM_V8),0)
34-
# We're gonna build static link. Rip it out after include Makefile
35-
SHLIB_LINK := $(filter-out -lv8, $(SHLIB_LINK))
36-
37-
@@ -101,6 +105,7 @@ else
38-
SHLIB_LINK += -lrt -std=c++14
39-
endif
40-
endif
40+
CCFLAGS += -Ideps/v8-cmake/v8/include -std=c++17
4141
+endif
4242

43-
DATA = $(PLV8_DATA)
44-
ifndef DISABLE_DIALECT
45-
--
46-
2.37.3
43+
ifdef EXECUTION_TIMEOUT
44+
CCFLAGS += -DEXECUTION_TIMEOUT

nix/ext/plv8.nix

Lines changed: 23 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,70 @@
11
{ stdenv
22
, lib
33
, fetchFromGitHub
4-
, v8
4+
, nodejs_20
55
, perl
66
, postgresql
7-
# For test
7+
# For test
88
, runCommand
99
, coreutils
1010
, gnugrep
11-
, clang
12-
, patchelf
13-
, xcbuild
14-
, darwin
1511
}:
1612

17-
stdenv.mkDerivation (finalAttrs: {
13+
let
14+
libv8 = nodejs_20.libv8;
15+
in stdenv.mkDerivation (finalAttrs: {
1816
pname = "plv8";
19-
version = "3.1.5";
17+
version = "3.2.2";
2018

2119
src = fetchFromGitHub {
2220
owner = "plv8";
2321
repo = "plv8";
2422
rev = "v${finalAttrs.version}";
25-
hash = "sha256-LodC2eQJSm5fLckrjm2RuejZhmOyQMJTv9b0iPCnzKQ=";
23+
hash = "sha256-azO33v22EF+/sTNmwswxyDR0PhrvWfTENuLu6JgSGJ0=";
2624
};
2725

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

3232
nativeBuildInputs = [
3333
perl
34-
] ++ lib.optionals stdenv.isDarwin [
35-
clang
36-
xcbuild
3734
];
3835

3936
buildInputs = [
40-
(v8.overrideAttrs (oldAttrs: {
41-
version = "9.7.106.18";
42-
}))
37+
libv8
4338
postgresql
44-
] ++ lib.optionals stdenv.isDarwin [
45-
darwin.apple_sdk.frameworks.CoreFoundation
46-
darwin.apple_sdk.frameworks.Kerberos
4739
];
4840

4941
buildFlags = [ "all" ];
5042

5143
makeFlags = [
44+
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
5245
"USE_SYSTEM_V8=1"
53-
"V8_OUTDIR=${v8}/lib"
54-
"PG_CONFIG=${postgresql}/bin/pg_config"
55-
] ++ lib.optionals stdenv.isDarwin [
56-
"CC=${clang}/bin/clang"
57-
"CXX=${clang}/bin/clang++"
58-
"SHLIB_LINK=-L${v8}/lib -lv8_monolith -Wl,-rpath,${v8}/lib"
59-
] ++ lib.optionals (!stdenv.isDarwin) [
60-
"SHLIB_LINK=-L${v8}/lib -lv8_monolith -Wl,-rpath,${v8}/lib"
61-
];
62-
63-
NIX_LDFLAGS = (lib.optionals stdenv.isDarwin [
64-
"-L${postgresql}/lib"
65-
"-L${v8}/lib"
66-
"-lv8_monolith"
67-
"-lpq"
68-
"-lpgcommon"
69-
"-lpgport"
70-
"-F${darwin.apple_sdk.frameworks.CoreFoundation}/Library/Frameworks"
71-
"-framework" "CoreFoundation"
72-
"-F${darwin.apple_sdk.frameworks.Kerberos}/Library/Frameworks"
73-
"-framework" "Kerberos"
74-
"-undefined" "dynamic_lookup"
75-
"-flat_namespace"
76-
]) ++ (lib.optionals (!stdenv.isDarwin) [
77-
"-L${postgresql}/lib"
78-
"-L${v8}/lib"
79-
"-lv8_monolith"
80-
"-lpq"
81-
"-lpgcommon"
82-
"-lpgport"
83-
]);
84-
85-
NIX_CFLAGS_COMPILE = [
86-
"-I${v8}/include"
87-
"-I${postgresql}/include"
88-
"-I${postgresql}/include/server"
89-
"-I${postgresql}/include/internal"
46+
"SHLIB_LINK=-lv8"
47+
"V8_OUTDIR=${libv8}/lib"
9048
];
9149

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

55+
# No configure script.
9656
dontConfigure = true;
9757

9858
postPatch = ''
9959
patchShebangs ./generate_upgrade.sh
100-
substituteInPlace generate_upgrade.sh \
101-
--replace " 2.3.10 " " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 "
102-
103-
${lib.optionalString stdenv.isDarwin ''
104-
# Replace g++ with clang++ in Makefile
105-
sed -i 's/g++/clang++/g' Makefile
106-
''}
107-
'';
108-
109-
preBuild = lib.optionalString stdenv.isDarwin ''
110-
export CC=${clang}/bin/clang
111-
export CXX=${clang}/bin/clang++
11260
'';
11361

11462
postInstall = ''
63+
# Move the redirected to proper directory.
64+
# There appear to be no references to the install directories
65+
# so changing them does not cause issues.
11566
mv "$out/nix/store"/*/* "$out"
11667
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
117-
118-
${lib.optionalString stdenv.isDarwin ''
119-
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}.so
120-
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}.so
121-
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
122-
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}.so
123-
''}
124-
125-
${lib.optionalString (!stdenv.isDarwin) ''
126-
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
127-
''}
12868
'';
12969

13070
passthru = {
@@ -133,9 +73,8 @@ stdenv.mkDerivation (finalAttrs: {
13373
postgresqlWithSelf = postgresql.withPackages (_: [
13474
finalAttrs.finalPackage
13575
]);
136-
in
137-
{
138-
smoke = runCommand "plv8-smoke-test" { } ''
76+
in {
77+
smoke = runCommand "plv8-smoke-test" {} ''
13978
export PATH=${lib.makeBinPath [
14079
postgresqlWithSelf
14180
coreutils
@@ -195,9 +134,8 @@ stdenv.mkDerivation (finalAttrs: {
195134
meta = with lib; {
196135
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
197136
homepage = "https://plv8.github.io/";
198-
maintainers = with maintainers; [ samrose ];
199-
platforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
137+
maintainers = with maintainers; [ ];
138+
platforms = [ "x86_64-linux" "aarch64-linux" ];
200139
license = licenses.postgresql;
201-
#broken = postgresql.jitSupport;
202140
};
203-
})
141+
})

0 commit comments

Comments
 (0)