Skip to content

fix: Fix compiler error found on latest main that breaks wasip1 (wasm) compilation #3271

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 24, 2025

Conversation

scottmarchant
Copy link
Contributor

@scottmarchant scottmarchant commented Jun 20, 2025

This is a quick simple fix for compiling NIOCore to wasm using the command swift build --swift-sdk wasm32-unknown-wasip1-threads --target NIOCore.

This fixes all errors for wasip1, however there are other errors remaining in main when compiling for wasi using the command swift build --swift-sdk wasm32-unknown-wasi --target NIOCore. Those issues are out of scope for this PR.

Motivation:

I am working to enable wasm compilation for a wide range of repositories which depend on NIOCore. See here for a sneak peak. This change is required to enable compiling several respositories.

Modifications:

.multicastNotSupported is elided for os(WASI) builds in Channel.swift, however some new code referenced that case without proper WASI guards.

This modification simply adds the appropriate elision guard to fix wasip1 builds for NIOCore.

Result:

After making this change, swift build --swift-sdk wasm32-unknown-wasip1-threads --target NIOCore builds again (assuming you have the appropriate wasm sdk installed).

…OCore. This fixes the build command `swift build --swift-sdk wasm32-unknown-wasip1-threads --target NIOCore`. The build command `swift build --swift-sdk wasm32-unknown-wasi --target NIOCore` still fails due to other issues.
Copy link
Contributor

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

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

Thanks!

@scottmarchant
Copy link
Contributor Author

@gjcairo Thanks for the review! Do you know what the process looks like to get this MR merged? I think a handful of other wasm-related efforts such as #3159 might become blocked waiting for this fix.

@Lukasa Lukasa enabled auto-merge (squash) June 24, 2025 09:28
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Jun 24, 2025
@Lukasa Lukasa merged commit 15dfe08 into apple:main Jun 24, 2025
40 of 42 checks passed
@scottmarchant scottmarchant deleted the fix/fix-niocore-build-for-wasip1 branch June 24, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants