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

CI: Update Swift SDK for Wasm to 2024-10-15-a #160

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ jobs:
# Swift 5.8.1
- os: macos-13
xcode: Xcode_14.3.1
development-toolchain-tag: swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-tag: swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
test-args: ""
# Swift 5.9.0
- os: macos-13
xcode: Xcode_15.0.1
development-toolchain-tag: swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-tag: swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
test-args: "--sanitize address"

runs-on: ${{ matrix.os }}
Expand All @@ -41,7 +43,7 @@ jobs:
curl -L "$development_toolchain_download" -o $pkg
sudo installer -pkg $pkg -target /
echo "toolchain-path=$toolchain_path" >> $GITHUB_OUTPUT
"$toolchain_path/usr/bin/swift" sdk install "${{ matrix.wasi-swift-sdk-download }}"
"$toolchain_path/usr/bin/swift" sdk install "${{ matrix.wasi-swift-sdk-download }}" --checksum "${{ matrix.wasi-swift-sdk-checksum }}"
wasi_sdk_path=$("$toolchain_path/usr/bin/swift" sdk configure --show-configuration "${{ matrix.wasi-swift-sdk-id }}" wasm32-unknown-wasi | grep sdkRootPath: | cut -d: -f2)
echo "wasi-swift-sdk-path=$(dirname $wasi_sdk_path)" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -75,27 +77,32 @@ jobs:
matrix:
include:
- swift: "swift:5.8-focal"
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
- swift: "swift:5.9-focal"
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
- swift: "swift:5.9-amazonlinux2"
development-toolchain-download: "https://download.swift.org/development/amazonlinux2/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a-amazonlinux2.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-download: "https://download.swift.org/development/amazonlinux2/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-amazonlinux2.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
- swift: "swift:6.0-focal"
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-download: "https://download.swift.org/development/ubuntu2004/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubuntu20.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"
test-args: "--enable-code-coverage"
build-dev-dashboard: true
- swift: "swiftlang/swift:nightly-main-jammy"
development-toolchain-download: "https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-07-08-a-ubuntu22.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasi
development-toolchain-download: "https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubuntu22.04.tar.gz"
wasi-swift-sdk-download: "https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi.artifactbundle.zip"
wasi-swift-sdk-id: DEVELOPMENT-SNAPSHOT-2024-10-15-a-wasm32-unknown-wasi
wasi-swift-sdk-checksum: "229cd9d3b0ed582c7ef7c3064888ad78764e4743b5a770df92554a94513f53fb"

runs-on: ubuntu-20.04
name: "build-linux (${{ matrix.swift }})"
Expand All @@ -115,7 +122,7 @@ jobs:
./build-exec mkdir -p "$toolchain_path"
curl -L ${{ matrix.development-toolchain-download }} | ./build-exec tar xz --strip-component 1 -C "$toolchain_path"
echo "toolchain-path=$toolchain_path" >> $GITHUB_OUTPUT
./build-exec "$toolchain_path/usr/bin/swift" sdk install "${{ matrix.wasi-swift-sdk-download }}"
./build-exec "$toolchain_path/usr/bin/swift" sdk install "${{ matrix.wasi-swift-sdk-download }}" --checksum "${{ matrix.wasi-swift-sdk-checksum }}"
wasi_sdk_path=$(./build-exec "$toolchain_path/usr/bin/swift" sdk configure --show-configuration "${{ matrix.wasi-swift-sdk-id }}" wasm32-unknown-wasi | grep sdkRootPath: | cut -d: -f2)
echo "wasi-swift-sdk-path=$(dirname $wasi_sdk_path)" >> $GITHUB_OUTPUT

