From d14c790fb1be99639df69593cbaff6258d0e83c8 Mon Sep 17 00:00:00 2001 From: tudor Date: Wed, 5 Nov 2025 13:53:18 +0100 Subject: [PATCH 01/20] cleanup --- src/backend/Makefile | 4 ++-- src/include/port/pg_pthread.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/backend/Makefile b/src/backend/Makefile index 0bc6a84c3b10a..1c04efeab0099 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -110,8 +110,8 @@ pglite: pglite-exported-functions $(CC) $(CFLAGS) $(LDFLAGS) -DPG_PREFIX=/tmp/pglite -I$(top_builddir)/src/include -I$(top_builddir)/src/ -I$(top_builddir)/src/interfaces/libpq -o pglite.o -c $(top_builddir)/$(PGLITE_MAIN) -Wno-incompatible-pointer-types-discards-qualifiers $(CC) \ $(PGLITE_CFLAGS) \ - -fPIC -m32 -D_FILE_OFFSET_BITS=64 -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 \ - -DPYDK=1 -DPG_PREFIX=/tmp/pglite -o pglite.html \ + -fPIC -m32 -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 \ + -DPG_PREFIX=/tmp/pglite -o pglite.html \ $(PGPRELOAD) \ -ferror-limit=1 \ -sEXPORTED_FUNCTIONS=@$(emscripten_imports_dir)/exported_functions.txt \ diff --git a/src/include/port/pg_pthread.h b/src/include/port/pg_pthread.h index 6922eb423b945..b3d4ffbf59353 100644 --- a/src/include/port/pg_pthread.h +++ b/src/include/port/pg_pthread.h @@ -12,9 +12,6 @@ #ifndef PG_PTHREAD_H #define PG_PTHREAD_H -#if defined(__wasi__) -#define PYDK -#endif /* __wasi__ */ #include #ifndef HAVE_PTHREAD_BARRIER_WAIT From 1ccb2d383226687a3a326c1a09fbb092196a1d9c Mon Sep 17 00:00:00 2001 From: tudor Date: Wed, 5 Nov 2025 14:24:42 +0100 Subject: [PATCH 02/20] initial pg_uuidv7 commit --- .gitmodules | 3 +++ pglite/pg_uuidv7 | 1 + 2 files changed, 4 insertions(+) create mode 160000 pglite/pg_uuidv7 diff --git a/.gitmodules b/.gitmodules index 94158709d174c..60cfbe40928c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "pglite/pgtap"] path = pglite/pgtap url = https://github.com/theory/pgtap.git +[submodule "pglite/pg_uuidv7"] + path = pglite/pg_uuidv7 + url = https://github.com/fboulnois/pg_uuidv7/ diff --git a/pglite/pg_uuidv7 b/pglite/pg_uuidv7 new file mode 160000 index 0000000000000..c707aae241118 --- /dev/null +++ b/pglite/pg_uuidv7 @@ -0,0 +1 @@ +Subproject commit c707aae2411181be4802f5fa565b44d9c0bcbc29 From 1195d5388bd5529e0013c45fa816cfcd953d84e0 Mon Sep 17 00:00:00 2001 From: tudor Date: Wed, 5 Nov 2025 14:51:58 +0100 Subject: [PATCH 03/20] backend pg_uuidv7 implemented --- pglite/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pglite/Makefile b/pglite/Makefile index f6bc99b8e50cc..633fe686b9eba 100644 --- a/pglite/Makefile +++ b/pglite/Makefile @@ -6,7 +6,8 @@ include $(top_builddir)/src/Makefile.global SUBDIRS = \ pg_ivm \ vector \ - pgtap + pgtap \ + pg_uuidv7 prefix ?= /install/pglite EXTENSIONS_BUILD_ROOT := /tmp/extensions/build From da9387504aceb4caa41279b7eb5635ee3046f7e6 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 10:07:54 +0100 Subject: [PATCH 04/20] new try to make pgcrypto work on CI --- build-pglite.sh | 6 ++ build-with-docker.sh | 2 +- contrib/Makefile | 4 + contrib/pgcrypto/Makefile | 3 - pglite-wasm/builder/Dockerfile | 9 +- pglite-wasm/included.pglite.imports | 148 +++++++++++++++++++++++++++- pglite/build-pgcrypto.sh | 6 ++ 7 files changed, 169 insertions(+), 9 deletions(-) create mode 100755 pglite/build-pgcrypto.sh diff --git a/build-pglite.sh b/build-pglite.sh index 3500a9dc1ebee..740ed6a3f5074 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -65,11 +65,17 @@ emmake make PORTNAME=emscripten -j || { echo 'error: emmake make PORTNAME=emscri emmake make PORTNAME=emscripten install || { echo 'error: emmake make PORTNAME=emscripten install' ; exit 22; } # Step 3.1: make all contrib extensions - do not install +# Step 3.1.1 pgcrypto - special case +cd ./pglite/ && ./build-pgcrypto.sh && cd ../ +# Step 3.1.2 all the rest of contrib emmake make PORTNAME=emscripten -C contrib/ -j || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ -j' ; exit 31; } # Step 3.2: make dist contrib extensions - this will create an archive for each extension emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } # the above will also create a file with the imports that each extension needs - we pass these as input in the next step for emscripten to keep alive +# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported +find / -name pgcrypto.imports -exec rm -f {} \; + # Step 4: make and dist other extensions SAVE_PATH=$PATH PATH=$PATH:$INSTALL_FOLDER/bin diff --git a/build-with-docker.sh b/build-with-docker.sh index 6a849b52ab863..2e7bbddbe24a3 100755 --- a/build-with-docker.sh +++ b/build-with-docker.sh @@ -8,6 +8,6 @@ docker run $@ \ --workdir=${DOCKER_WORKSPACE} \ -v .:${DOCKER_WORKSPACE}:rw \ -v ./dist:/install/pglite:rw \ - electricsql/pglite-builder:3.1.74_2 \ + electricsql/pglite-builder:3.1.74_4 \ ./build-pglite.sh diff --git a/contrib/Makefile b/contrib/Makefile index 603636cd4d248..ec0e4c7fa84ea 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -57,6 +57,10 @@ else ALWAYS_SUBDIRS += pgcrypto sslinfo endif +ifeq ($(PORTNAME), emscripten) +SUBDIRS += pgcrypto +endif + ifneq ($(with_uuid),no) SUBDIRS += uuid-ossp else diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile index 8085114dca6c2..5efa10c334c80 100644 --- a/contrib/pgcrypto/Makefile +++ b/contrib/pgcrypto/Makefile @@ -62,9 +62,6 @@ endif # shared library link. (The order in which you list them here doesn't # matter.) SHLIB_LINK += $(filter -lcrypto -lz, $(LIBS)) -ifeq ($(PORTNAME), emscripten) -SHLIB_LINK += -lcrypto -endif ifeq ($(PORTNAME), win32) SHLIB_LINK += $(filter -leay32, $(LIBS)) # those must be at the end diff --git a/pglite-wasm/builder/Dockerfile b/pglite-wasm/builder/Dockerfile index cf613dd2ddc85..8bcf3c6bb6aa3 100644 --- a/pglite-wasm/builder/Dockerfile +++ b/pglite-wasm/builder/Dockerfile @@ -22,7 +22,7 @@ WORKDIR /install/libs WORKDIR /src # 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" +ENV EMCC_COMMON_FLAGS="-O2 -fPIC -sWASM_BIGINT" WORKDIR /src RUN curl -L https://www.zlib.net/zlib-1.3.1.tar.gz | tar -xz @@ -34,7 +34,7 @@ RUN ${LLVM_NM} /install/libs/lib/libz.a | awk '$2 ~ /^[TDB]$/ {print $3}' | sed WORKDIR /src RUN curl -L https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.14.5/libxml2-v2.14.5.tar.gz | tar -xz WORKDIR /src/libxml2-v2.14.5 -RUN ./autogen.sh --with-python=no +RUN ./autogen.sh --with-python=no --with-threads=no RUN CFLAGS="${EMCC_COMMON_FLAGS}" CXXFLAGS="${EMCC_COMMON_FLAGS}" emconfigure ./configure --enable-shared=no --enable-static=yes --with-python=no --prefix=/install/libs RUN emmake make -j && emmake make install # extract exported symbols - useful for passing them to emscripten as EXPORTED_FUNCTIONS @@ -52,11 +52,12 @@ RUN ${LLVM_NM} /install/libs/lib/libxslt.a | awk '$2 ~ /^[TDB]$/ {print $3}' | s WORKDIR /src RUN curl -L https://github.com/openssl/openssl/releases/download/openssl-3.0.17/openssl-3.0.17.tar.gz | tar xz WORKDIR /src/openssl-3.0.17 -RUN emconfigure ./Configure no-tests linux-generic64 --prefix=/install/libs +RUN CFLAGS="${EMCC_COMMON_FLAGS}" CXXFLAGS="${EMCC_COMMON_FLAGS}" emconfigure ./config no-sse2 no-hw no-asm no-tests no-threads no-shared linux-generic32 --prefix=/install/libs RUN sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile # see https://github.com/emscripten-core/emscripten/issues/19597#issue-1754476454 -RUN emmake make -j && emmake make install +RUN emmake make -j && emmake make install_sw install_ssldirs # extract exported symbols - useful for passing them to emscripten as EXPORTED_FUNCTIONS RUN ${LLVM_NM} /install/libs/lib/libssl.a | awk '$2 ~ /^[TDB]$/ {print $3}' | sed '/^$/d' | sort -u > /install/exports/libssl.exports +RUN ${LLVM_NM} /install/libs/lib/libcrypto.a | awk '$2 ~ /^[TDB]$/ {print $3}' | sed '/^$/d' | sort -u > /install/exports/libcrypto.exports WORKDIR /src RUN curl -L ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz | tar xz diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index 7a5d30d895111..179eedc72ac62 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -1,33 +1,179 @@ +__errno_location +abort +accept +appendStringInfo +appendStringInfoChar +appendStringInfoString +atexit +atoi +bind +BuildTupleFromCStrings +calloc +chmod +clearerr +clock_gettime close +closedir +closelog +connect +cstring_to_text +cstring_to_text_with_len +deconstruct_array_builtin +dladdr +dlclose +dlerror +dlopen +dlsym +downcase_truncate_identifier +end_MultiFuncCall +enlargeStringInfo +errcode +errfinish +errmsg +errmsg_internal +errstart +errstart_cold +fclose fcntl +fdopen +feof +ferror +fflush +fgets +fileno +fiprintf +fopen +fputc +fputs +fread free +freeaddrinfo +fseek +fstat +ftell +fwrite +gai_strerror +gen_random_uuid +get_call_result_type +getaddrinfo +GetDatabaseEncoding +getegid +getenv +geteuid +getgid +gethostbyname +getnameinfo getpid +getsockname +getsockopt gettimeofday +getuid gmtime +HeapTupleHeaderGetDatum +init_MultiFuncCall +initStringInfo interactive_one ioctl isalnum isxdigit +listen lowerstr +lseek +madvise main malloc +memchr memcmp memcpy +memmove +MemoryContextAlloc +MemoryContextAllocZero memset +mlock +mmap +mprotect +munmap nanosleep +ntohs open +opendir +openlog +palloc +palloc0 +per_MultiFuncCall +perror +pfree +pg_any_to_server +pg_detoast_datum +pg_detoast_datum_packed +pg_do_encoding_conversion +pg_is_ascii +pg_strcasecmp +pg_strong_random +pg_vsnprintf pgl_backend pgl_initdb pgl_shutdown +ProcessInterrupts +pstrdup +puts +qsort rand read +readdir readstoplist realloc +recvfrom +repalloc +ResourceOwnerEnlarge +ResourceOwnerForget +ResourceOwnerRemember searchstoplist +select +sendto set_read_write_cbs +setbuf +setsockopt +shutdown +sigaction +signal +siprintf +sleep +snprintf socket srand +sscanf +stat +stderr +strcat +strchr strcmp +strcpy +strcspn +strdup +strerror +strerror_r strftime +strlcpy strlen -strtoul \ No newline at end of file +strncat +strncmp +strncpy +strrchr +strspn +strstr +strtol +strtoul +sysconf +syslog +tcgetattr +tcsetattr +text_to_cstring +text_to_cstring_buffer +time +tolower +TupleDescGetAttInMetadata +usleep +vfprintf +vsnprintf +write \ No newline at end of file diff --git a/pglite/build-pgcrypto.sh b/pglite/build-pgcrypto.sh new file mode 100755 index 0000000000000..1d7369190fd8d --- /dev/null +++ b/pglite/build-pgcrypto.sh @@ -0,0 +1,6 @@ +#!/bin/bash +pushd ../contrib/pgcrypto +# these flags are used in pgxs.mk (postgresql extension makefile) and passed to the build process of that extension +emmake make LDFLAGS_SL="-sWASM_BIGINT -sSIDE_MODULE=1 -fexceptions -Wl,--whole-archive -lssl -lcrypto -Wl,--no-whole-archive" CFLAGS_SL="$PGLITE_CFLAGS -fexceptions -sWASM_BIGINT" -j +# emmake make PORTNAME=emscripten dist +popd \ No newline at end of file From 8ca11422280035381bfb92bb13723899e5fdc715 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 10:36:38 +0100 Subject: [PATCH 05/20] remove libcrypto and libssl exports --- src/backend/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/Makefile b/src/backend/Makefile index 1c04efeab0099..d4e40e4d410bb 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -95,7 +95,7 @@ postgres: $(OBJS) # excludes the one in excluded.pglite.imports and adds a leading _ to each. pglite-exported-functions: $(MKDIR_P) '$(emscripten_imports_dir)' - cat $(top_builddir)/pglite-wasm/excluded.*.imports $(top_builddir)/src/interfaces/libpq/exports.list $(LIB_EXPORTS_DIR)/libossp-uuid.exports | sort -u > '$(top_builddir)/pglite-wasm/excluded.imports' + cat $(top_builddir)/pglite-wasm/excluded.*.imports $(top_builddir)/src/interfaces/libpq/exports.list $(LIB_EXPORTS_DIR)/libossp-uuid.exports /install/exports/libcrypto.exports /install/exports/libssl.exports | sort -u > '$(top_builddir)/pglite-wasm/excluded.imports' cat $(DESTDIR)$(emscripten_extension_imports_dir)/*.imports '$(top_builddir)/pglite-wasm/included.pglite.imports' | \ sort -u | \ grep -Fvx -f '$(top_builddir)/pglite-wasm/excluded.imports' | \ From 41b92387c2ee8a7e7b6820b004958b17c242f78e Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 11:05:36 +0100 Subject: [PATCH 06/20] move build and dist to the end of build --- build-pglite.sh | 11 +++++++---- contrib/Makefile | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index 740ed6a3f5074..2245a74b1b71e 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -65,16 +65,13 @@ emmake make PORTNAME=emscripten -j || { echo 'error: emmake make PORTNAME=emscri emmake make PORTNAME=emscripten install || { echo 'error: emmake make PORTNAME=emscripten install' ; exit 22; } # Step 3.1: make all contrib extensions - do not install -# Step 3.1.1 pgcrypto - special case -cd ./pglite/ && ./build-pgcrypto.sh && cd ../ + # Step 3.1.2 all the rest of contrib emmake make PORTNAME=emscripten -C contrib/ -j || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ -j' ; exit 31; } # Step 3.2: make dist contrib extensions - this will create an archive for each extension emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } # the above will also create a file with the imports that each extension needs - we pass these as input in the next step for emscripten to keep alive -# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported -find / -name pgcrypto.imports -exec rm -f {} \; # Step 4: make and dist other extensions SAVE_PATH=$PATH @@ -95,3 +92,9 @@ PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -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 $PGLITE_EMSCRIPTEN_FLAGS" emmake make PORTNAME=emscripten -j -C src/backend/ install-pglite || { echo 'emmake make OPTFLAGS="" PORTNAME=emscripten -j -C pglite' ; exit 51; } + +# Step 3.1.1 pgcrypto - special case +cd ./pglite/ && ./build-pgcrypto.sh && cd ../ +PGLITE_WITH_PGCRYPTO=1 emmake make PORTNAME=emscripten -C contrib/ dist +# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported +# find / -name pgcrypto.imports -exec rm -f {} \; \ No newline at end of file diff --git a/contrib/Makefile b/contrib/Makefile index ec0e4c7fa84ea..ba794bfc35d60 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -57,7 +57,7 @@ else ALWAYS_SUBDIRS += pgcrypto sslinfo endif -ifeq ($(PORTNAME), emscripten) +ifeq ($(PGLITE_WITH_PGCRYPTO), 1) SUBDIRS += pgcrypto endif From b5bc713dbf02c6e7ff0c6eadf4fb1aaebca1960d Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 12:28:17 +0100 Subject: [PATCH 07/20] undo included.pglite.imports --- pglite-wasm/included.pglite.imports | 148 +--------------------------- 1 file changed, 1 insertion(+), 147 deletions(-) diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index 179eedc72ac62..7a5d30d895111 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -1,179 +1,33 @@ -__errno_location -abort -accept -appendStringInfo -appendStringInfoChar -appendStringInfoString -atexit -atoi -bind -BuildTupleFromCStrings -calloc -chmod -clearerr -clock_gettime close -closedir -closelog -connect -cstring_to_text -cstring_to_text_with_len -deconstruct_array_builtin -dladdr -dlclose -dlerror -dlopen -dlsym -downcase_truncate_identifier -end_MultiFuncCall -enlargeStringInfo -errcode -errfinish -errmsg -errmsg_internal -errstart -errstart_cold -fclose fcntl -fdopen -feof -ferror -fflush -fgets -fileno -fiprintf -fopen -fputc -fputs -fread free -freeaddrinfo -fseek -fstat -ftell -fwrite -gai_strerror -gen_random_uuid -get_call_result_type -getaddrinfo -GetDatabaseEncoding -getegid -getenv -geteuid -getgid -gethostbyname -getnameinfo getpid -getsockname -getsockopt gettimeofday -getuid gmtime -HeapTupleHeaderGetDatum -init_MultiFuncCall -initStringInfo interactive_one ioctl isalnum isxdigit -listen lowerstr -lseek -madvise main malloc -memchr memcmp memcpy -memmove -MemoryContextAlloc -MemoryContextAllocZero memset -mlock -mmap -mprotect -munmap nanosleep -ntohs open -opendir -openlog -palloc -palloc0 -per_MultiFuncCall -perror -pfree -pg_any_to_server -pg_detoast_datum -pg_detoast_datum_packed -pg_do_encoding_conversion -pg_is_ascii -pg_strcasecmp -pg_strong_random -pg_vsnprintf pgl_backend pgl_initdb pgl_shutdown -ProcessInterrupts -pstrdup -puts -qsort rand read -readdir readstoplist realloc -recvfrom -repalloc -ResourceOwnerEnlarge -ResourceOwnerForget -ResourceOwnerRemember searchstoplist -select -sendto set_read_write_cbs -setbuf -setsockopt -shutdown -sigaction -signal -siprintf -sleep -snprintf socket srand -sscanf -stat -stderr -strcat -strchr strcmp -strcpy -strcspn -strdup -strerror -strerror_r strftime -strlcpy strlen -strncat -strncmp -strncpy -strrchr -strspn -strstr -strtol -strtoul -sysconf -syslog -tcgetattr -tcsetattr -text_to_cstring -text_to_cstring_buffer -time -tolower -TupleDescGetAttInMetadata -usleep -vfprintf -vsnprintf -write \ No newline at end of file +strtoul \ No newline at end of file From 804f5f378c5fda1c5a28c25609a812264880cd93 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 13:51:40 +0100 Subject: [PATCH 08/20] change included imports --- build-pglite.sh | 5 +- pglite-wasm/included.pglite.imports | 123 +++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index 2245a74b1b71e..ff1523ea7cb4a 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -8,13 +8,14 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release -PGLITE_CFLAGS="-O2" +PGLITE_CFLAGS="-Wbad-function-cast -Wcast-function-type" if [ "$DEBUG" = true ] then echo "pglite: building debug version." - PGLITE_CFLAGS="-g -gsource-map --no-wasm-opt" + PGLITE_CFLAGS="$PGLITE_CFLAGS -g -gsource-map --no-wasm-opt" else echo "pglite: building release version." + PGLITE_CFLAGS="$PGLITE_CFLAGS -O2" # we shouldn't need to do this, but there's a bug somewhere that prevents a successful build if this is set unset DEBUG fi diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index 7a5d30d895111..a9ec46d14f0e5 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -1,33 +1,154 @@ +abort +accept +appendStringInfo +appendStringInfoChar +appendStringInfoString +atexit +atoi +bind +calloc +chmod +clearerr +clock_gettime close +closedir +closelog +connect +cstring_to_text +cstring_to_text_with_len +deconstruct_array_builtin +downcase_truncate_identifier +enlargeStringInfo +fclose fcntl +fdopen +feof +ferror +fflush +fgets +fileno +fiprintf +fopen +fputc +fputs +fread free +fseek +fstat +ftell +fwrite +gai_strerror +gen_random_uuid +get_call_result_type +GetDatabaseEncoding +getegid +getenv +geteuid +getgid +gethostbyname +getnameinfo getpid +getsockname +getsockopt gettimeofday +getuid gmtime +initStringInfo interactive_one ioctl isalnum isxdigit lowerstr +lseek +madvise main malloc +memchr memcmp memcpy +memmove memset +mlock +mmap +mprotect +munmap nanosleep +ntohs open +opendir +openlog +palloc +palloc0 +perror +pfree +pg_any_to_server +pg_detoast_datum +pg_detoast_datum_packed +pg_do_encoding_conversion +pg_is_ascii +pg_strcasecmp +pg_strong_random +pg_vsnprintf pgl_backend pgl_initdb pgl_shutdown +pstrdup +puts +qsort rand read +readdir readstoplist realloc +recvfrom +repalloc +ResourceOwnerEnlarge +ResourceOwnerForget +ResourceOwnerRemember searchstoplist +select +sendto set_read_write_cbs +setbuf +shutdown +sigaction +signal +siprintf +sleep +snprintf socket srand +sscanf +stat +stderr +strcat +strchr strcmp +strcpy +strcspn +strdup +strerror +strerror_r strftime +strlcpy strlen -strtoul \ No newline at end of file +strncat +strncmp +strncpy +strrchr +strspn +strstr +strtol +strtoul +sysconf +syslog +tcgetattr +tcsetattr +text_to_cstring +text_to_cstring_buffer +time +tolower +usleep +vfprintf +vsnprintf +write \ No newline at end of file From abef27f86476050e6a0882fadfbb26a9c1d3bdb3 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 14:45:47 +0100 Subject: [PATCH 09/20] readd includes for pgcrypto --- pglite-wasm/included.pglite.imports | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index a9ec46d14f0e5..ae8bdb0a2f521 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -6,6 +6,7 @@ appendStringInfoString atexit atoi bind +BuildTupleFromCStrings calloc chmod clearerr @@ -18,7 +19,14 @@ cstring_to_text cstring_to_text_with_len deconstruct_array_builtin downcase_truncate_identifier +end_MultiFuncCall enlargeStringInfo +errcode +errfinish +errmsg +errmsg_internal +errstart +errstart_cold fclose fcntl fdopen @@ -53,6 +61,8 @@ getsockopt gettimeofday getuid gmtime +HeapTupleHeaderGetDatum +init_MultiFuncCall initStringInfo interactive_one ioctl @@ -67,6 +77,8 @@ memchr memcmp memcpy memmove +MemoryContextAlloc +MemoryContextAllocZero memset mlock mmap @@ -79,6 +91,7 @@ opendir openlog palloc palloc0 +per_MultiFuncCall perror pfree pg_any_to_server @@ -92,6 +105,7 @@ pg_vsnprintf pgl_backend pgl_initdb pgl_shutdown +ProcessInterrupts pstrdup puts qsort @@ -148,6 +162,7 @@ text_to_cstring text_to_cstring_buffer time tolower +TupleDescGetAttInMetadata usleep vfprintf vsnprintf From 70845fe3769f3986499397ffaba632e7f36024ff Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 15:12:28 +0100 Subject: [PATCH 10/20] build debug version for CI --- build-pglite.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index ff1523ea7cb4a..aa75972d518f5 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -8,17 +8,17 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release -PGLITE_CFLAGS="-Wbad-function-cast -Wcast-function-type" -if [ "$DEBUG" = true ] -then - echo "pglite: building debug version." - PGLITE_CFLAGS="$PGLITE_CFLAGS -g -gsource-map --no-wasm-opt" -else - echo "pglite: building release version." - PGLITE_CFLAGS="$PGLITE_CFLAGS -O2" - # we shouldn't need to do this, but there's a bug somewhere that prevents a successful build if this is set - unset DEBUG -fi +PGLITE_CFLAGS="-g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" +# if [ "$DEBUG" = true ] +# then +# echo "pglite: building debug version." +# PGLITE_CFLAGS="$PGLITE_CFLAGS -g -gsource-map --no-wasm-opt" +# else +# echo "pglite: building release version." +# PGLITE_CFLAGS="$PGLITE_CFLAGS -O2" +# # we shouldn't need to do this, but there's a bug somewhere that prevents a successful build if this is set +# unset DEBUG +# fi echo "pglite: PGLITE_CFLAGS=$PGLITE_CFLAGS" From a16b7149bed05342d665525dd2449ce676395bea Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 15:27:41 +0100 Subject: [PATCH 11/20] -sDYLINK_DEBUG=2 for CI --- build-pglite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-pglite.sh b/build-pglite.sh index aa75972d518f5..300f5f5e249c4 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -8,7 +8,7 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release -PGLITE_CFLAGS="-g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" +PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" # if [ "$DEBUG" = true ] # then # echo "pglite: building debug version." From e03679165bf977a0b7a27373699c651e84c8e0ef Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 15:39:09 +0100 Subject: [PATCH 12/20] still trying to identify the missing function --- build-pglite.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-pglite.sh b/build-pglite.sh index 300f5f5e249c4..cf43c3770fd2c 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -8,7 +8,8 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release -PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" +# PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" +PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -O2" # if [ "$DEBUG" = true ] # then # echo "pglite: building debug version." From af0cb762cc2882b133188c2c1ae38dda62b2b615 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 18:38:51 +0100 Subject: [PATCH 13/20] trying to find the missing symbol --- .gitignore | 2 ++ build-pglite.sh | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 682db69d4d24c..28890f4bf4ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ pglite.js pglite.html *.map pglite-wasm/excluded.imports +*.js.symbols +*.so.symbols \ No newline at end of file diff --git a/build-pglite.sh b/build-pglite.sh index cf43c3770fd2c..5287e2a49ce3b 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -9,7 +9,7 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release # PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" -PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -O2" +PGLITE_CFLAGS="-sDYLINK_DEBUG=2 --emit-symbol-map -O2" # if [ "$DEBUG" = true ] # then # echo "pglite: building debug version." @@ -40,7 +40,7 @@ else fi # we define here "all" emscripten flags in order to allow native builds (like libpglite) -EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS" +EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS,wasmTable" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ @@ -83,7 +83,7 @@ emmake make OPTFLAGS="" PORTNAME=emscripten -C pglite/ dist || { echo 'error: ma PATH=$SAVE_PATH # Step 5: make and install pglite -EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction" +EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction,wasmTable" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ From 740a38490c413acc62629086c493fb23ef27cf00 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 19:01:14 +0100 Subject: [PATCH 14/20] add mode included functions --- pglite-wasm/included.pglite.imports | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index ae8bdb0a2f521..16f8412687014 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -19,6 +19,7 @@ cstring_to_text cstring_to_text_with_len deconstruct_array_builtin downcase_truncate_identifier +dtoi2 end_MultiFuncCall enlargeStringInfo errcode @@ -121,6 +122,7 @@ ResourceOwnerForget ResourceOwnerRemember searchstoplist select +SendSharedInvalidMessages sendto set_read_write_cbs setbuf From 31e629368c792e87131d6af5288514a98d24a45e Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 19:17:30 +0100 Subject: [PATCH 15/20] add mode included functions --- pglite-wasm/included.pglite.imports | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index 16f8412687014..f628b17166ea3 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -17,9 +17,29 @@ closelog connect cstring_to_text cstring_to_text_with_len +dacos +dacosd +dasin +datan +datan2 +dcbrt +dceil +dcos +dcot deconstruct_array_builtin +dexp +dfloor +dlog1 +dlog10 downcase_truncate_identifier +dpow +dround +dsign +dsin +dsqrt +dtan dtoi2 +dtrunc end_MultiFuncCall enlargeStringInfo errcode @@ -45,6 +65,8 @@ free fseek fstat ftell +ftoi2 +ftoi4 fwrite gai_strerror gen_random_uuid @@ -63,6 +85,10 @@ gettimeofday getuid gmtime HeapTupleHeaderGetDatum +i2tod +i2tof +i4tod +i4tof init_MultiFuncCall initStringInfo interactive_one From e99177dab7dd8dfd6aa0b014081693db77c5ab28 Mon Sep 17 00:00:00 2001 From: tudor Date: Thu, 11 Dec 2025 19:22:50 +0100 Subject: [PATCH 16/20] reduce amount of logs --- build-pglite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-pglite.sh b/build-pglite.sh index 5287e2a49ce3b..4f7fde65595b7 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -9,7 +9,7 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release # PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" -PGLITE_CFLAGS="-sDYLINK_DEBUG=2 --emit-symbol-map -O2" +PGLITE_CFLAGS="--emit-symbol-map -O2" # if [ "$DEBUG" = true ] # then # echo "pglite: building debug version." From caa1ec6973df5fd8660f9740c819400faf982e74 Mon Sep 17 00:00:00 2001 From: tudor Date: Tue, 16 Dec 2025 15:17:01 +0100 Subject: [PATCH 17/20] remove many exported functions that are apparently not needed --- .gitignore | 3 +- pglite-wasm/included.pglite.imports | 105 +--------------------------- 2 files changed, 3 insertions(+), 105 deletions(-) diff --git a/.gitignore b/.gitignore index 28890f4bf4ba3..f9d8874941d77 100644 --- a/.gitignore +++ b/.gitignore @@ -56,5 +56,4 @@ pglite.js pglite.html *.map pglite-wasm/excluded.imports -*.js.symbols -*.so.symbols \ No newline at end of file +*.symbols \ No newline at end of file diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index f628b17166ea3..ad348a8178828 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -1,73 +1,20 @@ -abort -accept +__errno_location appendStringInfo appendStringInfoChar appendStringInfoString atexit atoi -bind BuildTupleFromCStrings -calloc -chmod -clearerr -clock_gettime close -closedir -closelog -connect cstring_to_text cstring_to_text_with_len -dacos -dacosd -dasin -datan -datan2 -dcbrt -dceil -dcos -dcot deconstruct_array_builtin -dexp -dfloor -dlog1 -dlog10 downcase_truncate_identifier -dpow -dround -dsign -dsin -dsqrt -dtan -dtoi2 -dtrunc -end_MultiFuncCall enlargeStringInfo errcode -errfinish -errmsg -errmsg_internal -errstart -errstart_cold -fclose fcntl -fdopen -feof -ferror -fflush -fgets -fileno -fiprintf fopen -fputc -fputs -fread free -fseek -fstat -ftell -ftoi2 -ftoi4 -fwrite gai_strerror gen_random_uuid get_call_result_type @@ -76,28 +23,16 @@ getegid getenv geteuid getgid -gethostbyname -getnameinfo getpid -getsockname -getsockopt gettimeofday getuid gmtime -HeapTupleHeaderGetDatum -i2tod -i2tof -i4tod -i4tof -init_MultiFuncCall initStringInfo interactive_one ioctl isalnum isxdigit lowerstr -lseek -madvise main malloc memchr @@ -107,32 +42,20 @@ memmove MemoryContextAlloc MemoryContextAllocZero memset -mlock -mmap -mprotect -munmap nanosleep -ntohs open -opendir -openlog palloc palloc0 -per_MultiFuncCall perror pfree pg_any_to_server -pg_detoast_datum -pg_detoast_datum_packed pg_do_encoding_conversion pg_is_ascii pg_strcasecmp pg_strong_random -pg_vsnprintf pgl_backend pgl_initdb pgl_shutdown -ProcessInterrupts pstrdup puts qsort @@ -141,27 +64,15 @@ read readdir readstoplist realloc -recvfrom repalloc ResourceOwnerEnlarge ResourceOwnerForget ResourceOwnerRemember searchstoplist -select -SendSharedInvalidMessages -sendto set_read_write_cbs -setbuf -shutdown -sigaction -signal -siprintf -sleep -snprintf socket srand sscanf -stat stderr strcat strchr @@ -176,22 +87,10 @@ strlcpy strlen strncat strncmp -strncpy -strrchr -strspn strstr -strtol strtoul -sysconf -syslog -tcgetattr -tcsetattr text_to_cstring text_to_cstring_buffer time tolower -TupleDescGetAttInMetadata -usleep -vfprintf -vsnprintf -write \ No newline at end of file +TupleDescGetAttInMetadata \ No newline at end of file From 16ea22ce27216655c644589628f48ec6bd760395 Mon Sep 17 00:00:00 2001 From: tudor Date: Tue, 16 Dec 2025 15:19:26 +0100 Subject: [PATCH 18/20] undo changes to build_pglite.sh --- build-pglite.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index 4f7fde65595b7..9e71fa772e4fe 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -9,17 +9,17 @@ INSTALL_FOLDER=${INSTALL_FOLDER:-"/install/pglite"} # build with optimizations by default aka release # PGLITE_CFLAGS="-sDYLINK_DEBUG=2 -g -gsource-map --no-wasm-opt -Wbad-function-cast -Wcast-function-type" -PGLITE_CFLAGS="--emit-symbol-map -O2" -# if [ "$DEBUG" = true ] -# then -# echo "pglite: building debug version." -# PGLITE_CFLAGS="$PGLITE_CFLAGS -g -gsource-map --no-wasm-opt" -# else -# echo "pglite: building release version." -# PGLITE_CFLAGS="$PGLITE_CFLAGS -O2" -# # we shouldn't need to do this, but there's a bug somewhere that prevents a successful build if this is set -# unset DEBUG -# fi +PGLITE_CFLAGS="" +if [ "$DEBUG" = true ] +then + echo "pglite: building debug version." + PGLITE_CFLAGS="$PGLITE_CFLAGS -g -gsource-map --no-wasm-opt --emit-symbol-map" +else + echo "pglite: building release version." + PGLITE_CFLAGS="$PGLITE_CFLAGS -O2" + # we shouldn't need to do this, but there's a bug somewhere that prevents a successful build if this is set + unset DEBUG +fi echo "pglite: PGLITE_CFLAGS=$PGLITE_CFLAGS" From d57e66a77dda5cf31f52cbd18d854649d895be0a Mon Sep 17 00:00:00 2001 From: tudor Date: Tue, 16 Dec 2025 17:06:10 +0100 Subject: [PATCH 19/20] simplify build-pglite.sh script --- build-pglite.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index 9e71fa772e4fe..784db18ab6a3b 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -40,7 +40,7 @@ else fi # we define here "all" emscripten flags in order to allow native builds (like libpglite) -EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS,wasmTable" +EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ @@ -68,10 +68,15 @@ emmake make PORTNAME=emscripten install || { echo 'error: emmake make PORTNAME=e # Step 3.1: make all contrib extensions - do not install +# Step 3.1.1 pgcrypto - special case +cd ./pglite/ && ./build-pgcrypto.sh && cd ../ +# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported +find / -name pgcrypto.imports -exec rm -f {} \; + # Step 3.1.2 all the rest of contrib emmake make PORTNAME=emscripten -C contrib/ -j || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ -j' ; exit 31; } # Step 3.2: make dist contrib extensions - this will create an archive for each extension -emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } +PGLITE_WITH_PGCRYPTO=1 emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } # the above will also create a file with the imports that each extension needs - we pass these as input in the next step for emscripten to keep alive @@ -83,7 +88,7 @@ emmake make OPTFLAGS="" PORTNAME=emscripten -C pglite/ dist || { echo 'error: ma PATH=$SAVE_PATH # Step 5: make and install pglite -EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction,wasmTable" +EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ @@ -94,9 +99,3 @@ PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -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 $PGLITE_EMSCRIPTEN_FLAGS" emmake make PORTNAME=emscripten -j -C src/backend/ install-pglite || { echo 'emmake make OPTFLAGS="" PORTNAME=emscripten -j -C pglite' ; exit 51; } - -# Step 3.1.1 pgcrypto - special case -cd ./pglite/ && ./build-pgcrypto.sh && cd ../ -PGLITE_WITH_PGCRYPTO=1 emmake make PORTNAME=emscripten -C contrib/ dist -# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported -# find / -name pgcrypto.imports -exec rm -f {} \; \ No newline at end of file From f4f82f77c0cbf9922cb839854d678904803bc0bf Mon Sep 17 00:00:00 2001 From: tudor Date: Tue, 16 Dec 2025 19:00:25 +0100 Subject: [PATCH 20/20] revert build-pglite.sh --- build-pglite.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/build-pglite.sh b/build-pglite.sh index 784db18ab6a3b..9e71fa772e4fe 100755 --- a/build-pglite.sh +++ b/build-pglite.sh @@ -40,7 +40,7 @@ else fi # we define here "all" emscripten flags in order to allow native builds (like libpglite) -EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS" +EXPORTED_RUNTIME_METHODS="addFunction,removeFunction,FS,MEMFS,wasmTable" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ @@ -68,15 +68,10 @@ emmake make PORTNAME=emscripten install || { echo 'error: emmake make PORTNAME=e # Step 3.1: make all contrib extensions - do not install -# Step 3.1.1 pgcrypto - special case -cd ./pglite/ && ./build-pgcrypto.sh && cd ../ -# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported -find / -name pgcrypto.imports -exec rm -f {} \; - # Step 3.1.2 all the rest of contrib emmake make PORTNAME=emscripten -C contrib/ -j || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ -j' ; exit 31; } # Step 3.2: make dist contrib extensions - this will create an archive for each extension -PGLITE_WITH_PGCRYPTO=1 emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } +emmake make PORTNAME=emscripten -C contrib/ dist || { echo 'error: emmake make PORTNAME=emscripten -C contrib/ dist' ; exit 32; } # the above will also create a file with the imports that each extension needs - we pass these as input in the next step for emscripten to keep alive @@ -88,7 +83,7 @@ emmake make OPTFLAGS="" PORTNAME=emscripten -C pglite/ dist || { echo 'error: ma PATH=$SAVE_PATH # Step 5: make and install pglite -EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction" +EXPORTED_RUNTIME_METHODS="MEMFS,IDBFS,FS,setValue,getValue,UTF8ToString,stringToNewUTF8,stringToUTF8OnStack,addFunction,removeFunction,wasmTable" PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -sSUPPORT_LONGJMP=emscripten \ -sFORCE_FILESYSTEM=1 \ @@ -99,3 +94,9 @@ PGLITE_EMSCRIPTEN_FLAGS="-sWASM_BIGINT \ -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 $PGLITE_EMSCRIPTEN_FLAGS" emmake make PORTNAME=emscripten -j -C src/backend/ install-pglite || { echo 'emmake make OPTFLAGS="" PORTNAME=emscripten -j -C pglite' ; exit 51; } + +# Step 3.1.1 pgcrypto - special case +cd ./pglite/ && ./build-pgcrypto.sh && cd ../ +PGLITE_WITH_PGCRYPTO=1 emmake make PORTNAME=emscripten -C contrib/ dist +# hack for pgcrypto. since we're linking lssl and lcrypto directly to the extension, their respective symbols should not be exported +# find / -name pgcrypto.imports -exec rm -f {} \; \ No newline at end of file