From 64daf20470d666bacd9f65a4c3e130821d55392d Mon Sep 17 00:00:00 2001 From: tdrz Date: Mon, 21 Apr 2025 11:08:12 +0200 Subject: [PATCH 1/6] map local folder as readonly inside docker, use copy such that the output of the build will not polute the host --- wasm-build/build-with-docker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wasm-build/build-with-docker.sh b/wasm-build/build-with-docker.sh index 2da234e657338..59c111f796f1c 100755 --- a/wasm-build/build-with-docker.sh +++ b/wasm-build/build-with-docker.sh @@ -22,7 +22,7 @@ cat .buildconfig docker run \ --rm \ --env-file .buildconfig \ - -v .:/workspace:rw \ + -v .:/tmp-workspace:ro \ -v ./dist:/tmp/sdk/dist:rw \ $IMG_NAME:$IMG_TAG \ - bash -c "source ${SDKROOT}/wasm32-bi-emscripten-shell.sh && ./wasm-build.sh ${WHAT:-\"contrib extra\"}" + bash -c "cp -r /tmp-workspace /workspace && source ${SDKROOT}/wasm32-bi-emscripten-shell.sh && ./wasm-build.sh ${WHAT:-\"contrib extra\"}" From 0377fa8e894535e7e9d39e3eae598e68629ff0eb Mon Sep 17 00:00:00 2001 From: tdrz Date: Mon, 21 Apr 2025 11:25:48 +0200 Subject: [PATCH 2/6] fixes --- wasm-build/build-with-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm-build/build-with-docker.sh b/wasm-build/build-with-docker.sh index 59c111f796f1c..c56a5c079f4c7 100755 --- a/wasm-build/build-with-docker.sh +++ b/wasm-build/build-with-docker.sh @@ -25,4 +25,4 @@ docker run \ -v .:/tmp-workspace:ro \ -v ./dist:/tmp/sdk/dist:rw \ $IMG_NAME:$IMG_TAG \ - bash -c "cp -r /tmp-workspace /workspace && source ${SDKROOT}/wasm32-bi-emscripten-shell.sh && ./wasm-build.sh ${WHAT:-\"contrib extra\"}" + bash -c "cp -r /tmp-workspace/. /workspace && cd /workspace && source ${SDKROOT}/wasm32-bi-emscripten-shell.sh && ./wasm-build.sh ${WHAT:-\"contrib extra\"}" From 85ab61e4569df4ddac0e4b202ba9050cc918eb25 Mon Sep 17 00:00:00 2001 From: tdrz Date: Mon, 21 Apr 2025 11:42:42 +0200 Subject: [PATCH 3/6] remove code optimization flag when building debug variant --- .gitignore | 3 ++- wasm-build.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 278a03ed13ead..236e2672abb45 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,5 @@ lib*.pc /pglite/dist/** /pglite/patches /patches/ -/dist/pglite \ No newline at end of file +/dist/pglite +/dist \ No newline at end of file diff --git a/wasm-build.sh b/wasm-build.sh index 24176b10a7a54..3041e3d037872 100755 --- a/wasm-build.sh +++ b/wasm-build.sh @@ -40,8 +40,8 @@ export PGUSER=${PGUSER:-postgres} if $DEBUG then - export COPTS=${COPTS:-"-O2 -g3"} - export LOPTS=${LOPTS:-"-O2 -g3 --no-wasm-opt -sASSERTIONS=1"} + export COPTS=${COPTS:-"-g3"} + export LOPTS=${LOPTS:-"-g3 --no-wasm-opt -sASSERTIONS=1"} else # DO NOT CHANGE COPTS - optimized wasm corruption fix export COPTS=${COPTS:-"-O2 -g3 --no-wasm-opt"} From 5c98a5f037a7e64c8ca2751573c96f9999ed69d5 Mon Sep 17 00:00:00 2001 From: tdrz Date: Mon, 21 Apr 2025 14:19:43 +0200 Subject: [PATCH 4/6] link dir such that when debugging expected pglite-wasm folder (symlink) points to the right place --- pglite-wasm | 1 + wasm-build.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 120000 pglite-wasm diff --git a/pglite-wasm b/pglite-wasm new file mode 120000 index 0000000000000..e2e295215d816 --- /dev/null +++ b/pglite-wasm @@ -0,0 +1 @@ +./pglite-REL_17_4_WASM \ No newline at end of file diff --git a/wasm-build.sh b/wasm-build.sh index 3041e3d037872..c728455aca027 100755 --- a/wasm-build.sh +++ b/wasm-build.sh @@ -432,7 +432,7 @@ fi # only build extra when targeting pglite-wasm . # TODO link the good tag -ln -s ${WORKSPACE}/pglite-REL_17_4_WASM ${WORKSPACE}/pglite-wasm +ln -s ${WORKSPACE}/pglite-REL_17_4_WASM ${WORKSPACE}/pglite-wasm || true if [ -f ${WORKSPACE}/pglite-wasm/build.sh ] then From 9fee38a7331b69ced6fe2ddc635984210fdd27cc Mon Sep 17 00:00:00 2001 From: tdrz Date: Mon, 21 Apr 2025 14:30:18 +0200 Subject: [PATCH 5/6] add debug doc --- DEBUGGING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 DEBUGGING.md diff --git a/DEBUGGING.md b/DEBUGGING.md new file mode 100644 index 0000000000000..bba190fffb61e --- /dev/null +++ b/DEBUGGING.md @@ -0,0 +1,15 @@ +### Debugging pglite c code + +# Prerequisites + +- Chrome browser +- [C/C++ DevTools Support (DWARF) Chrome extension](https://goo.gle/wasm-debugging-extension). +- Set `DEBUG=true` in `.buildconfig` file. + +Everything needed to build a debug version of `pglite` comes preinstalled in the [docker image](https://hub.docker.com/r/electricsql/pglite-builder). + +# Run the build + +`./build-with-docker.sh` + +This step will create a `pglite.wasm` build that contains the debug information. But since the build was done in docker, you need to adapt the file paths used. Follow [these instructions](https://developer.chrome.com/docs/devtools/wasm#map-path) and specify the mapping `/workspace` -> `your local folder` (e.g. `/workspace` -> `/home/me/pglite/postgres-pglite`). From 9e7d39baae6f2bd1e8c19da3785f86021286ad23 Mon Sep 17 00:00:00 2001 From: tdrz Date: Wed, 23 Apr 2025 18:20:42 +0200 Subject: [PATCH 6/6] moved DEBUGGING doc to pglite project --- DEBUGGING.md | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 DEBUGGING.md diff --git a/DEBUGGING.md b/DEBUGGING.md deleted file mode 100644 index bba190fffb61e..0000000000000 --- a/DEBUGGING.md +++ /dev/null @@ -1,15 +0,0 @@ -### Debugging pglite c code - -# Prerequisites - -- Chrome browser -- [C/C++ DevTools Support (DWARF) Chrome extension](https://goo.gle/wasm-debugging-extension). -- Set `DEBUG=true` in `.buildconfig` file. - -Everything needed to build a debug version of `pglite` comes preinstalled in the [docker image](https://hub.docker.com/r/electricsql/pglite-builder). - -# Run the build - -`./build-with-docker.sh` - -This step will create a `pglite.wasm` build that contains the debug information. But since the build was done in docker, you need to adapt the file paths used. Follow [these instructions](https://developer.chrome.com/docs/devtools/wasm#map-path) and specify the mapping `/workspace` -> `your local folder` (e.g. `/workspace` -> `/home/me/pglite/postgres-pglite`).