13
13
import SwiftOptions
14
14
import struct Foundation. Data
15
15
import class Foundation. JSONDecoder
16
-
16
+ import struct TSCBasic . Diagnostic
17
17
import class TSCBasic. DiagnosticsEngine
18
18
import protocol TSCBasic. FileSystem
19
19
import struct TSCBasic. RelativePath
@@ -58,25 +58,17 @@ extension Toolchain {
58
58
59
59
extension Driver {
60
60
static func computeSupportedCompilerArgs( of toolchain: Toolchain , hostTriple: Triple ,
61
- parsedOptions: inout ParsedOptions ,
62
- diagnosticsEngine: DiagnosticsEngine ,
63
- fileSystem: FileSystem ,
64
- executor: DriverExecutor , env: [ String : String ] )
61
+ parsedOptions: inout ParsedOptions ,
62
+ diagnosticsEngine: DiagnosticsEngine ,
63
+ fileSystem: FileSystem ,
64
+ executor: DriverExecutor , env: [ String : String ] )
65
65
throws -> Set < String > {
66
- // TODO: Once we are sure libSwiftScan is deployed across supported platforms and architectures
67
- // we should deploy it here.
68
- // let swiftScanLibPath = try Self.getScanLibPath(of: toolchain,
69
- // hostTriple: hostTriple,
70
- // env: env)
71
- //
72
- // if fileSystem.exists(swiftScanLibPath) {
73
- // let libSwiftScanInstance = try SwiftScan(dylib: swiftScanLibPath)
74
- // if libSwiftScanInstance.canQuerySupportedArguments() {
75
- // return try libSwiftScanInstance.querySupportedArguments()
76
- // }
77
- // }
66
+ if let supportedArgs = try querySupportedCompilerArgsInProcess ( of: toolchain, hostTriple: hostTriple,
67
+ fileSystem: fileSystem, env: env) {
68
+ return supportedArgs
69
+ }
78
70
79
- // Invoke `swift-frontend -emit-supported-features`
71
+ // Fallback: Invoke `swift-frontend -emit-supported-features` and decode the output
80
72
let frontendOverride = try FrontendOverride ( & parsedOptions, diagnosticsEngine)
81
73
frontendOverride. setUpForTargetInfo ( toolchain)
82
74
defer { frontendOverride. setUpForCompilation ( toolchain) }
@@ -91,6 +83,23 @@ extension Driver {
91
83
return Set ( decodedSupportedFlagList)
92
84
}
93
85
86
+ static func querySupportedCompilerArgsInProcess( of toolchain: Toolchain ,
87
+ hostTriple: Triple ,
88
+ fileSystem: FileSystem ,
89
+ env: [ String : String ] )
90
+ throws -> Set < String > ? {
91
+ let swiftScanLibPath = try Self . getScanLibPath ( of: toolchain,
92
+ hostTriple: hostTriple,
93
+ env: env)
94
+ if fileSystem. exists ( swiftScanLibPath) {
95
+ let libSwiftScanInstance = try SwiftScan ( dylib: swiftScanLibPath)
96
+ if libSwiftScanInstance. canQuerySupportedArguments ( ) {
97
+ return try libSwiftScanInstance. querySupportedArguments ( )
98
+ }
99
+ }
100
+ return nil
101
+ }
102
+
94
103
static func computeSupportedCompilerFeatures( of toolchain: Toolchain ,
95
104
env: [ String : String ] ) throws -> Set < String > {
96
105
struct FeatureInfo : Codable {
0 commit comments