fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.22k stars 247 forks source link

Spin build, for swiftwasm, uses 'swiftc' instead of 'swift build' #2888

Open k0pernicus opened 1 week ago

k0pernicus commented 1 week ago

Only for spin with Swift (swiftwasm):

Reproduction:

> spin new swiftwasm_test # uses http-swift
> cd swiftwasm_test
> spin build
Building component swiftwasm-test with `swiftc -target wasm32-unknown-wasi main.swift -o main.wasm`
error: missing external dependency '/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a.xctoolchain/usr/lib/swift/wasi/static-executable-args.lnk'
Error: Build command for component swiftwasm-test failed with status Exited(1)

I checked quickly on the Swiftwasm book, and found out that swiftc should not be used to build a WASM component / binary:

You may encounter this error while building with Swift SDK for WebAssembly and swiftc driver command. Unfortunately, Swift SDK does not support building with swiftc command yet, so you need to use swift build Swift Package Manager command instead. Source: https://book.swiftwasm.org/getting-started/troubleshooting.html

So, swift build should be used here instead of swiftc.


Version: spin 2.7.0 (a111517 2024-07-30) Plugins:

lann commented 1 week ago

Hi @k0pernicus, thanks for the report. We are currently planning to drop support for Swift with Spin 3.0 because of limitations in the Swift toolchain that the 2.7 template is based on.

We'd be very happy to reintroduce/keep support if a newer Swift SDK can be made to work with Spin 3.0 (i.e. the main branch, currently). I wasn't able to get it to work but I have practically zero experience with Swift so it may be possible for someone to do so already.

k0pernicus commented 1 week ago

Thank you for your response. I could take a look as I got more and more into Swift "these days", but I can't promise anything. I will try to look at this in the upcoming weeks.