Skip to content

Commit 3e9b646

Browse files
authored
Bump to Swift 6 compiler for Linux (#81)
* Bump to Swift 6 compiler for Linux and WASI * Fix env issue * Fix #73 * Fix WASM CI issue
1 parent 82ad5dd commit 3e9b646

File tree

8 files changed

+14
-52
lines changed

8 files changed

+14
-52
lines changed

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
swift_version: ["5.10"]
15+
swift_version: ["6.0"]
1616
runs-on: ubuntu-22.04
1717
env:
1818
OPENGRAPH_WERROR: 1
19-
OPENGRAPH_SWIFT_TESTING: 1
2019
OPENGRAPH_ATTRIBUTEGRAPH: 0
2120
OPENGRAPH_COMPATIBILITY_TEST: 0
2221
container: swift:${{ matrix.swift_version }}-jammy

.github/workflows/wasm.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
swift_version: ["5.10.0-RELEASE"]
15+
swift_version: ["5.10.0-RELEASE", "6.0-SNAPSHOT-2024-09-18-a"]
1616
os: [ubuntu-22.04]
17+
include:
18+
- swift_version: "6.0-SNAPSHOT-2024-09-18-a"
19+
continue-on-error: true
1720
runs-on: ${{ matrix.os }}
1821
env:
1922
OPENGRAPH_WERROR: 1
20-
OPENGRAPH_SWIFT_TESTING: 0
2123
OPENGRAPH_ATTRIBUTEGRAPH: 0
2224
OPENGRAPH_COMPATIBILITY_TEST: 0
2325
steps:
@@ -26,9 +28,9 @@ jobs:
2628
with:
2729
swift-version: wasm-${{ matrix.swift_version }}
2830
- name: build
31+
continue-on-error: ${{ matrix.continue-on-error }}
2932
run: |
3033
swift build --triple wasm32-unknown-wasi
31-
# Blocked by upstream support for WASM. See https://github.com/apple/swift-testing/issues/228
3234
# - name: test
33-
# run: |
34-
# swift test --triple wasm32-unknown-wasi
35+
# run: |
36+
# swift test --triple wasm32-unknown-wasi

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ let openGraphCompatibilityTestTarget = Target.testTarget(
6060
swiftSettings: sharedSwiftSettings
6161
)
6262

63-
let swiftBinPath = Context.environment["_"] ?? ""
63+
let swiftBinPath = Context.environment["_"] ?? "/usr/bin/swift"
6464
let swiftBinURL = URL(fileURLWithPath: swiftBinPath)
6565
let SDKPath = swiftBinURL.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
66-
let includePath = SDKPath.appending("/usr/lib/swift_static")
66+
let includePath = SDKPath.appending("/usr/lib/swift")
6767

6868
let package = Package(
6969
name: "OpenGraph",

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let openGraphCompatibilityTestTarget = Target.testTarget(
5555
swiftSettings: sharedSwiftSettings
5656
)
5757

58-
let swiftBinPath = Context.environment["_"] ?? ""
58+
let swiftBinPath = Context.environment["_"] ?? "/usr/bin/swift"
5959
let swiftBinURL = URL(fileURLWithPath: swiftBinPath)
6060
let SDKPath = swiftBinURL.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().path
6161
let includePath = SDKPath.appending("/usr/lib/swift_static")

Plugins/UpdateModule/UpdateModuleCommand.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@ import Foundation
1010
@main
1111
struct UpdateModuleCommand: CommandPlugin {
1212
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws {
13+
#if compiler(>=6.0) // Skip build on WASI 5.10
1314
let process = Process()
14-
#if os(macOS)
15-
let path: String = try context.tool(named: "zsh").url.path()
16-
let url: URL? = if #available(macOS 14, *) {
17-
URL(filePath: path)
18-
} else {
19-
URL(string: "file://\(path)")
20-
}
21-
#else
22-
let path = try context.tool(named: "zsh").path.string
23-
let url = URL(string: "file://\(path)")
24-
#endif
25-
process.executableURL = url
15+
process.executableURL = try context.tool(named: "zsh").url
2616
process.arguments = ["AG/update.sh"]
2717
try process.run()
2818
process.waitUntilExit()
19+
#endif
2920
}
3021
}

Scripts/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))"
99

1010
cd $OPENGRAPH_ROOT
1111

12-
export OPENGRAPH_SWIFT_TESTING=0
1312
swift build

Scripts/og_swiftinterface.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ OG_ROOT="$(dirname $(dirname $(filepath $0)))"
99

1010
cd $OG_ROOT
1111

12-
export OPENGRAPH_SWIFT_TESTING=0
1312
swift build -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution

Tests/OpenGraphCompatibilityTests/Attribute/Attribute/PointerOffsetTests.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct PointerOffsetTests {
4242
#expect(invalidPointer == UnsafeMutablePointer(bitPattern: stride))
4343
}
4444

45-
#if compiler(>=6.0)
4645
@Test(.bug("https://github.com/OpenSwiftUIProject/OpenGraph/issues/70", id: 70, "Verify fix of #70"))
4746
func ofAndOffset() {
4847
struct Empty {
@@ -79,7 +78,6 @@ struct PointerOffsetTests {
7978
.of(&invalid.third)
8079
}
8180
}
82-
#endif
8381

8482
@Test("Extension API between UnsafePointer/UnsafeMutablePointer and PointerOffset")
8583
func unsafePointerAndUnsafeMutablePointerExtension() {
@@ -147,7 +145,6 @@ struct PointerOffsetTests {
147145
#expect((pointer + secondOffset).pointee == 4)
148146
#expect((pointer + thirdOffset).pointee == 5)
149147
}
150-
#if !(!canImport(Darwin) && !DEBUG)
151148
withUnsafePointer(to: triple) { pointer in
152149
#expect((pointer + firstOffset).pointee == 3)
153150
#expect((pointer + secondOffset).pointee == 4)
@@ -156,31 +153,6 @@ struct PointerOffsetTests {
156153
#expect(triple.first == 3)
157154
#expect(triple.second == 4)
158155
#expect(triple.third == 5)
159-
#endif
160-
}
161-
}
162-
163-
#if !canImport(Darwin) && !DEBUG
164-
@Test("Undefined Behavior Issue for PointerOffset", .bug("#73", relationship: .uncoveredBug))
165-
func unsafePointerAndUnsafeMutablePointerExtensionUB() {
166-
var tuple = Tuple(first: 1, second: 2)
167-
typealias Base = Tuple<Int, Int>
168-
let firstOffset = PointerOffset<Base, Int>(byteOffset: 0)
169-
withUnsafeMutablePointer(to: &tuple) { pointer in
170-
#expect(pointer[offset: firstOffset] == 1)
171-
pointer[offset: firstOffset] = 3
172-
}
173-
let unexpectedValue = tuple.first
174-
// The value will be unexpected due to UB
175-
#expect(unexpectedValue == 1)
176-
// The value will be expected after and within a withKnownIssue block
177-
withKnownIssue {
178-
let expectedValue = tuple.first
179-
#expect(expectedValue == 3)
180-
Issue.record("To make withKnownIssue pass")
181156
}
182-
let expectedValue = tuple.first
183-
#expect(expectedValue == 3)
184157
}
185-
#endif
186158
}

0 commit comments

Comments
 (0)