@@ -410,23 +410,24 @@ public final class UserToolchain: Toolchain {
410
410
static func deriveMacOSSpecificSwiftTestingFlags(
411
411
derivedSwiftCompiler: AbsolutePath ,
412
412
fileSystem: any FileSystem
413
- ) -> [ String ] {
413
+ ) -> ( swiftCFlags : [ String ] , linkerFlags : [ String ] ) {
414
414
// If this is CommandLineTools all we need to add is a frameworks path.
415
415
if let frameworksPath = try ? AbsolutePath (
416
416
validating: " ../../Library/Developer/Frameworks " ,
417
417
relativeTo: resolveSymlinks ( derivedSwiftCompiler) . parentDirectory
418
418
) , fileSystem. exists ( frameworksPath. appending ( " Testing.framework " ) ) {
419
- return [
419
+ return ( swiftCFlags : [
420
420
" -F " , frameworksPath. pathString,
421
+ ] , linkerFlags: [
421
422
" -Xlinker " , " -rpath " ,
422
- " -Xlinker " , frameworksPath. pathString
423
- ]
423
+ " -Xlinker " , frameworksPath. pathString,
424
+ ] )
424
425
}
425
426
426
427
guard let toolchainLibDir = try ? toolchainLibDir (
427
428
swiftCompilerPath: derivedSwiftCompiler
428
429
) else {
429
- return [ ]
430
+ return ( swiftCFlags : [ ] , linkerFlags : [ ] )
430
431
}
431
432
432
433
let testingLibDir = toolchainLibDir. appending (
@@ -438,15 +439,16 @@ public final class UserToolchain: Toolchain {
438
439
)
439
440
440
441
guard fileSystem. exists ( testingLibDir) , fileSystem. exists ( testingPluginsDir) else {
441
- return [ ]
442
+ return ( swiftCFlags : [ ] , linkerFlags : [ ] )
442
443
}
443
444
444
- return [
445
+ return ( swiftCFlags : [
445
446
" -I " , testingLibDir. pathString,
446
447
" -L " , testingLibDir. pathString,
447
448
" -plugin-path " , testingPluginsDir. pathString,
449
+ ] , linkerFlags: [
448
450
" -Xlinker " , " -rpath " , " -Xlinker " , testingLibDir. pathString,
449
- ]
451
+ ] )
450
452
}
451
453
452
454
internal static func deriveSwiftCFlags(
@@ -669,11 +671,15 @@ public final class UserToolchain: Toolchain {
669
671
self . targetTriple = triple
670
672
671
673
var swiftCompilerFlags : [ String ] = [ ]
674
+ var extraLinkerFlags : [ String ] = [ ]
675
+
672
676
#if os(macOS)
673
- swiftCompilerFlags + = Self . deriveMacOSSpecificSwiftTestingFlags (
677
+ let ( swiftCFlags , linkerFlags ) = Self . deriveMacOSSpecificSwiftTestingFlags (
674
678
derivedSwiftCompiler: swiftCompilers. compile,
675
679
fileSystem: fileSystem
676
680
)
681
+ swiftCompilerFlags += swiftCFlags
682
+ extraLinkerFlags += linkerFlags
677
683
#endif
678
684
679
685
swiftCompilerFlags += try Self . deriveSwiftCFlags (
@@ -683,11 +689,13 @@ public final class UserToolchain: Toolchain {
683
689
fileSystem: fileSystem
684
690
)
685
691
692
+ extraLinkerFlags += swiftSDK. toolset. knownTools [ . linker] ? . extraCLIOptions ?? [ ]
693
+
686
694
self . extraFlags = BuildFlags (
687
695
cCompilerFlags: swiftSDK. toolset. knownTools [ . cCompiler] ? . extraCLIOptions ?? [ ] ,
688
696
cxxCompilerFlags: swiftSDK. toolset. knownTools [ . cxxCompiler] ? . extraCLIOptions ?? [ ] ,
689
697
swiftCompilerFlags: swiftCompilerFlags,
690
- linkerFlags: swiftSDK . toolset . knownTools [ . linker ] ? . extraCLIOptions ?? [ ] ,
698
+ linkerFlags: extraLinkerFlags ,
691
699
xcbuildFlags: swiftSDK. toolset. knownTools [ . xcbuild] ? . extraCLIOptions ?? [ ] )
692
700
693
701
self . includeSearchPaths = swiftSDK. pathsConfiguration. includeSearchPaths ?? [ ]
0 commit comments