Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6255cdf
some cleanup
Sep 23, 2025
97dbb55
do not run ./configure if not needed; specify portname in clean script
tdrz Sep 24, 2025
bd5acf4
cleanup
tdrz Sep 24, 2025
52b61d8
Merge branch 'REL_17_5_WASM-pglite-builder' into tdrz/ccoderefactoring
tdrz Sep 24, 2025
7e4257c
remove startup_hacks
tdrz Sep 24, 2025
1743988
readd initdb requirements
tdrz Sep 24, 2025
09a5666
add linker search path for backend
tdrz Sep 24, 2025
c570404
remove get_buffer_size and get_buffer_addr"
tdrz Sep 24, 2025
8f1bad6
remove recv_password_packet in interactive_one
tdrz Sep 24, 2025
bb1befd
removed pglite-modpython.c; removed __PYDK__
tdrz Sep 24, 2025
068679e
remove specifing MIN_SAFARI_VERSION since that is the default value a…
tdrz Sep 24, 2025
ee194e6
moved some of the emscripten flags to bash script to allow a native b…
tdrz Sep 24, 2025
e57f54c
docker run under current user
tdrz Sep 24, 2025
bc1a2c8
improved cleanup
tdrz Sep 24, 2025
7c73e9c
readd recv_password_packet to interactive_one.c
tdrz Sep 24, 2025
58724c5
remove -it when running docker
tdrz Sep 24, 2025
b4b9af3
script fix
tdrz Sep 24, 2025
433ce1e
fix build-with-docker.sh script for GH actions; cleanup target for ex…
tdrz Sep 24, 2025
4b7eafe
fix
tdrz Sep 24, 2025
dd474bc
cb data transport
tdrz Oct 1, 2025
6cf2d5f
cleanup
tdrz Oct 1, 2025
fd02949
nothing
tdrz Oct 2, 2025
3df81f3
more cleanup
tdrz Oct 2, 2025
a4013b5
cleanup is_repl and others
tdrz Oct 6, 2025
d512ff5
sort included imports
tdrz Oct 6, 2025
5452dfc
add a pq_flush() at the end of interactive_one(). this is needed beca…
tdrz Oct 6, 2025
e6ac5c2
more cleanup
tdrz Oct 6, 2025
8f14aca
remove repl.html
tdrz Oct 6, 2025
da47168
more cleanup
tdrz Oct 6, 2025
d7e7832
:)
tdrz Oct 7, 2025
b570638
remove things not working
tdrz Oct 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions build-pglite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,28 @@ fi

echo "pglite: PGLITE_CFLAGS=$PGLITE_CFLAGS"

# run ./configure only if config.status is older than this file
# TODO: we should ALSO check if any of the PGLITE_CFLAGS have changed and trigger a ./configure if they did!!!
REF_FILE="build-pglite.sh"
CONFIG_STATUS="config.status"
RUN_CONFIGURE=false

if [ ! -f "$CONFIG_STATUS" ]; then
echo "$CONFIG_STATUS does not exist, need to run ./configure"
RUN_CONFIGURE=true
elif [ "$REF_FILE" -nt "$CONFIG_STATUS" ]; then
echo "$CONFIG_STATUS is older than $REF_FILE. Need to run ./configure."
RUN_CONFIGURE=true
else
echo "$CONFIG_STATUS exists and is newer than $REF_FILE. ./configure will NOT be run."
fi

