@@ -2056,6 +2056,45 @@ final class SwiftDriverTests: XCTestCase {
2056
2056
] ) )
2057
2057
}
2058
2058
2059
+ do {
2060
+ try withTemporaryDirectory { path in
2061
+ try localFileSystem. writeFileContents ( path. appending ( components: " linux " , " static-executable-args.lnk " ) ) {
2062
+ $0. send ( " empty " )
2063
+ }
2064
+ // Ensure that when building a static executable on Linux we do not pass in
2065
+ // a redundant '-pie'
2066
+ var driver = try Driver ( args: commonArgs + [ " -emit-executable " , " -L " , " /tmp " , " -Xlinker " , " --export-all " ,
2067
+ " -Xlinker " , " -E " , " -Xclang-linker " , " foo " ,
2068
+ " -resource-dir " , path. pathString,
2069
+ " -static-executable " ,
2070
+ " -target " , " x86_64-unknown-linux " ] , env: env)
2071
+ let plannedJobs = try driver. planBuild ( )
2072
+ XCTAssertEqual ( plannedJobs. count, 4 )
2073
+ let linkJob = plannedJobs [ 3 ]
2074
+ let cmd = linkJob. commandLine
2075
+ XCTAssertFalse ( cmd. contains ( . flag( " -pie " ) ) )
2076
+ }
2077
+
2078
+ }
2079
+
2080
+ do {
2081
+ try withTemporaryDirectory { path in
2082
+ try localFileSystem. writeFileContents ( path. appending ( components: " linux " , " static-executable-args.lnk " ) ) {
2083
+ $0. send ( " empty " )
2084
+ }
2085
+ // Ensure that when building a non-static executable on Linux, we specify '-pie'
2086
+ var driver = try Driver ( args: commonArgs + [ " -emit-executable " , " -L " , " /tmp " , " -Xlinker " , " --export-all " ,
2087
+ " -Xlinker " , " -E " , " -Xclang-linker " , " foo " ,
2088
+ " -resource-dir " , path. pathString,
2089
+ " -target " , " x86_64-unknown-linux " ] , env: env)
2090
+ let plannedJobs = try driver. planBuild ( )
2091
+ XCTAssertEqual ( plannedJobs. count, 4 )
2092
+ let linkJob = plannedJobs [ 3 ]
2093
+ let cmd = linkJob. commandLine
2094
+ XCTAssertTrue ( cmd. contains ( . flag( " -pie " ) ) )
2095
+ }
2096
+ }
2097
+
2059
2098
do {
2060
2099
// Xlinker flags
2061
2100
// Ensure that Xlinker flags are passed as such to the clang linker invocation.
0 commit comments