-
Notifications
You must be signed in to change notification settings - Fork 112
Add support for WASILibc
module
#159
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
Conversation
This mostly amounted to excluding unsupported errnos, adding TLS dictionary storage shim for single-threaded environment, and adding constants in C headers for macros that Clang importer currently doesn't support.
@swift-ci test |
Adding CI jobs for WASI is currently blocked by swiftlang/swift#72728. |
@swift-ci test |
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally tested and it works well 👍
$ cat Sources/main.swift
import SystemPackage
let message: String = "Hello, world!" + "\n"
let path: FilePath = "/tmp/log"
let fd = try FileDescriptor.open(
path, .writeOnly, options: [.append, .create], permissions: .ownerReadWrite)
try fd.closeAfter {
_ = try fd.writeAll(message.utf8)
}
$ swift build --experimental-swift-sdk DEVELOPMENT-SNAPSHOT-2024-04-25-a-wasm32-unknown-wasi
$ wasmtime --dir /tmp .build/debug/Example.wasm
$ cat /tmp/log
Hello, world!
Co-authored-by: Guillaume Lessard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do we have multi-threaded wasi support on swift/main?
@swift-ci please test |
@glessard Yes, we have multi-threaded wasi target as a separate triple (wasm32-unknown-wasip1-threads) from the non-threaded one (wasm32-unknown-wasi) |
Yes, but that requires a special Swift SDK to be installed from artifacts built by the SwiftWasm org. There's ongoing work to build that on Swift CI directly in swiftlang/swift#72728. |
Quoting the [wasi.dev landing page](https://wasi.dev): > The WebAssembly System Interface (WASI) is a group of standard API specifications for software compiled to the W3C WebAssembly (Wasm) standard. WASI is designed to provide a secure standard interface for applications that can be compiled to Wasm from any language, and that may run anywhere—from browsers to clouds to embedded devices. Currently support for WASI in Swift is based on [`wasi-libc`](https://github.com/WebAssembly/wasi-libc). Adding support for `wasi-libc` mostly amounted to excluding unsupported errnos, adding TLS dictionary storage shim for single-threaded environment, and adding constants in C headers for macros that Clang importer currently doesn't support. Co-authored-by: Guillaume Lessard <[email protected]> # Conflicts: # Sources/System/FileOperations.swift # Sources/System/Internals/Syscalls.swift
Quoting the wasi.dev landing page:
Currently support for WASI in Swift is based on
wasi-libc
.Adding support for
wasi-libc
mostly amounted to excluding unsupported errnos, adding TLS dictionary storage shim for single-threaded environment, and adding constants in C headers for macros that Clang importer currently doesn't support.