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

wasm lacks signal support #5592

Open
Kyle-Ye opened this issue Sep 22, 2024 · 2 comments
Open

wasm lacks signal support #5592

Kyle-Ye opened this issue Sep 22, 2024 · 2 comments

Comments

@Kyle-Ye
Copy link

Kyle-Ye commented Sep 22, 2024

In file included from /home/runner/work/xx/xx.h:51:
In file included from /opt/hostedtoolcache/swiftwasm/wasm-6.0-SNAPSHOT-2024-09-18-a/x86_64/usr/lib/swift/CoreFoundation/CoreFoundation.h:28:
/opt/hostedtoolcache/swiftwasm/wasm-6.0-SNAPSHOT-2024-09-18-a/x86_64/usr/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
    2 | #error "wasm lacks signal support; to enable minimal signal emulation, \
      |  ^
1 error generated.

I'm dropping support for Swift 5.10 for all supported platform in my package.

Since WASM does not have a corresponding release yet. I'm switching to the latest 6.0 snapshot wasm-6.0-SNAPSHOT-2024-09-18-a toolchain. And I hit with the above error.

Is there some extra param I can use to workaround it like #5563 (comment)?

@Kyle-Ye
Copy link
Author

Kyle-Ye commented Sep 22, 2024

Solved by adding the them to my Package.swift

cSettings: [
...
+ .define("_WASI_EMULATED_SIGNAL", to: "1", .when(platforms: [.wasi]))
],
linkerSettings: [
...
+ .unsafeFlags(["wasi-emulated-signal"], .when(platforms: [.wasi])),
]
),

But then encounter other issue then. (Build and run test fine with normal Linux build)

eg.

# Host OS: Ubuntu 22.04 & swift sdk download the correct WASM SDK
swift build --triple wasm32-unknown-wasi
/toolchain/swift-6.0/usr/lib/swift/CoreFoundation/CoreFoundation.h:16:10: fatal error: 'sys/types.h' file not found
   16 | #include <sys/types.h>
# Host OS: Ubuntu 22.04 & swift sdk download the correct WASM SDK
swift build --swift-sdk 6.0-SNAPSHOT-2024-09-18-a-wasm32-unknown-wasi
warning: Could not read SDKSettings.json for SDK at: /home/kyle/.swiftpm/swift-sdks/swift-wasm-6.0-SNAPSHOT-2024-09-18-a-wasm32-unknown-wasi.artifactbundle/6.0-SNAPSHOT-2024-09-18-a-wasm32-unknown-wasi/wasm32-unknown-wasi/WASI.sdk
Swift version 6.0 (swift-6.0-RELEASE)
Target: wasm32-unknown-wasi
...

<unknown>:0: error: module compiled with Swift 6.0.2 cannot be imported by the Swift 6.0 compiler: xx

I guess I should wait for a final release 6.0 of WASM and test it again.

@Kyle-Ye Kyle-Ye closed this as completed Sep 22, 2024
@Kyle-Ye Kyle-Ye reopened this Nov 10, 2024
@Kyle-Ye
Copy link
Author

Kyle-Ye commented Nov 10, 2024

Still encounter this after I tried the latest 6.0.2 release.

This will happen when I try to include the CoreFoundation header. It used to work on 5.x version.

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

No branches or pull requests

1 participant