mirror of
https://github.com/apple/swift.git
synced 2026-11-20 05:27:31 +01:00
Enable the Embedded Swift and stdlib lit tests to run on `wasm32-unknown-emscripten`. Embedded Swift linker RUN lines move off the hard-coded `%target-clang` onto a `%target-embedded-link` substitution that links through `emcc` on Emscripten and keeps `%target-clang` for other platforms elsewhere. The `REQUIRES`/`UNSUPPORTED` gates gain an `OS=emscripten` arm, so emscripten runs the `wasip1` tests it shares and skips the ones it cannot satisfy yet. Also renamed `wasilibc_functions.swift` to `libc_functions.swift` and updated `docs/WebAssembly.md`.
26 lines
557 B
Swift
26 lines
557 B
Swift
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo) | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: OS=wasip1 || OS=emscripten
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
#if canImport(WASILibc)
|
|
import WASILibc
|
|
#elseif canImport(EmscriptenLibc)
|
|
import EmscriptenLibc
|
|
#else
|
|
#error("Unsupported libc")
|
|
#endif
|
|
|
|
@main struct Main {
|
|
static func main() {
|
|
puts("Hello")
|
|
// CHECK: Hello
|
|
let div_result = div(5,2)
|
|
print(div_result.quot)
|
|
// CHECK: 2
|
|
print(div_result.rem)
|
|
// CHECK: 1
|
|
}
|
|
}
|