error: link command failed with exit code 1 (use -v to see invocation)
wasm-ld: error: cannot open crt1.o: No such file or directory
wasm-ld: error: unable to find library -lc
wasm-ld: error: cannot open /Users/user/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a.xctoolchain/usr/lib/clang/17/lib/wasm32-unknown-none-wasm/libclang_rt.builtins.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So for some reason builder adds to the linker command this parameters:
The toolchain itself does not include compiler-rt for Wasm, but it's included in the Swift SDK for Wasm instead.
I recommend to use swift-<version>_wasm-embedded variant Swift.org - Getting Started with Swift SDKs for WebAssembly
If you really don't want to use Swift SDK, you can pass linkerSettings: [.unsafeFlags(["-Xclang-linker", "-nodefaultlibs"]), but note that you will lose a lot of functionalities.
No, you don't need to specify any of those options with the Embedded Swift SDK. --swift-sdk is enough, -c release may be still required with 6.2 snapshots, but not with main snapshots where debug builds are now possible.
Thus with the main snapshots of the toolchain, this is the whole command for debug build:
swift build --swift-sdk swift-DEVELOPMENT-SNAPSHOT-2025-06-17-a_wasm-embedded
and nothing else is needed, unless you build a specific product with --product.
This is not something I would recommend at this point, as WASI-libc provides you an allocator, RNG, basic I/O facilities, and much more, most importantly compatibility with many existing libraries and packages. The binary size is still quite small (10 kB for print("Hello, World!")), and you get a stable imports ABI that almost all Wasm runtimes support or have shims for.
Yes, but it still doesn't work on the NEAR blockchain. I compile the WebAssembly (WASM) file, stub the WASI imports, and disable all WASM features, but I still encounter errors when calling the function on-chain. So far, I've only had success with WASM files compiled using the wasm32-unknown-unknown target. Every language that supports this target allows me to upload the code to the blockchain and call functions. However, with languages that use the wasm32-unknown-wasi target, I haven’t been able to get it working for some reason.
vlmoon99/near-sdk-swift: Experimental Near SDK for Swift lang
I built and deployed it on the chain, and it works well. I believe this can be very useful in the future for developers who want to write smart contracts in Swift and communicate with the blockchain using Swift and WebAssembly. Thanks to everyone who made this possible!