From 3ebf8b478a0f8236d0d29b129d67f802e7e3f6eb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 8 Jun 2021 22:32:16 -0400 Subject: [PATCH] Pass -warn-on-potentially-unavailable-enum-case frontend flag when building a module Fixes rdar://problem/78306593. --- Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift | 9 +++++++++ Sources/SwiftOptions/Options.swift | 1 + 2 files changed, 10 insertions(+) diff --git a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift index 1f4468669..0c06fc648 100644 --- a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift +++ b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift @@ -85,6 +85,15 @@ extension Driver { commandLine.appendFlag("-aarch64-use-tbi") } + // Potentially unavailable enum cases are downgraded to a warning when building a + // swiftmodule, to allow building a module (or module interface) for an older + // deployment target than the framework itself. + if isFrontendArgSupported(.warnOnPotentiallyUnavailableEnumCase) { + if compilerOutputType == .swiftModule { + commandLine.appendFlag(.warnOnPotentiallyUnavailableEnumCase) + } + } + // Enable or disable ObjC interop appropriately for the platform if targetTriple.isDarwin { commandLine.appendFlag(.enableObjcInterop) diff --git a/Sources/SwiftOptions/Options.swift b/Sources/SwiftOptions/Options.swift index cfcfa63de..1d74ae704 100644 --- a/Sources/SwiftOptions/Options.swift +++ b/Sources/SwiftOptions/Options.swift @@ -576,6 +576,7 @@ extension Option { public static let warnLongExpressionTypeChecking: Option = Option("-warn-long-expression-type-checking", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "", helpText: "Warns when type-checking a function takes longer than ms") public static let warnLongFunctionBodiesEQ: Option = Option("-warn-long-function-bodies=", .joined, alias: Option.warnLongFunctionBodies, attributes: [.helpHidden, .frontend, .noDriver]) public static let warnLongFunctionBodies: Option = Option("-warn-long-function-bodies", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "", helpText: "Warns when type-checking a function takes longer than ms") + public static let warnOnPotentiallyUnavailableEnumCase: Option = Option("-warn-on-potentially-unavailable-enum-case", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Downgrade potential unavailability of enum case to a warning") public static let warnSwift3ObjcInferenceComplete: Option = Option("-warn-swift3-objc-inference-complete", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Warn about deprecated @objc inference in Swift 3 for every declaration that will no longer be inferred as @objc in Swift 4") public static let warnSwift3ObjcInferenceMinimal: Option = Option("-warn-swift3-objc-inference-minimal", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Warn about deprecated @objc inference in Swift 3 based on direct uses of the Objective-C entrypoint") public static let warnSwift3ObjcInference: Option = Option("-warn-swift3-objc-inference", .flag, alias: Option.warnSwift3ObjcInferenceComplete, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild])