Skip to content

Commit 3e8874a

Browse files
committed
restore stock wasm
1 parent 383cbeb commit 3e8874a

File tree

6 files changed

+289
-75
lines changed

6 files changed

+289
-75
lines changed

src/Makefile.shlib

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -224,33 +224,6 @@ ifeq ($(SHLIB_EXPORTS),)
224224
override CXXFLAGS += $(CXXFLAGS_SL_MODULE)
225225
endif
226226

227-
ifeq ($(PORTNAME), emscripten)
228-
LINK.shared = emsdk-shared
229-
ifdef soname
230-
# emscripten uses unversioned shared libraries
231-
shlib = $(shlib_bare)
232-
soname = $(shlib_bare)
233-
endif
234-
BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
235-
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
236-
# ifneq (,$(exports_file))
237-
# LINK.shared += -Wl,--version-script=$(exports_file)
238-
# endif
239-
endif
240-
241-
ifeq ($(PORTNAME), wasi)
242-
LINK.shared = wasi-shared
243-
ifdef soname
244-
# emscripten uses unversioned shared libraries
245-
shlib = $(shlib_bare)
246-
soname = $(shlib_bare)
247-
endif
248-
BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
249-
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
250-
# ifneq (,$(exports_file))
251-
# LINK.shared += -Wl,--version-script=$(exports_file)
252-
# endif
253-
endif
254227

255228
##
256229
## BUILD
@@ -266,11 +239,8 @@ all-lib: lib$(NAME).pc
266239
endif
267240

268241
all-static-lib: $(stlib)
269-
ifdef wasi
270-
all-shared-lib: all-static-lib
271-
else
242+
272243
all-shared-lib: $(shlib)
273-
endif
274244

275245
# In this rule, "touch $@" works around a problem on some platforms wherein
276246
# ar updates the library file's mod time with a value calculated to

src/backend/libpq/pqcomm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ PDEBUG("# 285:" __FILE__);
320320
AddWaitEventToSet(FeBeWaitSet, WL_POSTMASTER_DEATH, PGINVALID_SOCKET,
321321
NULL, NULL);
322322
#else /* WASM */
323-
PDEBUG("# 323: FIXME: socketfile");
324-
#pragma message "FIXME: use socketfile when overflowing PqRecvBuffer_static"
323+
PDEBUG("# 220: FIXME: socketfile");
324+
#pragma message "FIXME: socketfile"
325325
/* because we fill before starting reading message */
326326
PqRecvBuffer = &PqRecvBuffer_static[0];
327327
#endif /* WASM */
@@ -1150,14 +1150,14 @@ pq_buffer_remaining_data(void)
11501150
* This must be called before any of the pq_get* functions.
11511151
* --------------------------------
11521152
*/
1153-
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
1153+
#if defined(I_EMSCRIPTEN) || defined(I_WASI)
11541154
EMSCRIPTEN_KEEPALIVE void
11551155
pq_recvbuf_fill(FILE* fp, int packetlen) {
11561156
fread( PqRecvBuffer, packetlen, 1, fp);
11571157
PqRecvPointer = 0;
11581158
PqRecvLength = packetlen;
11591159
#if PDEBUG
1160-
printf("# 1160: pq_recvbuf_fill cma_rsize=%d PqRecvLength=%d buf=%p reply=%p\n", cma_rsize, PqRecvLength, &PqRecvBuffer[0], &PqSendBuffer[0]);
1160+
printf("# 1199: pq_recvbuf_fill cma_rsize=%d PqRecvLength=%d buf=%p reply=%p\n", cma_rsize, PqRecvLength, &PqRecvBuffer[0], &PqSendBuffer[0]);
11611161
#endif
11621162

11631163
}
@@ -1175,7 +1175,7 @@ pq_startmsgread(void)
11751175
ereport(FATAL,
11761176
(errcode(ERRCODE_PROTOCOL_VIOLATION),
11771177
errmsg("terminating connection because protocol synchronization was lost")));
1178-
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
1178+
#if defined(I_EMSCRIPTEN) || defined(I_WASI)
11791179
if (!pq_buffer_remaining_data()) {
11801180
if (cma_rsize) {
11811181
PqRecvPointer = 0;
@@ -1326,7 +1326,7 @@ extern int SOCKET_DATA;
13261326
static int
13271327
internal_putbytes(const char *s, size_t len) {
13281328
if (PqSendPointer >= PqSendBufferSize) {
1329-
fprintf(stderr, "# 1329: overflow %zu >= %d cma_rsize=%d CMA=%d\n", PqSendPointer, PqSendBufferSize,cma_rsize, CMA_MB);
1329+
fprintf(stderr, "# 1329: overflow %d >= %d cma_rsize=%d CMA=%d\n", PqSendPointer, PqSendBufferSize,cma_rsize, CMA_MB);
13301330
}
13311331

13321332
if (!cma_rsize) {

src/backend/utils/error/elog.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,8 @@ errfinish(const char *filename, int lineno, const char *funcname)
543543
*/
544544

545545
recursion_depth--;
546-
#if defined(__wasi__)
547-
fprintf(stderr, "# 547: PG_RE_THROW(ERROR : %d) custom handling\n", recursion_depth);
548-
EmitErrorReport();
549-
FreeErrorDataContents(edata);
550-
errordata_stack_depth--;
551-
MemoryContextSwitchTo(oldcontext);
552-
recursion_depth--;
553-
abort();
554-
#else
555546
fprintf(stderr, "# 549: PG_RE_THROW(ERROR : %d)\n", recursion_depth);
556547
PG_RE_THROW();
557-
#endif
558548
}
559549

560550
/* Emit the message to the right places */
@@ -603,7 +593,7 @@ errfinish(const char *filename, int lineno, const char *funcname)
603593
* worthy of panic, depending on which subprocess returns it.
604594
*/
605595
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
606-
PDEBUG("# 601: proc_exit(FATAL) ignored");
596+
puts("# 599: proc_exit(FATAL) ignored");
607597
#else
608598
proc_exit(1);
609599
#endif
@@ -2020,13 +2010,6 @@ ReThrowError(ErrorData *edata)
20202010
void
20212011
pg_re_throw(void)
20222012
{
2023-
#if defined(__wasi__)
2024-
if (PG_exception_stack != NULL)
2025-
PDEBUG("# 2020: pg_re_throw(void) [ ex stack ! ]");
2026-
else
2027-
PDEBUG("# 2022: pg_re_throw(void) [ NO STACK ]");
2028-
return;
2029-
#endif
20302013
/* If possible, throw the error to the next outer setjmp handler */
20312014
if (PG_exception_stack != NULL)
20322015
siglongjmp(*PG_exception_stack, 1);

src/include/port/emscripten.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/* src/include/port/{wasi/emscripten}.h */
1+
/* src/include/port/emscripten.h */
22

3-
#ifndef I_WASM
4-
#define I_WASM
3+
#ifndef I_EMSCRIPTEN
4+
#define I_EMSCRIPTEN
55

66
#if !defined(__cplusplus)
7-
#include <sdk_port.h>
7+
#include <emscripten.h>
88
#endif
99

1010
#include "/tmp/pglite/include/wasm_common.h"
@@ -14,4 +14,4 @@
1414
#define FD_BUFFER_MAX 16384
1515

1616

17-
#endif // I_WASM
17+
#endif // I_EMSCRIPTEN

0 commit comments

Comments
 (0)