Skip to content

Commit 5c0ad13

Browse files
committed
dual build
1 parent ec751e1 commit 5c0ad13

File tree

8 files changed

+110
-69
lines changed

8 files changed

+110
-69
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
USE_ICU: false
2626
PG_VERSION: 17.5
2727
PG_BRANCH: REL_17_5_WASM
28-
PGL_BRANCH: extra/pg_ivm
28+
PGL_BRANCH: main
2929
ZIC: /usr/sbin/zic
3030
GETZIC: false
3131

ci-alpine-proot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ else
9696
git clone --no-tags --depth 1 --single-branch --branch $PGL_BRANCH https://github.com/electric-sql/pglite pglite
9797
fi
9898

99-
rm -f ${WORKSPACE}/done
99+
rm -f ${WORKSPACE}/${BUILD}.done
100100

101101
# execute prooted build
102102
${WORKSPACE}/portable/portable.sh
103103

104-
if [ -f ${WORKSPACE}/done ]
104+
if [ -f ${WORKSPACE}/${BUILD}.done ]
105105
then
106106
if $LOCAL
107107
then

pglite-REL_17_4_WASM/build.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if $WASI
3636
then
3737

3838

39-
echo "
39+
echo "
4040
_______________________ PG_BRANCH=${PG_BRANCH} _____________________
4141
4242
wasi : $(which wasi-c) $(wasi-c -v)
@@ -139,12 +139,15 @@ END
139139
fi
140140
else
141141
echo "linking libpglite ${BUILD} failed in $(pwd)"
142+
exit 142
142143
fi
143144
else
144145
echo "${BUILD} compilation of libpglite ${PG_BRANCH} failed"
145-
exit 106
146+
exit 146
146147
fi
147148

149+
touch ${WORKSPACE}/${BUILD}.done
150+
148151
else
149152
. ${SDKROOT:-/opt/python-wasm-sdk}/wasm32-bi-emscripten-shell.sh
150153

@@ -165,17 +168,14 @@ else
165168
EXPORTED_FUNCTIONS="_main,_use_wire,_pgl_initdb,_pgl_backend,_pgl_shutdown,_interactive_write,_interactive_read,_interactive_one"
166169
EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS,_get_channel,_get_buffer_size,_get_buffer_addr"
167170

168-
# EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,FS_mount,FS_syncfs,FS_analyzePath,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack"
169171
EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack"
170172

171173

172-
173174
if $DEBUG
174175
then
175176
# FULL
176177
LINKER="-sMAIN_MODULE=1 -sEXPORTED_FUNCTIONS=${EXPORTED_FUNCTIONS}"
177178
unset EMCC_FORCE_STDLIBS
178-
# LINKER="-sMAIN_MODULE=2 -sEXPORTED_FUNCTIONS=@${PGL_DIST_LINK}/exports/pglite"
179179
else
180180
# min
181181
# LINKER="-sMAIN_MODULE=2"
@@ -255,7 +255,7 @@ ________________________________________________________
255255
./wasm-build/linkimports.sh
256256
else
257257
echo "
258-
* linking node raw version of pglite failed"; exit 250
258+
* linking node raw version of pglite failed"; exit 261
259259

260260
fi
261261

@@ -293,13 +293,13 @@ ________________________________________________________
293293
-lnodefs.js -lidbfs.js -lxml2 -lz
294294
then
295295
du -hs du -hs ${PG_DIST}/*
296-
touch ${WORKSPACE}/done
296+
touch ${WORKSPACE}/${BUILD}.done
297297
else
298298
echo "
299-
* linking web version of pglite failed"; exit 272
299+
* linking web version of pglite failed"; exit 302
300300
fi
301301
else
302-
echo "compilation of libpglite ${PG_BRANCH} failed"; exit 275
302+
echo "compilation of libpglite ${PG_BRANCH} failed"; exit 305
303303
fi
304304
fi
305305

pglite-REL_17_4_WASM/repl.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@
137137

138138
vm.FS.unlink(vm.PGDATA + "/postgresql.conf")
139139
vm.FS.writeFile( vm.PGDATA + "/postgresql.conf", lines.join("\n") )
140-
vm.FS.syncfs(false, (e) => { if (e) console.error("pgl_conf:", e)})
140+
try {
141+
vm.FS.syncfs(false, (e) => { /* if (e) console.error("pgl_conf:", e) */ })
142+
} catch (x) {
143+
console.error("pgl_conf: exception", x)
144+
}
141145

