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 21, 2023
1 parent 40a45ec commit 90aa042
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2892,12 +2892,16 @@ extension Driver {

extension Triple {
func toolchainType(_ diagnosticsEngine: DiagnosticsEngine) throws -> Toolchain.Type {
guard let os else {
diagnosticsEngine.emit(.error_unknown_target(triple))
throw Driver.ErrorDiagnostics.emitted
}
switch os {
case .darwin, .macosx, .ios, .tvos, .watchos:
return DarwinToolchain.self
case .linux:
return GenericUnixToolchain.self
case .freeBSD, .haiku, .openbsd:
case .freeBSD, .haiku, .openbsd, .none:
return GenericUnixToolchain.self
case .wasi:
return WebAssemblyToolchain.self
Expand Down
7 changes: 5 additions & 2 deletions Sources/SwiftDriver/Utilities/Triple+Platforms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ extension Triple {
/// identified as just `darwin` instead of by individual platform names.
/// Defaults to `false`.
public func platformName(conflatingDarwin: Bool = false) -> String? {
switch os {
case nil:
guard let os else {
fatalError("unknown OS")
}
switch os {
case .darwin, .macosx, .ios, .tvos, .watchos:
guard let darwinPlatform = darwinPlatform else {
fatalError("unsupported darwin platform kind?")
Expand Down Expand Up @@ -314,6 +315,8 @@ extension Triple {
return "haiku"
case .wasi:
return "wasi"
case .none:
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 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 Triple.OS.none
default:
return nil
}
Expand Down

0 comments on commit 90aa042

Please sign in to comment.