@@ -1289,8 +1289,43 @@ final class SwiftDriverTests: XCTestCase {
12891289 XCTAssertFalse ( cmd. contains ( . flag( " -dylib " ) ) )
12901290 XCTAssertFalse ( cmd. contains ( . flag( " -static " ) ) )
12911291 XCTAssertFalse ( cmd. contains ( . flag( " -shared " ) ) )
1292+ XCTAssertFalse ( cmd. contains ( . flag( " --start-group " ) ) )
1293+ XCTAssertFalse ( cmd. contains ( . flag( " --end-group " ) ) )
12921294 }
12931295
1296+ // /usr/lib/swift_static/linux/static-stdlib-args.lnk is required for static
1297+ // linking on Linux, but is not present in macOS toolchains
1298+ #if os(Linux)
1299+ do {
1300+ // executable linking linux static stdlib
1301+ var driver = try Driver ( args: commonArgs + [ " -emit-executable " , " -static-stdlib " , " -target " , " x86_64-unknown-linux " ] , env: env)
1302+ let plannedJobs = try driver. planBuild ( )
1303+
1304+ XCTAssertEqual ( plannedJobs. count, 4 )
1305+
1306+ let autolinkExtractJob = plannedJobs [ 2 ]
1307+ XCTAssertEqual ( autolinkExtractJob. kind, . autolinkExtract)
1308+
1309+ let autolinkCmd = autolinkExtractJob. commandLine
1310+ XCTAssertTrue ( autolinkCmd. contains ( . path( . temporary( RelativePath ( " foo.o " ) ) ) ) )
1311+ XCTAssertTrue ( autolinkCmd. contains ( . path( . temporary( RelativePath ( " bar.o " ) ) ) ) )
1312+ XCTAssertTrue ( autolinkCmd. contains ( . path( . temporary( RelativePath ( " Test.autolink " ) ) ) ) )
1313+
1314+ let linkJob = plannedJobs [ 3 ]
1315+ let cmd = linkJob. commandLine
1316+ XCTAssertTrue ( cmd. contains ( . flag( " -o " ) ) )
1317+ XCTAssertTrue ( cmd. contains ( . path( . temporary( RelativePath ( " foo.o " ) ) ) ) )
1318+ XCTAssertTrue ( cmd. contains ( . path( . temporary( RelativePath ( " bar.o " ) ) ) ) )
1319+ XCTAssertTrue ( cmd. contains ( . flag( " --start-group " ) ) )
1320+ XCTAssertTrue ( cmd. contains ( . flag( " --end-group " ) ) )
1321+ XCTAssertEqual ( linkJob. outputs [ 0 ] . file, try VirtualPath ( path: " Test " ) )
1322+
1323+ XCTAssertFalse ( cmd. contains ( . flag( " -static " ) ) )
1324+ XCTAssertFalse ( cmd. contains ( . flag( " -dylib " ) ) )
1325+ XCTAssertFalse ( cmd. contains ( . flag( " -shared " ) ) )
1326+ }
1327+ #endif
1328+
12941329 do {
12951330 // static WASM linking
12961331 var driver = try Driver ( args: commonArgs + [ " -emit-library " , " -static " , " -target " , " wasm32-unknown-wasi " ] , env: env)
0 commit comments