Skip to content

Commit 8554bf8

Browse files
committed
Review conf_wasm.py: fix ERRNO_CODES, WASI CFLAGS, and dlopen logic.
- _setup_emscripten_flags: add missing ERRNO_CODES to -sEXPORTED_RUNTIME_METHODS, matching configure.ac line 2368. - _setup_wasi_flags: also append -target wasm32-wasi-threads -pthread to CFLAGS (not just CFLAGS_NODIST); the comment explains this is needed so ac_compile/ac_link tests succeed during configure. - setup_wasm_flags: fix ac_cv_func_dlopen logic: use == "no" instead of "is False" so that explicit --enable-wasm-dynamic-linking=no suppresses dlopen (matching configure.ac), and "missing" (no option given) correctly leaves dlopen unprobed. Assisted-by: Claude
1 parent 59de0cf commit 8554bf8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Tools/configure/conf_wasm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def setup_wasm_flags(v):
7474
# Force/suppress ac_cv_func_dlopen for WASM dynamic linking
7575
if v.enable_wasm_dynamic_linking == "yes":
7676
v.ac_cv_func_dlopen = True
77-
elif v.enable_wasm_dynamic_linking is False:
77+
elif v.enable_wasm_dynamic_linking == "no":
7878
v.ac_cv_func_dlopen = False
7979

8080
# Ensure variables exist even on non-WASM builds
@@ -115,7 +115,7 @@ def _setup_emscripten_flags(v):
115115
" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"
116116
)
117117
v.LINKFORSHARED += (
118-
" -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY"
118+
" -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY,ERRNO_CODES"
119119
)
120120
v.LINKFORSHARED += (
121121
" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,"
@@ -173,6 +173,7 @@ def _setup_wasi_flags(v):
173173
# Note: wasi requires --export-memory.
174174
# Note: --export-memory is implicit unless --import-memory is given
175175
# Note: this requires LLVM >= 16.
176+
v.CFLAGS += " -target wasm32-wasi-threads -pthread"
176177
v.CFLAGS_NODIST += " -target wasm32-wasi-threads -pthread"
177178
v.LDFLAGS_NODIST += (
178179
" -target wasm32-wasi-threads -pthread"

Tools/configure/configure.awk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8762,7 +8762,7 @@ function u__setup_emscripten_flags( WASM_LINKFORSHARED_DEBUG) {
87628762
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=20971520"
87638763
V["LDFLAGS_NODIST"] = V["LDFLAGS_NODIST"] " -sWASM_BIGINT"
87648764
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"
8765-
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY"
8765+
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY,ERRNO_CODES"
87668766
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,_PyGILState_GetThisThreadState,__Py_DumpTraceback,__PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET"
87678767
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sSTACK_SIZE=5MB"
87688768
V["LINKFORSHARED"] = V["LINKFORSHARED"] " -sTEXTDECODER=2"
@@ -8790,6 +8790,7 @@ function u__setup_wasi_flags() {
87908790
pyconf_define("_WASI_EMULATED_PROCESS_CLOCKS", 1, 0, "Define to 1 if you want to emulate process clocks on WASI")
87918791
V["LIBS"] = V["LIBS"] " -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks"
87928792
if ((V["enable_wasm_pthreads"] == "yes")) {
8793+
V["CFLAGS"] = V["CFLAGS"] " -target wasm32-wasi-threads -pthread"
87938794
V["CFLAGS_NODIST"] = V["CFLAGS_NODIST"] " -target wasm32-wasi-threads -pthread"
87948795
V["LDFLAGS_NODIST"] = V["LDFLAGS_NODIST"] " -target wasm32-wasi-threads -pthread -Wl,--import-memory -Wl,--export-memory -Wl,--max-memory=10485760"
87958796
}

0 commit comments

Comments
 (0)