Fix compilation of quickjs-libc under emscripten (#773)

This commit is contained in:
Andrew Johnson 2024-12-27 23:37:34 +08:00 committed by GitHub
parent 482291286b
commit 8d88f320fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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) {