Expand Down
33 changes: 26 additions & 7 deletions Plugins/WITExtractorPlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ struct Plugin: CommandPlugin {
"--package-name", context.package.displayName,
"--wit-output-path", witOutputPath.string,
"--swift-output-path", swiftOutputPath.string,
"-I", buildPath.string
"-I", buildPath.string,
// SwiftPM 6.0 and later emits swiftmodule files into a separate directory
// https://github.com/swiftlang/swift-package-manager/pull/7212
"-I", buildPath.appending(["Modules"]).string,
]
if let sdk {
arguments += ["-sdk", sdk]
Expand All @@ -74,12 +77,28 @@ struct Plugin: CommandPlugin {
return nil
}
for line in contents.split(separator: "\n") {
let prefix = " executable: \""
if line.hasPrefix(prefix), line.hasSuffix("/swiftc\"") {
let pathStart = line.index(line.startIndex, offsetBy: prefix.count)
let pathEnd = line.index(before: line.endIndex)
let executablePath = line[pathStart..<pathEnd]
return String(executablePath)
do {
let prefix = " executable: \""
if line.hasPrefix(prefix), line.hasSuffix("/swiftc\"") {
let pathStart = line.index(line.startIndex, offsetBy: prefix.count)
let pathEnd = line.index(before: line.endIndex)
let executablePath = line[pathStart..<pathEnd]
return String(executablePath)
}
}
do {
// Swift 6.0 no longer uses llbuild's built-in swift tool. Instead,
// it uses the generic shell tool with full arguments.
// https://github.com/swiftlang/swift-package-manager/pull/6585
let prefix = " args: "
if line.hasPrefix(prefix) {
let argsString = line[line.index(line.startIndex, offsetBy: prefix.count)...]
guard let args = try? JSONDecoder().decode([String].self, from: Data(argsString.utf8)),
let swiftc = args.first(where: { $0.hasSuffix("/swiftc") }) else {
continue
}
return swiftc
}
}
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions Sources/WITExtractor/SwiftAPIDigester.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ struct SwiftAPIDigester {
throw SwiftAPIDigesterError.unexpectedEmptyOutput
}
process.waitUntilExit()
guard process.terminationStatus == 0 else {
throw SwiftAPIDigesterError.nonZeroExitCode(process.terminationStatus, arguments: args)
}
return try Output.parse(output)
#endif
}
}

enum SwiftAPIDigesterError: Error {
case unexpectedEmptyOutput
case nonZeroExitCode(Int32, arguments: [String])
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ let guestPrelude = """
#if canImport(WASILibc)
import WASILibc
#endif
#if compiler(>=6.0)
private import _CabiShims
#else
@_implementationOnly import _CabiShims
#endif

fileprivate enum Prelude {
class LeakBox<Wrapped> {
Expand Down
6 changes: 6 additions & 0 deletions Tests/WATTests/LexerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class LexerTests: XCTestCase {
}

func testLexSpectest() throws {
// NOTE: We do the same check as a part of the EncoderTests, so it's
// usually redundant and time-wasting to run this test every time.
// Keeping it here just for local unit testing purposes.
try XCTSkipIf(
ProcessInfo.processInfo.environment["WASMKIT_LEXER_SPECTEST"] != "1"
)
var failureCount = 0
for filePath in Spectest.wastFiles() {
print("Lexing \(filePath.path)...")
Expand Down
6 changes: 6 additions & 0 deletions Tests/WATTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ class ParserTests: XCTestCase {
}

func testParseSpectest() throws {
// NOTE: We do the same check as a part of the EncoderTests, so it's
// usually redundant and time-wasting to run this test every time.
// Keeping it here just for local unit testing purposes.
try XCTSkipIf(
ProcessInfo.processInfo.environment["WASMKIT_PARSER_SPECTEST"] != "1"
)
var failureCount = 0
var totalCount = 0
for filePath in Spectest.wastFiles(include: []) {
Expand Down
3 changes: 0 additions & 3 deletions Tests/WITExtractorPluginTests/PluginSmokeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import XCTest

class PluginSmokeTests: XCTestCase {
func testExtractPlugin() throws {
#if compiler(>=6.0)
throw XCTSkip("XFAIL: Swift compiler path inference is broken in Swift 6.0")
#endif
guard ProcessInfo.processInfo.environment["__XCODE_BUILT_PRODUCTS_DIR_PATHS"] == nil else {
throw XCTSkip(
"\"swift package resolve\" somehow fails to clone git repository only when invoking from Xcode test runner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ struct RuntimeTestHarness {
arguments: [
"-target", "wasm32-unknown-none-wasm",
"-enable-experimental-feature", "Embedded",
"-enable-experimental-feature", "Extern",
"-wmo", "-Xcc", "-fdeclspec",
"-Xfrontend", "-disable-stack-protector",
"-Xlinker", "--no-entry", "-Xclang-linker", "-nostdlib",
Expand All @@ -176,6 +177,7 @@ struct RuntimeTestHarness {
inputFiles: inputFiles,
arguments: [
"-target", "wasm32-unknown-wasi",
"-enable-experimental-feature", "Extern",
"-static-stdlib",
"-Xclang-linker", "-mexec-model=reactor",
"-resource-dir", configuration.wasiSwiftSDKPath.appendingPathComponent("/swift.xctoolchain/usr/lib/swift_static").path,
Expand Down