From c21f4a96db19b088f3aa41d2a751cc90e52aa8d0 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Wed, 22 Jul 2026 14:47:26 +0000 Subject: [PATCH] wasm: force TCL select() notifier (Emscripten has no working epoll) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TCL 9.1's configure defines NOTIFIER_EPOLL whenever is present (unix/configure.ac:342). Emscripten's sysroot ships that header and the epoll_* symbols, so TCL picked the epoll notifier — but epoll does not work under WASM at runtime and the event loop hangs. Hide the header/functions from TCL's configure via autoconf cache vars (ac_cv_header_sys_epoll_h=no + epoll_create/epoll_create1=no) so the select()-based notifier is selected instead. Verified with emsdk 6.0.3: NOTIFIER_EPOLL is absent from DEFS, the tclEpollNotfy.o/tclKqueueNotfy.o objects are empty stubs (333 B) and tclSelectNotfy.o is the live notifier (~9.9 KB); the tcl WASM variant links (magic.js + magic.wasm) via npm/build.sh out-of-source. Co-Authored-By: Claude Opus 4.8 (1M context) --- toolchains/emscripten/build-tcl-wasm.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/toolchains/emscripten/build-tcl-wasm.sh b/toolchains/emscripten/build-tcl-wasm.sh index b93617df..6306f8c6 100644 --- a/toolchains/emscripten/build-tcl-wasm.sh +++ b/toolchains/emscripten/build-tcl-wasm.sh @@ -107,7 +107,15 @@ cd "$OUT" # patching the read-only TCL source tree. if [ ! -f Makefile ]; then echo "=== emconfigure ===" + # Force the select()-based notifier: Emscripten exposes and the + # epoll_* symbols in its sysroot, so TCL's configure would pick the epoll + # notifier — but epoll does not work under WASM at runtime and the event loop + # hangs. Hide the header/functions from configure (autoconf cache vars) so + # TCL falls back to select(), which Emscripten does support. CFLAGS="-O2 -sUSE_ZLIB=1" \ + ac_cv_header_sys_epoll_h=no \ + ac_cv_func_epoll_create=no \ + ac_cv_func_epoll_create1=no \ emconfigure "$TCL_SRC/unix/configure" \ --disable-shared \ --disable-load \