Open
Conversation
Contributor
Author
|
This runs but basically doesn't do anything, a lot to debug here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #65
Summary
postgres) andinitdbtowasm32-wasiusing a two-pass build strategy (native pass for flex/bison/Perl codegen, then WASM cross-compile)make postgres/make install-postgrestargets to the top-levelMakefilepostgres.wasm → postgres.cwasm(andinitdb.wasm → initdb.cwasmwheninitdblinks successfully)Notable / Weird Build Workarounds
.ofiles while preserving the generated sources and re-configure for WASM in Pass 2.config.cache.wasi): Cross-compileconfigurecan't run test programs, so we pre-populate a cache with type sizes, alignments, spinlock support, and function availability for thewasm32ILP32 target.Makefile.shlibpatched to disable shared libraries:wasm-ldcannot build.sofiles (no--version-script,--sharedincompatible with--export-memory, missingcrt1-reactor.o). We comment out theall-shared-libdependency so only staticlibpq.ais produced.libpq/Makefilepatched:libpq-refs-stampnormally depends on the shared lib and runs a Perl symbol check. We remove that dependency since there’s no.soto check.pg_config.hpatched post-configure: Force-disableEXEC_BACKEND(nofork), all semaphore types (stubbed), and ensureHAVE_SPINLOCKSis set (GCC atomic builtins work on WASM).main.c: Lind sandbox’sgeteuid()returns 0, but the security concern does not apply inside the sandbox.wasm_compat.hforce-included: Maps oldst_atime/st_mtime/st_ctimestat field names to WASI’sst_atim.tv_sec/st_mtim.tv_sec/st_ctim.tv_sec.wasi_stubs.c: Stubs_Unwind_Backtrace,_Unwind_GetIP,_Unwind_GetGR,_Unwind_GetCFA. These are pulled in by glibc’sbacktrace.o, but WASI has no stack unwinder.initdblink flags manually specified: The compile script overridesLIBSon themakecommand line (to injectwasi_stubs.o -lm), which wipes out-lpgcommon -lpgportthatconfigurenormally adds. We re-add them along with explicit-Lpaths since theLDFLAGSoverride also dropsLDFLAGS_INTERNAL.--max-memory: PostgreSQL allocates shared buffers even in single-user mode and needs more than the default.libpq,fe_utils, andinitdbbuilds all tolerate errors and continue.New Files
postgres/compile_postgres.sh— main build orchestrator (527 lines)postgres/wasi_stubs.c—_Unwind_*no-op stubspostgres/wasm_compat.h— stat field name compatibility macrosTest Plan
make postgrescompletes and producespostgres.cwasminbuild/bin/postgres/wasm32-wasi/initdb.cwasmis also produced (or at least link errors are diagnosed and documented)lind-bootcan load and start thepostgresbinary in single-user mode