Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-101538: Add experimental wasi-threads build#101537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brettcannon merged 9 commits intopython:mainfromyamt:wasi-threads
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
gh-101538: Add experimental wasi-threads build
eg.```autoconfexport WASI_SDK_PATH=/opt/wasi-sdk-19.5g0236e959edbc./Tools/wasm/wasm_build.py wasi-threads build~/git/toywasm/b.thread/toywasm --wasi --wasi-dir . --wasi-dir ~/git/garbage/py/th2 -- builddir/wasi-threads/python.wasm ~/git/garbage/py/th2/thread.py```* I used an unreleased version of wasi-sdk* I used toywasm to test because wasmtime doesn't have  necessary functionality yet.
  • Loading branch information
@yamt
yamt committedFeb 3, 2023
commit0ef8b6609cfb399343a897cb12e9dbc51889b4fc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Add experimental wasi-threads support. Patch by Takashi Yamamoto.
7 changes: 7 additions & 0 deletionsPython/thread_pthread.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -356,7 +356,14 @@ PyThread_exit_thread(void)
{
if (!initialized)
exit(0);
#if defined(__wasi__)
/*
* wasi-threads doesn't have pthread_exit right now
*/
abort();
#else
pthread_exit(0);
#endif
}

#ifdef USE_SEMAPHORES
Expand Down
2 changes: 2 additions & 0 deletionsTools/wasm/config.site-wasm32-wasi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,3 +40,5 @@ ac_cv_header_netpacket_packet_h=no

# Disable int-conversion for wask-sdk as it triggers an error from version 17.
ac_cv_disable_int_conversion=yes

ac_cv_pthread=yes
8 changes: 7 additions & 1 deletionTools/wasm/wasm_build.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -480,7 +480,6 @@ def configure_cmd(self) -> List[str]:
cmd.append(f"--{opt}-wasm-dynamic-linking")

if self.pthreads is not None:
assert self.host.is_emscripten
opt = "enable" if self.pthreads else "disable"
cmd.append(f"--{opt}-wasm-pthreads")

Expand DownExpand Up@@ -745,6 +744,13 @@ def build_emports(self, force: bool = False):
support_level=SupportLevel.supported,
host=Host.wasm32_wasi,
),
# wasm32-wasi-threads
BuildProfile(
"wasi-threads",
support_level=SupportLevel.experimental,
host=Host.wasm32_wasi,
pthreads=True,
),
# no SDK available yet
# BuildProfile(
# "wasm64-wasi",
Expand Down
15 changes: 14 additions & 1 deletionconfigure.ac
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1053,7 +1053,11 @@ cat > conftest.c <<EOF
# if defined(__EMSCRIPTEN__)
wasm32-emscripten
# elif defined(__wasi__)
# if defined(_REENTRANT)
wasm32-wasi-threads
# else
wasm32-wasi
# endif
# else
# error unknown wasm32 platform
# endif
Expand DownExpand Up@@ -1245,7 +1249,7 @@ AC_ARG_ENABLE([wasm-pthreads],
[
AS_CASE([$ac_sys_system],
[Emscripten], [],
[WASI], [AC_MSG_ERROR([WASI threading is not implemented yet.])],
[WASI], [],
[AC_MSG_ERROR([--enable-wasm-pthreads only applies to Emscripten and WASI])]
)
], [
Expand DownExpand Up@@ -2199,6 +2203,15 @@ AS_CASE([$ac_sys_system],
LIBS="$LIBS -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks"
echo "#define _WASI_EMULATED_SIGNAL 1" >> confdefs.h

AS_VAR_IF([enable_wasm_pthreads], [yes], [
# Note: update CFLAGS because ac_compile/ac_link needs this too
CFLAGS="$CFLAGS -target wasm32-wasi-threads -pthread"
AS_VAR_APPEND([CFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
AS_VAR_APPEND([LDFLAGS_NODIST], [" -target wasm32-wasi-threads -pthread"])
AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--import-memory"])
AS_VAR_APPEND([LDFLAGS_NODIST], [" -Wl,--max-memory=10485760"])
])

dnl increase initial memory and stack size, move stack first
dnl https://github.com/WebAssembly/wasi-libc/issues/233
AS_VAR_APPEND([LDFLAGS_NODIST], [" -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760"])
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp