Skip to content

Update wasmkit toolchain build to emit universal binary on macOS to fix #82390 #82393

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
merged 1 commit into from
Jun 23, 2025

Conversation

wti
Copy link
Contributor

@wti wti commented Jun 21, 2025

Resolves #82390

(Pedantically...)

Problem: wasmkit binary in toolchain build since 5/15/25 targets host platform only

Solution: build wasmkit for macOS as a universal binary (for x86 and Apple silicon)

Validation: Untested when PR opened; please see later comments

Delivery: also hoist to release/6.2 branch for wasm-capable toolchain builds

Solution details:

  • wasmkit is built using SwiftPM in wasmkit.py
  • run_swift_build() already configures rpath_args per platform and config
  • Generalize rpath_args to platform_args
  • For macOS always inject --arch .. for x86 & arm64

Solution effects:

  • Universal binary created at new path
    • OK?: code already queries path using '--show-bin-path'

Validation:

  • untested locally pending build issues
  • must verify both arm64 and x86 hosts can build universal binaries

Related work:

  • Fix docc build to produce universal binary
  • Post-assembly step to verify that all macOS binaries are universal

…tlang#82390

[platform_args] has platform variants of SwiftPM wasmkit build command:
- unchanged: non-macOS + set_installation_rpath -> rpath config
- added: macOS -> universal binaries using --arch

side effect ok?: binary path changes are captured by '--show-bin-path'
@kateinoigakukun
Copy link
Member

@swift-ci please build toolchain

@kateinoigakukun
Copy link
Member

I verified the built toolchain now contains a universal binary with x86_64 and arm64.

@kateinoigakukun
Copy link
Member

@swift-ci please smoke test

@kateinoigakukun kateinoigakukun merged commit 9488df1 into swiftlang:main Jun 23, 2025
6 checks passed
@MaxDesiatov
Copy link
Contributor

@wti would you mind adding a test for this in https://github.com/swiftlang/swift-integration-tests?

@wti
Copy link
Contributor Author

wti commented Jun 23, 2025

@MaxDesiatov I'm investigating integration tests

@wti
Copy link
Contributor Author

wti commented Jun 23, 2025

@MaxDesiatov Please see PR swiftlang/swift-integration-tests#163

MaxDesiatov pushed a commit that referenced this pull request Jun 26, 2025
…#82390 (#82406)

- **Explanation**: Build wasmkit, a new toolchain executable, as universal binary on macOS using SwiftPM --arch flags. (Cherry picked from commit 6530236)
- **Scope**: WasmKit is new, and users targeting Wasm (and preferring WasmKit over other Wasm runtimes) might be few. WasmKit can be invoked directly by users and indirectly via `swift run` when using the official Swift SDKs for Wasm.
- **Issues**: Resolves #82390
- **Original PRs**:  #82393
- **Risk**: The new configuration only affects macOS targets. The binary is output to a new location, but the code already introspects the location correctly. The bug and fix impacts users of WasmKit binary newly added to toolchain, directly and via `swift run`. Risk of no-fix: The Swift.org wasm "Getting Started" [1] refers explicitly to this (unreleased) 6.2 toolchain WasmKit binary. Without this fix, users on Apple Silicon following those instructions get an obscure "bad CPU" error because it is built only for the host x86_64 arch.
- **Testing**: @kateinoigakukun verified WasmKit is universal after change in `main`. To verify, run shell `file usr/bin/wasmkit` and verify outputs include x86_64 and arm64 arch. An outstanding question is whether to add a check that toolchain executables are universal binaries on macOS. Currently they are, except for `docc`.
- **Reviewers**: @kateinoigakukun 

[1] https://www.swift.org/documentation/articles/wasm-getting-started.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wasmkit in 6.2 toolchain is not universal on macOS
3 participants