Open kateinoigakukun opened 11 months ago
One more task IMO:
generic_wasi_base.h
and update the include logic here to support WASI https://github.com/apple/swift-corelibs-libdispatch/blob/5529d351e304eb2312b7b3bfb073f7d8285473e0/os/object.h#L24-L33Started building stdlib for wasm32-unknown-wasip1-threads
target on main branch: https://github.com/apple/swift/pull/72650
I have a question. Are there still blockers for compiling Swift for the wasm32-unknown-wasip1-threads
target triple?
$ which swiftc
/home/kebo/downloads/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-04-03-a/usr/bin/swiftc
$ swiftc --version
Swift version 6.0-dev (LLVM 3dd3bce1adb5b65, Swift 1f09be97a890c3e)
Target: aarch64-unknown-linux-gnu
$ cat hello.swift
print("hello")
$ swiftc -target wasm32-wasip1-threads -c hello.swift
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasip1-threads'; C stdlib may be unavailable
<unknown>:0: error: could not find module '_Concurrency' for target 'wasm32-unknown-wasip1-threads'; found: wasm32-unknown-wasi, at: /home/kebo/downloads/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-04-03-a/usr/lib/swift/wasi/_Concurrency.swiftmodule
$ uname -a
Linux Brown-rhinoceros-beetle 6.6.3-414.asahi.fc39.aarch64+16k #1 SMP PREEMPT_DYNAMIC Sun Mar 24 19:44:17 UTC 2024 aarch64 GNU/Linux
error: could not find module '_Concurrency' for target 'wasm32-unknown-wasip1-threads'
also happens when using swift build
with the Swift SDK.
I still need some build script engineering 🙃
It's OK for now, thank you.
Tried to fix the issue around atomic.c in libclang_rt.builtin.a, but concluded that it's difficult to fix this with the current toolchain layout of clang, which requires the single builitin library for each arch.
Recently a lot of work on thread support has been done in WASI: https://github.com/WebAssembly/wasi-threads After our toolchain support threading, it will unlock offloading computationally heavy operations to threads.
Here is a list of tasks to support threads in SwiftWasm:
--gc-sections
to unlock wasi-libc upgrade https://github.com/swiftwasm/swift/issues/5128wasm32-unknown-wasi-threads
target tripleThis libcall requires libclang_rt.builtin.a to include atomic.c with atomics and bulk-memory features enabled, but it makes it difficult to share the archive between non-threaded target, so we should fix Swift runtime side.i32.atomic.wait
-> spin lock to work around browser limitation on main threadFeedback and any help are welcome :)