mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
0f9f043f7a
Multiple issues fixed here that prevent building Wasm Swift SDK on macOS: 1. After bumping WASI-libc to `wasi-sdk-31` tag, while building `compiler-rt`, `CMAKE_C_COMPILER_TARGET` is not set correctly, and `CMAKE_C_COMPILER_WORKS` should skip failing checks. 2. When building Swift SDKs, passing `SWIFT_WASI_SYSROOT_PATH` excludes `wasm32-unknown-none-wasm` Embedded Swift triple from building, which makes it hard to experiment with Wasm features like components that shouldn't have dependencies on `wasip1` ABI. 3. Now with `wasm32-unknown-none-wasm` triple present, `test/embedded/wasm/classes.swift` can pass, but it needs `test-resource-dir`. rdar://173926794
43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
// RUN: %swift-frontend -c %t/check.swift -parse-as-library -target wasm32-unknown-none-wasm \
|
|
// RUN: -resource-dir %test-resource-dir \
|
|
// RUN: -enable-experimental-feature Embedded -Xcc -fdeclspec -disable-stack-protector \
|
|
// RUN: -o %t/check.o
|
|
// RUN: %clang -target wasm32-unknown-none-wasm %t/check.o %t/rt.c -nostdlib -o %t/check.wasm
|
|
// RUN: %target-run %t/check.wasm
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: CPU=wasm32
|
|
// REQUIRES: embedded_stdlib_cross_compiling
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
//--- rt.c
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
int putchar(int c) { return c; }
|
|
void free(void *ptr) {}
|
|
void *memmove(void *dest, const void *src, size_t n) {
|
|
return __builtin_memmove(dest, src, n);
|
|
}
|
|
|
|
int posix_memalign(void **memptr, size_t alignment, size_t size) {
|
|
uintptr_t mem = __builtin_wasm_memory_grow(0, (size + 0xffff) / 0x10000);
|
|
if (mem == -1) {
|
|
return -1;
|
|
}
|
|
*memptr = (void *)(mem * 0x10000);
|
|
*memptr = (void *)(((uintptr_t)*memptr + alignment - 1) & -alignment);
|
|
return 0;
|
|
}
|
|
|
|
//--- check.swift
|
|
|
|
class Foo {}
|
|
|
|
@_cdecl("_start")
|
|
func main() {
|
|
_ = Foo()
|
|
}
|