diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index e3051fac170e7..6da917a50c52d 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1501,6 +1501,8 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, case options::OPT_emit_object: OI.CompilerOutputType = file_types::TY_Object; + if (OI.LTOVariant != OutputInfo::LTOKind::None) + OI.CompilerOutputType = file_types::TY_LLVM_BC; break; case options::OPT_emit_assembly: diff --git a/test/Driver/lto-output-mode-clash.swift b/test/Driver/lto-output-mode-clash.swift new file mode 100644 index 0000000000000..3114aec866c93 --- /dev/null +++ b/test/Driver/lto-output-mode-clash.swift @@ -0,0 +1,13 @@ +// REQUIRES: lld_lto + +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm-full -static -emit-library -target x86_64-apple-macosx10.9 | %FileCheck %s +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm-full -emit-library -target x86_64-apple-macosx10.9 | %FileCheck %s +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm-full -c -target x86_64-apple-macosx10.9 | %FileCheck %s +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -c -lto=llvm-full -target x86_64-apple-macosx10.9 | %FileCheck %s +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -c -lto=llvm-full -emit-bc -target x86_64-apple-macosx10.9 | %FileCheck %s +// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -emit-bc -c -lto=llvm-full -target x86_64-apple-macosx10.9 | %FileCheck %s + +// CHECK: swift +// CHECK-DAG: -emit-bc +// CHECK-DAG: -lto=llvm-full +// CHECK-DAG: -o [[BITCODEFILE:.*\.bc]]