diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a99cf3c..2b5006a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -398,7 +398,7 @@ jobs: run: emcc -v - name: build run: | - emcmake cmake -B build + emcmake cmake -B build -DBUILD_QJS_LIBC=ON emmake make -C build qjs_wasm -j$(getconf _NPROCESSORS_ONLN) - name: result run: ls -lh build diff --git a/quickjs-libc.c b/quickjs-libc.c index 6dbe501..a7b334f 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -3035,15 +3035,19 @@ static int my_execvpe(const char *filename, char **argv, char **envp) return -1; } -static js_once_t js_os_exec_once = JS_ONCE_INIT; - static void (*js_os_exec_closefrom)(int); +#if !defined(EMSCRIPTEN) && !defined(__wasi__) + +static js_once_t js_os_exec_once = JS_ONCE_INIT; + static void js_os_exec_once_init(void) { js_os_exec_closefrom = dlsym(RTLD_DEFAULT, "closefrom"); } +#endif + /* exec(args[, options]) -> exitcode */ static JSValue js_os_exec(JSContext *ctx, JSValue this_val, int argc, JSValue *argv) @@ -3163,9 +3167,11 @@ static JSValue js_os_exec(JSContext *ctx, JSValue this_val, } } +#if !defined(EMSCRIPTEN) && !defined(__wasi__) // should happen pre-fork because it calls dlsym() // and that's not an async-signal-safe function js_once(&js_os_exec_once, js_os_exec_once_init); +#endif pid = fork(); if (pid < 0) {