Skip to content

[wasm][build] Build stdlib and test IRGen for WebAssembly #69101

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

Merged

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Oct 10, 2023

This patch adds new build products to build and test the Swift stdlib for WebAssembly.
This adds WebAssembly specific stdlib product instead of adding the new target in stdlib-deployment-targets because unlike darwin platforms Wasm target has quite different stdlib configuration from host target and there is no way to specify different stdlib configuration for each target in stdlib-deployment-targets for now.

This patch adds 1 new dependency wasi-libc and 3 new build products:

  1. WASILibc - wasi-libc is a libc implementation for WebAssembly System Interface (WASI). This product is required to build the compiler runtimes and Swift stdlib.
  2. WasmLLVMRuntimeLibs - This product builds ./runtimes directory in llvm-project, which contains compiler-rt, libcxx and libcxxabi. This product is required to build Swift stdlib.
  3. WasmStdlib - This product builds standalone Swift stdlib for WebAssembly. (Similar to MinimalStdlib product, but configured for WebAssembly target)

Currently WasmStdlib runs test suite under test/IRGen to verify the semi-target specific code in IRGen works and the generated IR can be processed by LLVM WebAssembly backend. Rest of test suites including executable tests are now skipped, but will be enabled after we set up a Wasm runtime in the CI infrastructure and calling convention mismatch issues will be resolved.

Resolves rdar://116007434 and rdar://116523979.

@MaxDesiatov MaxDesiatov requested a review from al45tair October 10, 2023 18:16
@kateinoigakukun kateinoigakukun added build-script Area → utils: The build script WebAssembly Platform: WebAssembly labels Oct 10, 2023
@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from b8630f1 to e8a8f14 Compare October 10, 2023 18:49
@kateinoigakukun kateinoigakukun changed the title [wasm][build] Build and test stdlib for WebAssembly [wasm][build] Build stdlib and test IRGen for WebAssembly Oct 14, 2023
@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

@kateinoigakukun
Copy link
Member Author

preset= buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from e8a8f14 to 2625f83 Compare October 17, 2023 19:34
@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun
Copy link
Member Author

The stdlib compilation crash will be resolved after rebranch will be merged

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from 2625f83 to 6b391e4 Compare October 18, 2023 03:41
@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented Oct 18, 2023

I confirmed it passes with the llvm fix included in the rebranch #69239
Now ready for review!

@kateinoigakukun kateinoigakukun marked this pull request as ready for review October 18, 2023 05:37
@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from 6b391e4 to f8c8dd9 Compare October 23, 2023 16:56
@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch 2 times, most recently from caa9bf1 to b022941 Compare October 23, 2023 17:04
@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

This patch adds a new build products to build and test the Swift stdlib
for WebAssembly.
This adds WebAssembly specific stdlib product instead of adding the new
target in `stdlib-deployment-targets` because unlike darwin platforms
Wasm target has quite different stdlib configuration from host target
and there is no way to specify different stdlib configuration for each
target in `stdlib-deployment-targets` for now.

This patch adds 1 new dependency `wasi-libc` and 3 new build products:
1. `WASILibc` - wasi-libc is a libc implementation for WebAssembly
   System Interface (WASI). This product is required to build the
   compiler runtimes and Swift stdlib.
2. `WasmLLVMRuntimeLibs` - This product builds `./runtimes` directory
   in llvm-project, which contains compiler-rt, libcxx and libcxxabi.
   This product is required to build Swift stdlib.
3. `WasmStdlib` - This product builds standalone Swift stdlib for
   WebAssembly. (Similar to `MinimalStdlib` product, but configured for
   WebAssembly target)
@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from b022941 to 641e753 Compare October 23, 2023 18:52
@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from 641e753 to f3455d8 Compare October 23, 2023 22:46
@kateinoigakukun kateinoigakukun requested a review from a team as a code owner October 23, 2023 22:46
@kateinoigakukun
Copy link
Member Author

Added a few test fix commits that are found after rebranch 🩹

@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

stable/20230725 now rejects including builtin headers in modulemap by
default to avoid module cycles on non-Apple platforms. Builtin headers
are now part of their own `_Builtin_XXX` modules.

See:
- swiftlang/llvm-project#7618
- https://reviews.llvm.org/D159483
- https://reviews.llvm.org/D159064
@kateinoigakukun kateinoigakukun force-pushed the yt/wasm-stdlib-product-pr branch from f3455d8 to 977b74a Compare October 24, 2023 00:07
@kateinoigakukun
Copy link
Member Author

preset=buildbot_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke 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.

🤩 Super excited to see this, thank you!

@kateinoigakukun kateinoigakukun merged commit 1e5f69b into swiftlang:main Oct 25, 2023
@kateinoigakukun kateinoigakukun deleted the yt/wasm-stdlib-product-pr branch October 25, 2023 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-script Area → utils: The build script WebAssembly Platform: WebAssembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants