@@ -500,6 +500,60 @@ final class ExplicitModuleBuildTests: XCTestCase {
500500 }
501501 }
502502
503+ func testExplicitLinkFlags( ) throws {
504+ try withTemporaryDirectory { path in
505+ let ( _, _, toolchain, _) = try getDriverArtifactsForScanning ( )
506+
507+ let main = path. appending ( component: " testExplicitLinkLibraries.swift " )
508+ try localFileSystem. writeFileContents ( main, bytes:
509+ """
510+ import C;import E;import G;
511+ """
512+ )
513+
514+ let cHeadersPath : AbsolutePath =
515+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
516+ . appending ( component: " CHeaders " )
517+ let bridgingHeaderpath : AbsolutePath =
518+ cHeadersPath. appending ( component: " Bridging.h " )
519+ let swiftModuleInterfacesPath : AbsolutePath =
520+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
521+ . appending ( component: " Swift " )
522+ let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
523+
524+ // Verify the dependency scanner supports link library reporting
525+ let dependencyOracle = InterModuleDependencyOracle ( )
526+ let scanLibPath = try XCTUnwrap ( toolchain. lookupSwiftScanLib ( ) )
527+ try dependencyOracle. verifyOrCreateScannerInstance ( swiftScanLibPath: scanLibPath)
528+ guard try dependencyOracle. supportsLinkLibraries ( ) else {
529+ throw XCTSkip ( " libSwiftScan does not support link library reporting. " )
530+ }
531+
532+ let args = [ " swiftc " ,
533+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
534+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
535+ " -explicit-module-build " , " -explicit-auto-linking " ,
536+ " -import-objc-header " , bridgingHeaderpath. nativePathString ( escaped: true ) ,
537+ main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting
538+ var driver = try Driver ( args: args)
539+ let jobs = try driver. planBuild ( )
540+
541+ let linkJob = try jobs. findJob ( . link)
542+ if driver. targetTriple. isDarwin {
543+ XCTAssertTrue ( linkJob. commandLine. contains ( " -possible-lswiftCore " ) )
544+ XCTAssertTrue ( linkJob. commandLine. contains ( " -possible-lswift_StringProcessing " ) )
545+ XCTAssertTrue ( linkJob. commandLine. contains ( " -possible-lobjc " ) )
546+ XCTAssertTrue ( linkJob. commandLine. contains ( " -possible-lswift_Concurrency " ) )
547+ XCTAssertTrue ( linkJob. commandLine. contains ( " -possible-lswiftSwiftOnoneSupport " ) )
548+ } else {
549+ XCTAssertTrue ( linkJob. commandLine. contains ( " -lswiftCore " ) )
550+ XCTAssertTrue ( linkJob. commandLine. contains ( " -lswift_StringProcessing " ) )
551+ XCTAssertTrue ( linkJob. commandLine. contains ( " -lswift_Concurrency " ) )
552+ XCTAssertTrue ( linkJob. commandLine. contains ( " -lswiftSwiftOnoneSupport " ) )
553+ }
554+ }
555+ }
556+
503557 func testExplicitLinkLibraries( ) throws {
504558 try withTemporaryDirectory { path in
505559 let ( _, _, toolchain, _) = try getDriverArtifactsForScanning ( )
0 commit comments