Skip to content

Fix compilation of quickjs-libc under emscripten#773

Merged
saghul merged 2 commits intoquickjs-ng:masterfrom
andrjohns:emscripten-qjs-libc
Dec 27, 2024
Merged

Fix compilation of quickjs-libc under emscripten#773
saghul merged 2 commits intoquickjs-ng:masterfrom
andrjohns:emscripten-qjs-libc

Conversation

@andrjohns
Copy link
Copy Markdown
Contributor

The addition of js_once calls to js_os_exec is causing compilation errors under emscripten with:

./quickjs/quickjs-libc.c:3038:8: error: unknown type name 'js_once_t'
 3038 | static js_once_t js_os_exec_once = JS_ONCE_INIT;
      |        ^
./quickjs/quickjs-libc.c:3038:36: error: use of undeclared identifier 'JS_ONCE_INIT'
 3038 | static js_once_t js_os_exec_once = JS_ONCE_INIT;
      |                                    ^
./quickjs/quickjs-libc.c:3168:5: error: call to undeclared function 'js_once'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 3168 |     js_once(&js_os_exec_once, js_os_exec_once_init);
      |     ^

This PR just gates the initialisation behind ifdefs so that it falls back to the non-threaded codepath gracefully.

I've also added quickjs-libc to the emscripten CI so that the changes are tested.

Thanks!

@saghul
Copy link
Copy Markdown
Contributor

saghul commented Dec 27, 2024

Can you use the same guard used in cutils.h ?

@andrjohns
Copy link
Copy Markdown
Contributor Author

Can you use the same guard used in cutils.h ?

Done!

@saghul saghul merged commit 8d88f32 into quickjs-ng:master Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants