Skip to content

build: Fix native build for missing symbol #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
22 changes: 11 additions & 11 deletions Sources/_CJavaScriptKit/_CJavaScriptKit.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include "_CJavaScriptKit.h"
#if __wasm32__
#ifndef __wasi__
#if __has_include("malloc.h")
#include <malloc.h>
#endif
# ifndef __wasi__
# if __has_include("malloc.h")
# include <malloc.h>
# 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 <stdlib.h>
#include <stdbool.h>
# else
# include <stdlib.h>
# include <stdbool.h>

#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`.
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -67,5 +69,3 @@ int swjs_get_worker_thread_id_cached(void) {
}
return tid;
}
#endif
#endif