@@ -251,28 +251,10 @@ public struct Driver {
251
251
self . optionTable = OptionTable ( )
252
252
self . parsedOptions = try optionTable. parse ( Array ( args) , for: self . driverKind)
253
253
254
- ( self . toolchain, self . frontendTargetInfo) = try Self . computeToolchain (
255
- & self . parsedOptions, diagnosticsEngine: diagnosticEngine, env: env,
256
- executor: self . executor, fileSystem: fileSystem)
257
-
258
- // Local variable to alias the target triple, because self.targetTriple
259
- // is not available until the end of this initializer.
260
- let targetTriple = self . frontendTargetInfo. target. triple
261
-
262
- // Find the Swift compiler executable.
263
- if let frontendPath = self . parsedOptions. getLastArgument ( . driverUseFrontendPath) {
264
- var frontendCommandLine = frontendPath. asSingle. split ( separator: " ; " ) . map { String ( $0) }
265
- if frontendCommandLine. isEmpty {
266
- self . diagnosticEngine. emit ( . error_no_swift_frontend)
267
- self . swiftCompilerPrefixArgs = [ ]
268
- } else {
269
- let frontendPath = frontendCommandLine. removeFirst ( )
270
- self . toolchain. overrideToolPath ( . swiftCompiler, path: try AbsolutePath ( validating: frontendPath) )
271
- self . swiftCompilerPrefixArgs = frontendCommandLine
272
- }
273
- } else {
274
- self . swiftCompilerPrefixArgs = [ ]
275
- }
254
+ ( self . toolchain, self . frontendTargetInfo, self . swiftCompilerPrefixArgs) =
255
+ try Self . computeToolchain (
256
+ & self . parsedOptions, diagnosticsEngine: diagnosticEngine, env: env,
257
+ executor: self . executor, fileSystem: fileSystem)
276
258
277
259
// Compute the working directory.
278
260
workingDirectory = try parsedOptions. getLastArgument ( . workingDirectory) . map { workingDirectoryArg in
@@ -348,6 +330,9 @@ public struct Driver {
348
330
actualSwiftVersion: try ? toolchain. swiftCompilerVersion ( )
349
331
)
350
332
333
+ // Local variable to alias the target triple, because self.targetTriple
334
+ // is not available until the end of this initializer.
335
+ let targetTriple = self . frontendTargetInfo. target. triple
351
336
self . sdkPath = Self . computeSDKPath ( & parsedOptions, compilerMode: compilerMode, toolchain: toolchain, targetTriple: targetTriple,
352
337
fileSystem: fileSystem, diagnosticsEngine: diagnosticEngine, env: env)
353
338
@@ -1588,7 +1573,7 @@ extension Driver {
1588
1573
env: [ String : String ] ,
1589
1574
executor: DriverExecutor ,
1590
1575
fileSystem: FileSystem
1591
- ) throws -> ( Toolchain , FrontendTargetInfo ) {
1576
+ ) throws -> ( Toolchain , FrontendTargetInfo , [ String ] ) {
1592
1577
let explicitTarget = ( parsedOptions. getLastArgument ( . target) ? . asSingle)
1593
1578
. map {
1594
1579
Triple ( $0, normalizing: true )
@@ -1606,6 +1591,25 @@ extension Driver {
1606
1591
defaultToolchainType
1607
1592
let toolchain = toolchainType. init ( env: env, executor: executor, fileSystem: fileSystem)
1608
1593
1594
+ // Find the Swift compiler executable.
1595
+ let swiftCompilerPrefixArgs : [ String ]
1596
+ if let frontendPath = parsedOptions. getLastArgument ( . driverUseFrontendPath) {
1597
+ var frontendCommandLine =
1598
+ frontendPath. asSingle. split ( separator: " ; " ) . map { String ( $0) }
1599
+ if frontendCommandLine. isEmpty {
1600
+ diagnosticsEngine. emit ( . error_no_swift_frontend)
1601
+ swiftCompilerPrefixArgs = [ ]
1602
+ } else {
1603
+ let frontendPath = frontendCommandLine. removeFirst ( )
1604
+ toolchain. overrideToolPath (
1605
+ . swiftCompiler, path: try AbsolutePath ( validating: frontendPath) )
1606
+ swiftCompilerPrefixArgs = frontendCommandLine
1607
+ }
1608
+ } else {
1609
+ swiftCompilerPrefixArgs = [ ]
1610
+ }
1611
+
1612
+ // Query the frontend to for target information.
1609
1613
var info = try executor. execute (
1610
1614
job: toolchain. printTargetInfoJob (
1611
1615
target: explicitTarget, targetVariant: explicitTargetVariant,
@@ -1629,7 +1633,7 @@ extension Driver {
1629
1633
}
1630
1634
}
1631
1635
1632
- return ( toolchain, info)
1636
+ return ( toolchain, info, swiftCompilerPrefixArgs )
1633
1637
}
1634
1638
}
1635
1639
0 commit comments