# Step 1: configure the project
LDFLAGS="-sWASM_BIGINT -sUSE_PTHREADS=0" CFLAGS="${PGLITE_CFLAGS} -sWASM_BIGINT -fpic -sENVIRONMENT=node,web,worker -sSUPPORT_LONGJMP=emscripten -DPYDK=1 -DCMA_MB=12 -Wno-declaration-after-statement -Wno-macro-redefined -Wno-unused-function -Wno-missing-prototypes -Wno-incompatible-pointer-types" emconfigure ./configure ac_cv_exeext=.cjs --disable-spinlocks --disable-largefile --without-llvm --without-pam --disable-largefile --with-openssl=no --without-readline --without-icu --with-includes=$INSTALL_PREFIX/include:$INSTALL_PREFIX/include/libxml2 --with-libraries=$INSTALL_PREFIX/lib --with-uuid=ossp --with-zlib --with-libxml --with-libxslt --with-template=emscripten --prefix=$INSTALL_FOLDER || { echo 'error: emconfigure failed' ; exit 11; }
if [ "$RUN_CONFIGURE" = true ]; then
LDFLAGS="-sWASM_BIGINT -sUSE_PTHREADS=0" CFLAGS="${PGLITE_CFLAGS} -sWASM_BIGINT -fpic -sENVIRONMENT=node,web,worker -sSUPPORT_LONGJMP=emscripten -Wno-declaration-after-statement -Wno-macro-redefined -Wno-unused-function -Wno-missing-prototypes -Wno-incompatible-pointer-types" emconfigure ./configure ac_cv_exeext=.cjs --disable-spinlocks --disable-largefile --without-llvm --without-pam --disable-largefile --with-openssl=no --without-readline --without-icu --with-includes=$INSTALL_PREFIX/include:$INSTALL_PREFIX/include/libxml2 --with-libraries=$INSTALL_PREFIX/lib --with-uuid=ossp --with-zlib --with-libxml --with-libxslt --with-template=emscripten --prefix=$INSTALL_FOLDER || { echo 'error: emconfigure failed' ; exit 11; }
else
echo "Warning: configure has not been run because RUN_CONFIGURE=${RUN_CONFIGURE}"
fi

# Step 2: make and install all except pglite
emmake make PORTNAME=emscripten -j || { echo 'error: emmake make PORTNAME=emscripten -j' ; exit 21; }
Expand All @@ -42,5 +62,16 @@ emmake make OPTFLAGS="" PORTNAME=emscripten LDFLAGS_SL="-sSIDE_MODULE=1" -C pgli
PATH=$SAVE_PATH

# Step 5: make and install pglite
# we define here "all" emscripten flags in order to allow native builds (like libpglite)
EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction"
PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \
-sSUPPORT_LONGJMP=emscripten \
-sFORCE_FILESYSTEM=1 \
-sNO_EXIT_RUNTIME=1 -sENVIRONMENT=node,web,worker \
-sMAIN_MODULE=2 -sMODULARIZE=1 -sEXPORT_ES6=1 \
-sEXPORT_NAME=Module -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH \
-sERROR_ON_UNDEFINED_SYMBOLS=1 \
-sEXPORTED_RUNTIME_METHODS=$EXPORTED_RUNTIME_METHODS"

# Building pglite itself needs to be the last step because of the PRELOAD_FILES parameter (a list of files and folders) need to be available.
PGLITE_CFLAGS=$PGLITE_CFLAGS emmake make PORTNAME=emscripten -j -C src/backend/ install-pglite || { echo 'emmake make OPTFLAGS="" PORTNAME=emscripten -j -C pglite' ; exit 51; }
PGLITE_CFLAGS="$PGLITE_CFLAGS $PGLITE_EMSCRIPTEN_FLAGS" emmake make PORTNAME=emscripten -j -C src/backend/ install-pglite || { echo 'emmake make OPTFLAGS="" PORTNAME=emscripten -j -C pglite' ; exit 51; }
2 changes: 1 addition & 1 deletion build-with-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ docker run $@ \
--workdir=${DOCKER_WORKSPACE} \
-v .:${DOCKER_WORKSPACE}:rw \
-v ./dist:/install/pglite:rw \
electricsql/pglite-builder:3.1.74_1 \
electricsql/pglite-builder:3.1.74_2 \
./build-pglite.sh

12 changes: 8 additions & 4 deletions clean-pglite.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

emmake make -C src/backend uninstall; emmake make -C src/backend clean;
emmake make -C pglite/ clean; emmake make -C pglite/ uninstall;
emmake make -C contrib/ clean; emmake make -C contrib/ uninstall; emmake make -C pglite clean; emmake make -C pglite uninstall;
emmake make clean; emmake make uninstal
emmake make PORTNAME=emscripten -C src/backend uninstall; emmake make PORTNAME=emscripten -C src/backend clean;
emmake make PORTNAME=emscripten -C pglite/ clean; emmake make PORTNAME=emscripten -C pglite/ uninstall;
emmake make PORTNAME=emscripten -C contrib/ clean; emmake make PORTNAME=emscripten -C contrib/ uninstall;
emmake make PORTNAME=emscripten -C pglite clean; emmake make PORTNAME=emscripten -C pglite uninstall;
emmake make PORTNAME=emscripten clean; emmake make PORTNAME=emscripten uninstall;

