From c80eed35c2f838c7fcc258ccab682f52000ebcb5 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 1 Apr 2025 13:46:53 +0000 Subject: [PATCH 1/2] build: Fix native build for missing symbol ``` $s13JavaScriptKit8JSObjectC2idACs6UInt32V_tcfc: error: undefined reference to 'swjs_get_worker_thread_id_cached' ``` --- Sources/_CJavaScriptKit/_CJavaScriptKit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/_CJavaScriptKit/_CJavaScriptKit.c b/Sources/_CJavaScriptKit/_CJavaScriptKit.c index ed8240ca1..a32881804 100644 --- a/Sources/_CJavaScriptKit/_CJavaScriptKit.c +++ b/Sources/_CJavaScriptKit/_CJavaScriptKit.c @@ -1,18 +1,18 @@ #include "_CJavaScriptKit.h" #if __wasm32__ -#ifndef __wasi__ -#if __has_include("malloc.h") -#include -#endif +# ifndef __wasi__ +# if __has_include("malloc.h") +# include +# endif extern void *malloc(size_t size); extern void free(void *ptr); extern void *memset (void *, int, size_t); extern void *memcpy (void *__restrict, const void *__restrict, size_t); -#else -#include -#include +# else +# include +# include -#endif +# endif /// The compatibility runtime library version. /// Notes: If you change any interface of runtime library, please increment /// this and `SwiftRuntime.version` in `./Runtime/src/index.ts`. @@ -34,7 +34,7 @@ void swjs_cleanup_host_function_call(void *argv_buffer) { // NOTE: This __wasi__ check is a hack for Embedded compatibility (assuming that if __wasi__ is defined, we are not building for Embedded) // cdecls don't work in Embedded, but @_expose(wasm) can be used with Swift >=6.0 // the previously used `#if __Embedded` did not play well with SwiftPM (defines needed to be on every target up the chain) -#ifdef __wasi__ +# ifdef __wasi__ bool _call_host_function_impl(const JavaScriptHostFuncRef host_func_ref, const RawJSValue *argv, const int argc, const JavaScriptObjectRef callback_func); @@ -59,6 +59,8 @@ __attribute__((export_name("swjs_library_features"))) int swjs_library_features(void) { return _library_features(); } +# endif +#endif int swjs_get_worker_thread_id_cached(void) { _Thread_local static int tid = 0; @@ -67,5 +69,3 @@ int swjs_get_worker_thread_id_cached(void) { } return tid; } -#endif -#endif From 4709005e1b82b8112f5e2b5da4e15bbc0467d0ec Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 1 Apr 2025 13:48:29 +0000 Subject: [PATCH 2/2] CI: Ensure that linking works correctly for native targets --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 174b873ef..35405eaf6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,7 +64,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - run: swift build + - run: swift build --package-path ./Examples/Basic env: DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer/