Repository navigation
fix(v13): build PG13 WASM from source in CI - #177
Conversation
PG13's s_lock.h has no TAS for wasm32, so Emscripten stopped at '#error PostgreSQL does not have native spinlock support'. The old patch only added --disable-spinlocks / '#undef HAVE_SPINLOCKS' to configure and extract_source steps that 'make build' never runs. Backport PG14's generic __sync_lock_test_and_set() fallback instead, and drop CI's download of the prebuilt @libpg-query/[email protected] WASM.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No issues found — approved ✅. This PR makes PostgreSQL 13 buildable under Emscripten by backporting the upstream Reviewed commit: 555e166 |
Summary
CI has never built v13. It downloaded the prebuilt
@libpg-query/[email protected]WASM, which has Emscripten's default 64 KiB stack and traps onSELECT 1+1+…with 1000 terms. This PR makes v13 build from source like 14–18 do.Root cause. PG13's
src/postgres/include/storage/s_lock.hhas no test-and-set (TAS) for wasm32, so the build stops at:The old
emscripten_disable_spinlocks.patchonly added--disable-spinlocksand#undef HAVE_SPINLOCKSto libpg_query'sconfigureandextract_sourcesteps.make buildnever runs those steps; it uses thepg_config.halready checked in, which still hasHAVE_SPINLOCKS 1.PG14 added a generic fallback, which is why 14–18 build fine: if nothing else defined
HAS_TEST_AND_SET, it uses__sync_lock_test_and_set()whenHAVE_GCC__SYNC_INT32_TAS/HAVE_GCC__SYNC_CHAR_TASis set. PG13'spg_config.halready defines both of those. This PR's patch backports that block into PG13'ss_lock.h, word for word from PG14.Changes
versions/13/patches/emscripten_disable_spinlocks.patch: the content is replaced with the s_lock.h backport. The filename stays the same, so the template and Makefile need no changes andcopy:templatesproduces no diff..github/workflows/ci.yml: the v13 tarball download is removed; every version now runspnpm run build.Verified locally (Linux, Docker,
cd versions/13 && pnpm run buildfrom an empty.cache, about 35–40 s):pnpm testemscripten/emsdk, what main uses)c568fa4c…d67ac81f444c…8708[email protected](DDL, CTE, window, plpgsql function, GRANT, COPY…).1+1+…chains: 1000 and 5000 terms parse; 20000 terms gives a cleanRangeError(published 13.7.3 behaves the same). The CI prebuilt 13.5.7 traps at 1000 (table index is out of bounds).Conflicts with #173, which edits the same v13 CI step. Whichever merges second just deletes the
if v13branch.Link to Devin session: https://app.devin.ai/sessions/46dadacb8a2045eab1b68b35e90ad8de
Open in Devin Desktop: https://app.devin.ai/desktop/session/46dadacb8a2045eab1b68b35e90ad8de?variant=devin
Requested by: @pyramation