Skip to content

Commit

Permalink
move ecpg bits to static core
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Jul 15, 2024
1 parent 3350b10 commit 51a5e0e
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cibuild/linkweb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ pushd src
-c -o ../pg_initdb.o ${PGSRC}/src/bin/initdb/initdb.c $NOWARN || exit 34

#
emcc -DPG_LINK_MAIN=1 -DPREFIX=${PGROOT} ${CC_PGLITE} \
emcc -DPG_LINK_MAIN=1 -DPREFIX=${PGROOT} ${CC_PGLITE} -DPG_EC_STATIC \
-I${PGROOT}/include -I${PGROOT}/include/postgresql/server -I${PGROOT}/include/postgresql/internal \
-c -o ./backend/tcop/postgres.o ${PGSRC}/src/backend/tcop/postgres.c $NOWARN|| exit 39

EMCC_CFLAGS="${CC_PGLITE} -DPREFIX=${PGROOT} -DPG_INITDB_MAIN=1 $NOWARN" emmake make backend/main/main.o backend/utils/init/postinit.o || exit 41
EMCC_CFLAGS="${CC_PGLITE} -DPREFIX=${PGROOT} -DPG_INITDB_MAIN=1 $NOWARN" \
emmake make backend/main/main.o backend/utils/init/postinit.o || exit 41
popd


Expand Down Expand Up @@ -80,8 +81,21 @@ then
PG_L="$PG_L -L../../src/interfaces/ecpg/ecpglib ../../src/interfaces/ecpg/ecpglib/libecpg.so /tmp/libduckdb.so -lstdc++"
else
PG_L="$PG_L -L../../src/interfaces/ecpg/ecpglib ../../src/interfaces/ecpg/ecpglib/libecpg.so"
PG_L="../../src/common/libpgcommon_srv.a ../../src/port/libpgport_srv.a ../.././src/interfaces/libpq/libpq.a"

fi

# ../../src/common/libpgcommon_shlib.a"
# ./src/common/libpgcommon.a: binary file matches
# ./src/common/libpgcommon_shlib.a: binary file matches
# error: undefined symbol: fsync_pgdata (referenced by root reference (e.g. compiled C/C++ code))
# error: undefined symbol: get_restricted_token (referenced by root reference (e.g. compiled C/C++ code))
# error: undefined symbol: pg_malloc_extended (referenced by root reference (e.g. compiled C/C++ code))
# error: undefined symbol: pg_realloc (referenced by root reference (e.g. compiled C/C++ code))
# error: undefined symbol: pg_strdup (referenced by root reference (e.g. compiled C/C++ code))
# error: undefined symbol: simple_prompt (referenced by root reference (e.g. compiled C/C++ code))



## \
# /opt/python-wasm-sdk/devices/emsdk/usr/lib/libxml2.a \
Expand Down Expand Up @@ -206,7 +220,7 @@ emcc $EMCC_WEB -fPIC -sMAIN_MODULE=2 \
mkdir -p ${WEBROOT}

cp -v postgres.* ${WEBROOT}/
cp ${PGROOT}/lib/libecpg.so ${WEBROOT}/
#cp ${PGROOT}/lib/libecpg.so ${WEBROOT}/
cp ${PGROOT}/sdk/*.tar ${WEBROOT}/
for tarf in ${WEBROOT}/*.tar
do
Expand Down
57 changes: 57 additions & 0 deletions patches/pg_main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@

#if defined(PG_MAIN)

#if defined(PG_EC_STATIC)
#warning "PG_EC_STATIC"

EMSCRIPTEN_KEEPALIVE void
fsync_pgdata(const char *pg_data, int serverVersion) {
// stub
}

EMSCRIPTEN_KEEPALIVE void
get_restricted_token(void) {
// stub
}

EMSCRIPTEN_KEEPALIVE void *
pg_malloc(size_t size)
{
return malloc(size);
}
EMSCRIPTEN_KEEPALIVE void *
pg_malloc_extended(size_t size, int flags) {
return malloc(size);
}

EMSCRIPTEN_KEEPALIVE void *
pg_realloc(void *ptr, size_t size) {
return realloc(ptr, size);
}

EMSCRIPTEN_KEEPALIVE char *
pg_strdup(const char *in) {
char *tmp;

if (!in)
{
fprintf(stderr,
_("cannot duplicate null pointer (internal error)\n"));
exit(EXIT_FAILURE);
}
tmp = strdup(in);
if (!tmp)
{
fprintf(stderr, _("out of memory\n"));
exit(EXIT_FAILURE);
}
return tmp;
}

EMSCRIPTEN_KEEPALIVE char *
simple_prompt(const char *prompt, bool echo) {
return pg_strdup("");
}



#endif


bool is_node = false;
bool is_repl = true;

Expand Down

0 comments on commit 51a5e0e

Please sign in to comment.