Skip to content

[5.5] Validate that -static-executable is not supported on Darwin. #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ import SwiftOptions
}
// Validating darwin unsupported -static-stdlib argument.
if parsedOptions.hasArgument(.staticStdlib) {
throw ToolchainValidationError.argumentNotSupported("-static-stdlib")
throw ToolchainValidationError.argumentNotSupported("-static-stdlib")
}
// Validating darwin unsupported -static-executable argument.
if parsedOptions.hasArgument(.staticExecutable) {
throw ToolchainValidationError.argumentNotSupported("-static-executable")
}
// If a C++ standard library is specified, it has to be libc++.
if let cxxLib = parsedOptions.getLastArgument(.experimentalCxxStdlib) {
Expand Down
8 changes: 8 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,14 @@ final class SwiftDriverTests: XCTestCase {
return
}
}

XCTAssertThrowsError(try Driver(args: ["swiftc", "-c", "-static-executable", "-target", "x86_64-apple-macosx10.14",
"foo.swift"])) { error in
guard case DarwinToolchain.ToolchainValidationError.argumentNotSupported("-static-executable") = error else {
XCTFail()
return
}
}

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