142146
console.log("Config file written at :", vm.PGDATA + "/postgresql.conf" )
143147
}
@@ -305,7 +309,9 @@
305309
return text_codec.decode( new Uint8Array(ary) )
306310
}
307311
window.b_utf8 = b_utf8
312+
308313
// /tmp/pglite/base/postgresql.conf
314+
309315
function test_drive(step) {
310316
var data = null
311317
switch (test_step) {

portable/portable.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ Fatal: failed to apply patch : $one
513513
* Done setup emsdk+wasi sdk from $SDK_URL
514514
515515
"
516-
read
517516
fi
518517

519518

wasm-build.sh

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ else
7676
# dev debug
7777
export COPTS="-O2 -g3 --no-wasm-opt"
7878
export LOPTS=${LOPTS:-"-O2 -g3 --no-wasm-opt -sASSERTIONS=1"}
79+
7980
else
8081
# docker debug ( exepected to be ide friendly )
8182
export COPTS="-g3 --no-wasm-opt"
8283
export LOPTS=${LOPTS:-"-g3 --no-wasm-opt -sASSERTIONS=1"}
8384
fi
85+
86+
export COPTS="-O2 -sDEMANGLE_SUPPORT=1 -frtti -g4 --no-wasm-opt"
87+
export LOPTS=${LOPTS:-"-O1 -sDEMANGLE_SUPPORT=1 -frtti -g4 --no-wasm-opt -sASSERTIONS=1"}
88+
8489
else
8590
# DO NOT CHANGE COPTS - optimized wasm corruption fix
8691
export COPTS="-O2 -g3 --no-wasm-opt"
@@ -178,7 +183,7 @@ pushd ${SDKROOT}
178183
echo "$PORTABLE : sdk check passed (emscripten)"
179184
else
180185
echo emsdk failed
181-
exit 176
186+
exit 181
182187
fi
183188

184189

@@ -278,7 +283,7 @@ END
278283
ERROR: $(which wasm-objdump) not working properly ( is wasmtime ok ? )
279284
280285
"
281-
exit 262
286+
exit 281
282287
fi
283288
fi
284289
fi
@@ -451,8 +456,25 @@ then
451456
if $WASI
452457
then
453458
echo "
454-
* WASI build : skipping FS building
459+
* WASI build : TODO: FS building
460+
* WASI build : TODO: ext linking
455461
"
462+
cat > pglite-link.sh <<END
463+
. ${PGROOT}/pgopts.sh
464+
. ${SDKROOT}/wasm32-bi-emscripten-shell.sh
465+
if ./pglite-${PG_BRANCH}/build.sh
466+
then
467+
echo "TODO: tests"
468+
fi
469+
END
470+
471+
chmod +x pglite-link.sh
472+
473+
if ./pglite-link.sh
474+
then
475+
echo "TODO: extensions fs packing"
476+
fi
477+
456478
else
457479

458480
# this is for initial emscripten MEMFS
@@ -464,16 +486,11 @@ then
464486
--preload-file placeholder@${PGROOT}/bin/postgres \
465487
--preload-file placeholder@${PGROOT}/bin/initdb\
466488
"
467-
fi
468489

469-
echo "
470-
* building + linking pglite-wasm (initdb/loop/transport/repl/backend)
490+
echo "
491+
* emsdk: building + linking pglite-wasm (initdb/loop/transport/repl/backend)
471492
"
472493

473-
if $WASI
474-
then
475-
echo "TODO: wasi pack/tests"
476-
else
477494
cat > pglite-link.sh <<END
478495
. ${PGROOT}/pgopts.sh
479496
. ${SDKROOT}/wasm32-bi-emscripten-shell.sh
@@ -492,10 +509,15 @@ then
492509
493510
cp ${PGL_DIST_WEB}/pglite.* pglite/packages/pglite/release/
494511
pushd pglite
495-
export HOME=$PG_BUILD
496-
export PNPM_HOME=$PG_BUILD
497-
export PATH=$(echo -n ${SDKROOT}/emsdk/node/*.*.*/bin):$PNPM_HOME:$PATH
498-
which pnpm || npm install -g pnpm
512+
export PNPM_HOME=\$(echo -n $SDKROOT/emsdk/node/*.*.*/bin)
513+
export PATH=\$PNPM_HOME:\$PATH
514+
515+
if which pnpm
516+
then
517+
echo -n
518+
else
519+
npm install -g pnpm@latest-10
520+
fi
499521
pnpm install -g npm vitest
500522
pnpm install
501523
pnpm run ts:build
@@ -507,7 +529,7 @@ then
507529
else
508530
if $CI
509531
then
510-
./runtests.sh || exit 580
532+
./runtests.sh || exit 515
511533
fi
512534
fi
513535
fi
@@ -531,7 +553,7 @@ END
531553
done
532554
fi
533555
else
534-
exit 676
556+
exit 539
535557
fi
536558
fi
537559
else

wasm-build/build-ext.sh

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,82 @@
1+
2+
mkdir -p ${PGL_DIST_LINK}/exports ${PGL_DIST_LINK}/imports
3+
cd ${WORKSPACE}
4+
5+
16
if $WASI
27
then
38
echo "
49
5-
* WASI: skipping contrib extensions build
10+
* WASI: skipping some contrib extensions build
611
712
"
8-
else
9-
mkdir -p ${PGL_DIST_LINK}/exports ${PGL_DIST_LINK}/imports
10-
cd ${WORKSPACE}
11-
12-
if $WASI
13-
then
1413
echo " ========= TODO WASI openssl ============== "
1514
SKIP="\
1615
[\
1716
sslinfo bool_plperl hstore_plperl hstore_plpython jsonb_plperl jsonb_plpython\
1817
ltree_plpython sepgsql bool_plperl start-scripts\
1918
pgcrypto uuid-ossp xml2\
2019
]"
21-
else
22-
# TEMP FIX for SDK
23-
SSL_INCDIR=$EMSDK/upstream/emscripten/cache/sysroot/include/openssl
24-
[ -f $SSL_INCDIR/evp.h ] || ln -s $PREFIX/include/openssl $SSL_INCDIR
25-
SKIP="\
20+
21+
else
22+
23+
# TEMP FIX for SDK
24+
SSL_INCDIR=$EMSDK/upstream/emscripten/cache/sysroot/include/openssl
25+
[ -f $SSL_INCDIR/evp.h ] || ln -s $PREFIX/include/openssl $SSL_INCDIR
26+
SKIP="\
2627
[\
2728
sslinfo bool_plperl hstore_plperl hstore_plpython jsonb_plperl jsonb_plpython\
2829
ltree_plpython sepgsql bool_plperl start-scripts\
2930
]"
30-
fi
3131

32-
for extdir in postgresql-${PG_BRANCH}/contrib/*
33-
do
32+
fi
33+
34+
# common wasi/emsdk contrib build
3435

35-
if [ -d "$extdir" ]
36+
for extdir in postgresql-${PG_BRANCH}/contrib/*
37+
do
38+
39+
if [ -d "$extdir" ]
40+
then
41+
ext=$(echo -n $extdir|cut -d/ -f3)
42+
if echo -n $SKIP|grep -q "$ext "
3643
then
37-
ext=$(echo -n $extdir|cut -d/ -f3)
38-
if echo -n $SKIP|grep -q "$ext "
44+
echo "
45+
46+
skipping extension $ext
47+
48+
"
49+
else
50+
echo "
51+
52+
Building contrib extension : $ext : begin
53+
54+
"
55+
pushd ${BUILD_PATH}/contrib/$ext
56+
if PATH=$PREFIX/bin:$PATH emmake make install 2>&1 >/dev/null
3957
then
40-
echo skipping extension $ext
41-
else
4258
echo "
4359
44-
Building contrib extension : $ext : begin
60+
Building contrib extension : $ext : end
4561
46-
"
47-
pushd ${BUILD_PATH}/contrib/$ext
48-
if PATH=$PREFIX/bin:$PATH emmake make install 2>&1 >/dev/null
49-
then
50-
echo "
51-
Building contrib extension : $ext : end
52-
"
53-
else
54-
echo "
62+
"
63+
else
64+
echo "
5565
56-
Extension $ext from $extdir failed to build
66+
Extension $ext from $extdir failed to build
5767
58-
"
59-
exit 216
60-
fi
61-
popd
68+
"
69+
exit 69
70+
fi
71+
popd
6272

63-
python3 ${PORTABLE}/pack_extension.py 2>&1 >/dev/null
73+
python3 ${PORTABLE}/pack_extension.py 2>&1 >/dev/null
6474

65-
fi
6675
fi
67-
done
76+
fi
77+
done
78+
6879

69-
fi
7080

7181

7282
echo "

wasm-build/sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ WASI=${WASI:-false}
44
SDKROOT=${SDKROOT:-/tmp/sdk}
55
mkdir -p ${SDKROOT}
66

7+
if [ -f /alpine ]
8+
then
9+
cp -f /usr/bin/node ${SDKROOT}/emsdk/node/*.*.*/bin/
10+
fi
711

812
# always install wasmtime because wasm-objdump needs it.
913
if [ -f ${SDKROOT}/devices/$(arch)/usr/bin/wasmtime ]

0 commit comments

Comments
 (0)