Skip to content

Commit

Permalink
SwiftDriver: add support for baremetal targets (to reflect swiftlang/…
Browse files Browse the repository at this point in the history
  • Loading branch information
kubamracek committed Mar 31, 2023
1 parent af14cc2 commit 06c4244
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2936,7 +2936,7 @@ extension Triple {
return DarwinToolchain.self
case .linux:
return GenericUnixToolchain.self
case .freeBSD, .haiku, .openbsd:
case .freeBSD, .haiku, .openbsd, .noneOS:
return GenericUnixToolchain.self
case .wasi:
return WebAssemblyToolchain.self
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Utilities/Triple+Platforms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ extension Triple {
return "haiku"
case .wasi:
return "wasi"
case .noneOS:
return nil

// Explicitly spell out the remaining cases to force a compile error when
// Triple updates
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftDriver/Utilities/Triple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ extension Triple {
case hurd
case wasi
case emscripten
case noneOS // 'OS' suffix purely to avoid name clash with Optional.none

var name: String {
return rawValue
Expand Down Expand Up @@ -1188,6 +1189,8 @@ extension Triple {
return .wasi
case _ where os.hasPrefix("emscripten"):
return .emscripten
case _ where os.hasPrefix("none"):
return .noneOS
default:
return nil
}
Expand Down
8 changes: 7 additions & 1 deletion Tests/SwiftDriverTests/TripleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ final class TripleTests: XCTestCase {
T = Triple("arm-none-none-eabi")
XCTAssertEqual(T.arch, Triple.Arch.arm)
XCTAssertEqual(T.vendor, nil)
XCTAssertEqual(T.os, .noneOS)
XCTAssertEqual(T.environment, Triple.Environment.eabi)

T = Triple("arm-none-unknown-eabi")
XCTAssertEqual(T.arch, Triple.Arch.arm)
XCTAssertEqual(T.vendor, nil)
XCTAssertEqual(T.os, nil)
XCTAssertEqual(T.environment, Triple.Environment.eabi)

Expand Down Expand Up @@ -723,7 +729,7 @@ final class TripleTests: XCTestCase {
assertNormalizesEqual("i686-linux",
"i686-unknown-linux") // i686-pc-linux-gnu
assertNormalizesEqual("arm-none-eabi",
"arm-none-unknown-eabi") // arm-none-eabi
"arm-unknown-none-eabi") // arm-none-eabi
assertNormalizesEqual("wasm32-wasi",
"wasm32-unknown-wasi") // wasm32-unknown-wasi
assertNormalizesEqual("wasm64-wasi",
Expand Down

0 comments on commit 06c4244

Please sign in to comment.