apple / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.53k stars 55 forks source link

Add WASI support #228

Open Kyle-Ye opened 4 months ago

Kyle-Ye commented 4 months ago

Description

Current this build will fail due to some upstream blocked.

Open this issue to track the support for WASI

// ubuntu20 + swiftwasm 5.9.1 https://github.com/swiftwasm/swift
swift test --triple wasm32-unknown-wasi
<unknown>:0: warning: glibc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
/Users/kyle/Github/swift-testing/.build/checkouts/swift-syntax/Sources/SwiftCompilerPlugin/CompilerPlugin.swift:103:19: error: cannot find 'dup' in scope
    let inputFD = dup(fileno(stdin))
                  ^~~
/Users/kyle/Github/swift-testing/.build/checkouts/swift-syntax/Sources/SwiftCompilerPlugin/CompilerPlugin.swift:117:20: error: cannot find 'dup' in scope
    let outputFD = dup(fileno(stdout))
                   ^~~
/Users/kyle/Github/swift-testing/.build/checkouts/swift-syntax/Sources/SwiftCompilerPlugin/CompilerPlugin.swift:124:11: error: cannot find 'dup2' in scope
    guard dup2(fileno(stderr), fileno(stdout)) >= 0 else {

Context

I'm maintaining some library which supports WASI. After converting to swift-testing, the WASI CI is failing. I have to disable it for now.

Priority

Low.

Before we add official WASI support in Swift Project. The priority is low here and I only open the issue for keep tracking the progress.

Kyle-Ye commented 4 months ago

cc @kateinoigakukun in case you are interested for pushing this up.

kateinoigakukun commented 4 months ago

https://github.com/apple/swift-package-manager/pull/7118 will unblock this

grynspan commented 4 months ago

We'd love to support WASI/WASM! Are you able to build to a point where you can see failures in swift-testing yet, or are you blocked by the swift-syntax failures? (Our dependency on swift-syntax is limited to the compiler side of things, so we may be able to hack around the build failures if they cannot reasonably be solved.)

MaxDesiatov commented 4 months ago

The failures are not caused by swift-syntax or the compiler, it's SwiftPM passing a wrong triple to the Swift Syntax build when compiling dependencies of macros. That was fixed in the PR linked above, but we may need to revert that until we resolve remaining issues with how triple arguments are passed for cross-compiled builds.

grynspan commented 4 months ago

Thank you for the additional info, Max. 🙂 I said swift-syntax because the failures were reported against that package. I understand the nature of the failure here, and that the root cause is because SwiftPM is building our macro target and its dependencies for the target platform.

Kyle-Ye commented 4 months ago

The failures are not caused by swift-syntax or the compiler, it's SwiftPM passing a wrong triple to the Swift Syntax build when compiling dependencies of macros. That was fixed in the PR linked above, but we may need to revert that until we resolve remaining issues with how triple arguments are passed for cross-compiled builds.

Thanks for the tip. Would you mind cc me when the issue is eventually fixed to the nightly toolchain as I may not check the PRs on SwiftPM frequently?

grynspan commented 4 months ago

As an administrative thing, I'm going to mark issues asking for new platform support as enhancements rather than bugs. (Carry on!)