@@ -25,6 +25,8 @@ public struct Driver {
25
25
case integratedReplRemoved
26
26
case conflictingOptions( Option , Option )
27
27
case unableToLoadOutputFileMap( String )
28
+ case unableToDecodeFrontendTargetInfo
29
+ case failedToRetrieveFrontendTargetInfo
28
30
// Explicit Module Build Failures
29
31
case malformedModuleDependency( String , String )
30
32
case missingPCMArguments( String )
@@ -49,6 +51,10 @@ public struct Driver {
49
51
return " Compiler-internal integrated REPL has been removed; use the LLDB-enhanced REPL instead. "
50
52
case . conflictingOptions( let one, let two) :
51
53
return " conflicting options ' \( one. spelling) ' and ' \( two. spelling) ' "
54
+ case . unableToDecodeFrontendTargetInfo:
55
+ return " could not decode frontend target info; compiler driver and frontend executables may be incompatible "
56
+ case . failedToRetrieveFrontendTargetInfo:
57
+ return " failed to retrieve frontend target info "
52
58
// Explicit Module Build Failures
53
59
case . malformedModuleDependency( let moduleName, let errorDescription) :
54
60
return " Malformed Module Dependency: \( moduleName) , \( errorDescription) "
@@ -1639,7 +1645,8 @@ extension Driver {
1639
1645
diagnosticsEngine: diagnosticsEngine, env: env)
1640
1646
1641
1647
// Query the frontend to for target information.
1642
- var info = try executor. execute (
1648
+ do {
1649
+ var info = try executor. execute (
1643
1650
job: toolchain. printTargetInfoJob (
1644
1651
target: explicitTarget, targetVariant: explicitTargetVariant,
1645
1652
sdkPath: sdkPath, resourceDirPath: resourceDirPath,
@@ -1650,21 +1657,27 @@ extension Driver {
1650
1657
forceResponseFiles: false ,
1651
1658
recordedInputModificationDates: [ : ] )
1652
1659
1653
- // Parse the runtime compatibility version. If present, it will override
1654
- // what is reported by the frontend.
1655
- if let versionString =
1656
- parsedOptions. getLastArgument ( . runtimeCompatibilityVersion) ? . asSingle {
1657
- if let version = SwiftVersion ( string: versionString) {
1658
- info. target. swiftRuntimeCompatibilityVersion = version
1659
- info. targetVariant? . swiftRuntimeCompatibilityVersion = version
1660
- } else {
1661
- diagnosticsEngine. emit (
1662
- . error_invalid_arg_value(
1663
- arg: . runtimeCompatibilityVersion, value: versionString) )
1660
+
1661
+ // Parse the runtime compatibility version. If present, it will override
1662
+ // what is reported by the frontend.
1663
+ if let versionString =
1664
+ parsedOptions. getLastArgument ( . runtimeCompatibilityVersion) ? . asSingle {
1665
+ if let version = SwiftVersion ( string: versionString) {
1666
+ info. target. swiftRuntimeCompatibilityVersion = version
1667
+ info. targetVariant? . swiftRuntimeCompatibilityVersion = version
1668
+ } else {
1669
+ diagnosticsEngine. emit (
1670
+ . error_invalid_arg_value(
1671
+ arg: . runtimeCompatibilityVersion, value: versionString) )
1672
+ }
1664
1673
}
1665
- }
1666
1674
1667
- return ( toolchain, info, swiftCompilerPrefixArgs)
1675
+ return ( toolchain, info, swiftCompilerPrefixArgs)
1676
+ } catch is DecodingError {
1677
+ throw Error . unableToDecodeFrontendTargetInfo
1678
+ } catch {
1679
+ throw Error . failedToRetrieveFrontendTargetInfo
1680
+ }
1668
1681
}
1669
1682
}
1670
1683
0 commit comments