Skip to content

Commit c80eed3

Browse files
build: Fix native build for missing symbol
``` $s13JavaScriptKit8JSObjectC2idACs6UInt32V_tcfc: error: undefined reference to 'swjs_get_worker_thread_id_cached' ```
1 parent bad9706 commit c80eed3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Sources/_CJavaScriptKit/_CJavaScriptKit.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#include "_CJavaScriptKit.h"
22
#if __wasm32__
3-
#ifndef __wasi__
4-
#if __has_include("malloc.h")
5-
#include <malloc.h>
6-
#endif
3+
# ifndef __wasi__
4+
# if __has_include("malloc.h")
5+
# include <malloc.h>
6+
# endif
77
extern void *malloc(size_t size);
88
extern void free(void *ptr);
99
extern void *memset (void *, int, size_t);
1010
extern void *memcpy (void *__restrict, const void *__restrict, size_t);
11-
#else
12-
#include <stdlib.h>
13-
#include <stdbool.h>
11+
# else
12+
# include <stdlib.h>
13+
# include <stdbool.h>
1414

15-
#endif
15+
# endif
1616
/// The compatibility runtime library version.
1717
/// Notes: If you change any interface of runtime library, please increment
1818
/// this and `SwiftRuntime.version` in `./Runtime/src/index.ts`.
@@ -34,7 +34,7 @@ void swjs_cleanup_host_function_call(void *argv_buffer) {
3434
// NOTE: This __wasi__ check is a hack for Embedded compatibility (assuming that if __wasi__ is defined, we are not building for Embedded)
3535
// cdecls don't work in Embedded, but @_expose(wasm) can be used with Swift >=6.0
3636
// the previously used `#if __Embedded` did not play well with SwiftPM (defines needed to be on every target up the chain)
37-
#ifdef __wasi__
37+
# ifdef __wasi__
3838
bool _call_host_function_impl(const JavaScriptHostFuncRef host_func_ref,
3939
const RawJSValue *argv, const int argc,
4040
const JavaScriptObjectRef callback_func);
@@ -59,6 +59,8 @@ __attribute__((export_name("swjs_library_features")))
5959
int swjs_library_features(void) {
6060
return _library_features();
6161
}
62+
# endif
63+
#endif
6264

6365
int swjs_get_worker_thread_id_cached(void) {
6466
_Thread_local static int tid = 0;
@@ -67,5 +69,3 @@ int swjs_get_worker_thread_id_cached(void) {
6769
}
6870
return tid;
6971
}
70-
#endif
71-
#endif

0 commit comments

Comments
 (0)