@@ -57,26 +57,19 @@ extension Toolchain {
57
57
}
58
58
59
59
extension Driver {
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 ] )
60
+ static func computeSupportedCompilerArgs( of toolchain: Toolchain ,
61
+ hostTriple: Triple ,
62
+ parsedOptions: inout ParsedOptions ,
63
+ diagnosticsEngine: DiagnosticsEngine ,
64
+ fileSystem: FileSystem ,
65
+ executor: DriverExecutor , env: [ String : String ] )
65
66
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
- // }
67
+ if let supportedArgs = try querySupportedCompilerArgsInProcess ( of: toolchain, hostTriple: hostTriple,
68
+ fileSystem: fileSystem, env: env) {
69
+ return supportedArgs
70
+ }
78
71
79
- // Invoke `swift-frontend -emit-supported-features`
72
+ // Fallback: Invoke `swift-frontend -emit-supported-features` and decode the output
80
73
let frontendOverride = try FrontendOverride ( & parsedOptions, diagnosticsEngine)
81
74
frontendOverride. setUpForTargetInfo ( toolchain)
82
75
defer { frontendOverride. setUpForCompilation ( toolchain) }
@@ -91,6 +84,23 @@ extension Driver {
91
84
return Set ( decodedSupportedFlagList)
92
85
}
93
86
87
+ static func querySupportedCompilerArgsInProcess( of toolchain: Toolchain ,
88
+ hostTriple: Triple ,
89
+ fileSystem: FileSystem ,
90
+ env: [ String : String ] )
91
+ throws -> Set < String > ? {
92
+ let swiftScanLibPath = try Self . getScanLibPath ( of: toolchain,
93
+ hostTriple: hostTriple,
94
+ env: env)
95
+ if fileSystem. exists ( swiftScanLibPath) {
96
+ let libSwiftScanInstance = try SwiftScan ( dylib: swiftScanLibPath)
97
+ if libSwiftScanInstance. canQuerySupportedArguments ( ) {
98
+ return try libSwiftScanInstance. querySupportedArguments ( )
99
+ }
100
+ }
101
+ return nil
102
+ }
103
+
94
104
static func computeSupportedCompilerFeatures( of toolchain: Toolchain ,
95
105
env: [ String : String ] ) throws -> Set < String > {
96
106
struct FeatureInfo : Codable {
0 commit comments