echo "removing config.status"
rm config.status
1 change: 1 addition & 0 deletions other/empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PGlite is the best!
9 changes: 7 additions & 2 deletions pglite-wasm/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG BUILDPLATFORM
# we only need to build on one platform, since we're interested in the WASM output
# building on the native (BUILDPLATFORM) is much faster, so use that
# remove "-arm64" suffix if building on x86_64
FROM --platform=$BUILDPLATFORM emscripten/emsdk:${EMSDK_VER}-arm64 AS builder
FROM --platform=$BUILDPLATFORM emscripten/emsdk:${EMSDK_VER} AS builder

ENV LLVM_NM=/emsdk/upstream/bin/llvm-nm

Expand All @@ -21,7 +21,7 @@ WORKDIR /install/libs

WORKDIR /src

# ENV EMCC_COMMON_FLAGS="-fPIC -sWASM_BIGINT -sMIN_SAFARI_VERSION=150000 -D__PYDK__=1 -O2 -m32 -D_FILE_OFFSET_BITS=64 -sSUPPORT_LONGJMP=emscripten -mno-bulk-memory -mnontrapping-fptoint -mno-reference-types -mno-sign-ext -mno-extended-const -mno-atomics -mno-tail-call -mno-multivalue -mno-relaxed-simd -mno-simd128 -mno-multimemory -mno-exception-handling -Wno-unused-command-line-argument -Wno-unreachable-code-fallthrough -Wno-unused-function -Wno-invalid-noreturn -Wno-declaration-after-statement -Wno-invalid-noreturn"
# ENV EMCC_COMMON_FLAGS="-fPIC -sWASM_BIGINT -sMIN_SAFARI_VERSION=150000 -O2 -m32 -D_FILE_OFFSET_BITS=64 -sSUPPORT_LONGJMP=emscripten -mno-bulk-memory -mnontrapping-fptoint -mno-reference-types -mno-sign-ext -mno-extended-const -mno-atomics -mno-tail-call -mno-multivalue -mno-relaxed-simd -mno-simd128 -mno-multimemory -mno-exception-handling -Wno-unused-command-line-argument -Wno-unreachable-code-fallthrough -Wno-unused-function -Wno-invalid-noreturn -Wno-declaration-after-statement -Wno-invalid-noreturn"
ENV EMCC_COMMON_FLAGS="-O2 -fPIC"

WORKDIR /src
Expand Down Expand Up @@ -60,6 +60,8 @@ RUN ${LLVM_NM} /install/libs/lib/libssl.a | awk '$2 ~ /^[TDB]$/ {print $3}' | se

WORKDIR /src
RUN curl -L ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz | tar xz
# COPY . .
# RUN tar xvf uuid-1.6.2.tar.gz
WORKDIR /src/uuid-1.6.2
RUN CFLAGS="${EMCC_COMMON_FLAGS}" CXXFLAGS="${EMCC_COMMON_FLAGS}" emconfigure ./configure --build=aarch64-unknown-linux-gnu --enable-shared=no --enable-static=yes --with-perl=no --with-perl-compat=no --prefix=/install/libs --with-php=no --with-pic=yes
RUN emmake make -j && emmake make install || true # install tries to strip the wasm, but it doesnt recognize the format, so ignore atm
Expand All @@ -85,5 +87,8 @@ ENV LIB_EXPORTS_DIR=${LIB_EXPORTS_DIR}
COPY --from=builder /install/libs ${INSTALL_PREFIX}
COPY --from=builder /install/exports ${LIB_EXPORTS_DIR}

# allow access to anyone
RUN chmod -R 777 /install

# needed in building pglite.wasm
ENV LLVM_NM=/emsdk/upstream/bin/llvm-nm
9 changes: 2 additions & 7 deletions pglite-wasm/included.pglite.imports
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
close
fcntl
free
get_buffer_addr
get_buffer_size
get_channel
getpid
gettimeofday
gmtime
interactive_one
interactive_read
interactive_write
ioctl
isalnum
isxdigit
Expand All @@ -29,10 +24,10 @@ read
readstoplist
realloc
searchstoplist
set_read_write_cbs
socket
srand
strcmp
strftime
strlen
strtoul
use_wire
strtoul
Loading