Skip to content

Commit 9c06bbf

Browse files
committed
hacks to get wasi-sockets and WASI dynamic linking working
Signed-off-by: Joel Dice <joel.dice@fermyon.com> enable testing sockets on WASI Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent ebf955d commit 9c06bbf

5 files changed

Lines changed: 18 additions & 22 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,8 @@ def requires_subprocess():
625625
"""Used for subprocess, os.spawn calls, fd inheritance"""
626626
return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
627627

628-
# Emscripten's socket emulation and WASI sockets have limitations.
629-
has_socket_support = not (
630-
is_emscripten
631-
or is_wasi
632-
)
628+
# Emscripten's socket emulation has limitations.
629+
has_socket_support = not is_emscripten
633630

634631
def requires_working_socket(*, module=False):
635632
"""Skip tests or modules that require working sockets

Modules/expat/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
126126
# if ! defined(ULONG_MAX)
127127
# error Compiler did not define ULONG_MAX for us
128-
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
128+
# elif ULONG_MAX == 18446744073709551615u /* 2^64-1 */ || defined (__wasm32__)
129129
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
130130
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
131131
# elif defined(EMSCRIPTEN) // 32bit mode Emscripten

Modules/socketmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\
203203
# define USE_GETHOSTBYNAME_LOCK
204204
#endif
205205

206-
#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__NetBSD__)
206+
#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__NetBSD__) || defined(__wasi__)
207207
# include <sys/ioctl.h>
208208
#endif
209209

configure

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ AC_ARG_ENABLE([wasm-dynamic-linking],
13101310
[
13111311
AS_CASE([$ac_sys_system],
13121312
[Emscripten], [],
1313-
[WASI], [AC_MSG_ERROR([WASI dynamic linking is not implemented yet.])],
1313+
[WASI], [],
13141314
[AC_MSG_ERROR([--enable-wasm-dynamic-linking only applies to Emscripten and WASI])]
13151315
)
13161316
], [
@@ -2388,7 +2388,7 @@ AS_CASE([$ac_sys_system],
23882388
dnl gh-117645: Set the memory size to 40 MiB, the stack size to 16 MiB,
23892389
dnl and move the stack first.
23902390
dnl https://github.com/WebAssembly/wasi-libc/issues/233
2391-
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=16777216 -Wl,--stack-first -Wl,--initial-memory=41943040"])
2391+
dnl AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=16777216 -Wl,--stack-first -Wl,--initial-memory=41943040"])
23922392
]
23932393
)
23942394

@@ -8185,9 +8185,9 @@ PY_STDLIB_MOD([_testclinic_limited], [test "$TEST_MODULES" = yes])
81858185
PY_STDLIB_MOD([_testlimitedcapi], [test "$TEST_MODULES" = yes])
81868186
PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
81878187
PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
8188-
PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
8189-
PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
8190-
PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
8188+
PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = foo])
8189+
PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = foo])
8190+
PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = foo])
81918191
PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes])
81928192
PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes])
81938193
PY_STDLIB_MOD([_ctypes_test],
@@ -8196,8 +8196,8 @@ PY_STDLIB_MOD([_ctypes_test],
81968196

81978197
dnl Limited API template modules.
81988198
dnl Emscripten does not support shared libraries yet.
8199-
PY_STDLIB_MOD([xxlimited], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
8200-
PY_STDLIB_MOD([xxlimited_35], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
8199+
PY_STDLIB_MOD([xxlimited], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = foo])
8200+
PY_STDLIB_MOD([xxlimited_35], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = foo])
82018201

82028202
# substitute multiline block, must come after last PY_STDLIB_MOD()
82038203
AC_SUBST([MODULE_BLOCK])

0 commit comments

Comments
 (0)