Skip to content
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

Add WebAssembly SDK recipe and make-wasm-sdk subcommand #74

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Jan 24, 2024

This patch introduces an experimental WebAssembly SDK recipe and make-wasm-sdk subcommand. The make command takes host Swift toolchain package, target Swift stdlib (lib/swift{,_static}), and WASI sysroot like follows:

$ # Install https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-18-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-18-a-macos_arm64.pkg

$ swift run swift-sdk-generator make-wasm-sdk \
      --target wasm32-unknown-wasi --sdk-name DEVELOPMENT-SNAPSHOT-2024-01-18-a_wasm \
      --host-swift-package-path /Library/Developer/Toolchains/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-18-a.xctoolchain \
      --target-swift-package-path /Library/Developer/Toolchains/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-18-a.xctoolchain \
      --wasi-sysroot /Library/Developer/Toolchains/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-18-a.xctoolchain/usr/share/wasi-sysroot

MaxDesiatov pushed a commit that referenced this pull request Jan 24, 2024
…#75)

Generalized `--{host,target}-swift-package-path` options to be common generator options based on PR feedback #74 (comment)
@MaxDesiatov MaxDesiatov requested a review from euanh January 24, 2024 14:39
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-recipe branch 2 times, most recently from a7e3c24 to c2f764c Compare January 24, 2024 14:40
@kateinoigakukun
Copy link
Member Author

@swift-ci test

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I realize this is hard to test without downloading the actual dependencies on CI. Eventually we should have a way to pass a virtual file system to the generator engine for testing purposes. But for that we need to resolve #76 first.

@kateinoigakukun
Copy link
Member Author

I think it would be worth considering standalone stdlib build support in the generator to avoid such external dependencies in CI :)

@MaxDesiatov
Copy link
Contributor

standalone stdlib build support in the generator

Can you elaborate on what it would mean in this context?

@kateinoigakukun
Copy link
Member Author

I mean if we can build stdlib on sdk-generator CI, we don't need to download stdlib artifacts from third party swiftwasm releases.

@MaxDesiatov
Copy link
Contributor

Yes, that's true. But ideally stdlib builds would be tested in the main Swift repository. Here we only need to verify that files are moved to correct locations, I hope that can be done with a virtual in-memory file system without requiring actual content to be present.

This patch introduces an experimental WebAssembly SDK recipe and `make-wasm-sdk`
subcommand. The make command takes host Swift toolchain package, target
Swift stdlib (`lib/swift{,_static}`), and WASI sysroot like follows:

```console
swift run swift-sdk-generator make-wasm-sdk \
  --target wasm32-unknown-wasi \
  --host-swift-package-path Downloads/swift-DEVELOPMENT-SNAPSHOT-2024-01-12-a \
  --target-swift-package-path Downloads/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-01-12-a \
  --wasi-sysroot Downloads/wasi-sysroot
```
The directory was missed to be taken from target toolchain but it wasn't
revealed on local testing since the host toolchain unintentionally
contained the directory.
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@kateinoigakukun kateinoigakukun merged commit de216d1 into swiftlang:main Jan 25, 2024
2 of 3 checks passed
@kateinoigakukun kateinoigakukun deleted the yt/wasm-recipe branch January 25, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants