Skip to content

-c with LTO should still emit bitcode #410

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 1 commit into from
Feb 4, 2021
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
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ extension Driver {
compilerOutputType = objectLikeFileType

case .emitObject, .c:
compilerOutputType = .object
compilerOutputType = objectLikeFileType

case .emitAssembly, .S:
compilerOutputType = .assembly
Expand Down
26 changes: 26 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertEqual(driver5.compilerOutputType, .llvmBitcode)
}

func testLtoOutputModeClash() throws {
let driver1 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full", "-static",
"-emit-library", "-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver1.compilerOutputType, .llvmBitcode)

let driver2 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full",
"-emit-library", "-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver2.compilerOutputType, .llvmBitcode)

let driver3 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full",
"c", "-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver3.compilerOutputType, .llvmBitcode)

let driver4 = try Driver(args: ["swiftc", "foo.swift", "-c","-lto=llvm-full",
"-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver4.compilerOutputType, .llvmBitcode)

let driver5 = try Driver(args: ["swiftc", "foo.swift", "-c","-lto=llvm-full",
"-emit-bc", "-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver5.compilerOutputType, .llvmBitcode)

let driver6 = try Driver(args: ["swiftc", "foo.swift", "-emit-bc", "-c","-lto=llvm-full",
"-target", "x86_64-apple-macosx10.9"])
XCTAssertEqual(driver6.compilerOutputType, .llvmBitcode)
}

func testPrimaryOutputKindsDiagnostics() throws {
try assertDriverDiagnostics(args: "swift", "-i") {
$1.expect(.error("the flag '-i' is no longer required and has been removed; use 'swift input-filename'"))
Expand Down