Skip to content

Commit 2855d00

Browse files
authored
Merge pull request #410 from artemcm/lto-output-mode-clash
-c with LTO should still emit bitcode
2 parents 125b7d9 + 0ed837c commit 2855d00

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ extension Driver {
13351335
compilerOutputType = objectLikeFileType
13361336

13371337
case .emitObject, .c:
1338-
compilerOutputType = .object
1338+
compilerOutputType = objectLikeFileType
13391339

13401340
case .emitAssembly, .S:
13411341
compilerOutputType = .assembly

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,32 @@ final class SwiftDriverTests: XCTestCase {
281281
XCTAssertEqual(driver5.compilerOutputType, .llvmBitcode)
282282
}
283283

284+
func testLtoOutputModeClash() throws {
285+
let driver1 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full", "-static",
286+
"-emit-library", "-target", "x86_64-apple-macosx10.9"])
287+
XCTAssertEqual(driver1.compilerOutputType, .llvmBitcode)
288+
289+
let driver2 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full",
290+
"-emit-library", "-target", "x86_64-apple-macosx10.9"])
291+
XCTAssertEqual(driver2.compilerOutputType, .llvmBitcode)
292+
293+
let driver3 = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-full",
294+
"c", "-target", "x86_64-apple-macosx10.9"])
295+
XCTAssertEqual(driver3.compilerOutputType, .llvmBitcode)
296+
297+
let driver4 = try Driver(args: ["swiftc", "foo.swift", "-c","-lto=llvm-full",
298+
"-target", "x86_64-apple-macosx10.9"])
299+
XCTAssertEqual(driver4.compilerOutputType, .llvmBitcode)
300+
301+
let driver5 = try Driver(args: ["swiftc", "foo.swift", "-c","-lto=llvm-full",
302+
"-emit-bc", "-target", "x86_64-apple-macosx10.9"])
303+
XCTAssertEqual(driver5.compilerOutputType, .llvmBitcode)
304+
305+
let driver6 = try Driver(args: ["swiftc", "foo.swift", "-emit-bc", "-c","-lto=llvm-full",
306+
"-target", "x86_64-apple-macosx10.9"])
307+
XCTAssertEqual(driver6.compilerOutputType, .llvmBitcode)
308+
}
309+
284310
func testPrimaryOutputKindsDiagnostics() throws {
285311
try assertDriverDiagnostics(args: "swift", "-i") {
286312
$1.expect(.error("the flag '-i' is no longer required and has been removed; use 'swift input-filename'"))

0 commit comments

Comments
 (0)