Skip to content

Commit 69863e6

Browse files
Merge pull request #637 from artemcm/CHerryPickStaticExecutableVerify
[5.5] Validate that `-static-executable` is not supported on Darwin.
2 parents b7ab843 + e85183b commit 69863e6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ import SwiftOptions
181181
}
182182
// Validating darwin unsupported -static-stdlib argument.
183183
if parsedOptions.hasArgument(.staticStdlib) {
184-
throw ToolchainValidationError.argumentNotSupported("-static-stdlib")
184+
throw ToolchainValidationError.argumentNotSupported("-static-stdlib")
185+
}
186+
// Validating darwin unsupported -static-executable argument.
187+
if parsedOptions.hasArgument(.staticExecutable) {
188+
throw ToolchainValidationError.argumentNotSupported("-static-executable")
185189
}
186190
// If a C++ standard library is specified, it has to be libc++.
187191
if let cxxLib = parsedOptions.getLastArgument(.experimentalCxxStdlib) {

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,14 @@ final class SwiftDriverTests: XCTestCase {
23852385
return
23862386
}
23872387
}
2388+
2389+
XCTAssertThrowsError(try Driver(args: ["swiftc", "-c", "-static-executable", "-target", "x86_64-apple-macosx10.14",
2390+
"foo.swift"])) { error in
2391+
guard case DarwinToolchain.ToolchainValidationError.argumentNotSupported("-static-executable") = error else {
2392+
XCTFail()
2393+
return
2394+
}
2395+
}
23882396

23892397
XCTAssertThrowsError(try Driver(args: ["swiftc", "-c", "-target", "x86_64-apple-macosx10.14", "-experimental-cxx-stdlib", "libstdc++",
23902398
"foo.swift"])) { error in

0 commit comments

Comments
 (0)