Index: lld/trunk/COFF/Driver.cpp =================================================================== --- lld/trunk/COFF/Driver.cpp +++ lld/trunk/COFF/Driver.cpp @@ -475,9 +475,6 @@ if (!needsRebuilding(MBRef)) return Path.str(); - log("Creating a temporary archive for " + Path + - " to remove bitcode files"); - std::unique_ptr File = check(Archive::create(MBRef), MBRef.getBufferIdentifier() + ": failed to parse archive"); @@ -487,6 +484,11 @@ if (identify_magic(Member.getBuffer()) != file_magic::bitcode) New.emplace_back(Member); + if (New.empty()) + return None; + + log("Creating a temporary archive for " + Path + " to remove bitcode files"); + SmallString<128> S; if (auto EC = sys::fs::createTemporaryFile("lld-" + sys::path::stem(Path), ".lib", S)) Index: lld/trunk/test/COFF/msvclto-archive.ll =================================================================== --- lld/trunk/test/COFF/msvclto-archive.ll +++ lld/trunk/test/COFF/msvclto-archive.ll @@ -1,5 +1,7 @@ ;; Make sure we re-create archive files to strip bitcode files. +;; Do not create empty archives because the MSVC linker +;; doesn't support them. ; RUN: llvm-as -o %t.obj %s ; RUN: rm -f %t-main1.a ; RUN: llvm-ar cru %t-main1.a %t.obj @@ -8,7 +10,7 @@ ; RUN: lld-link %t-main1.a %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ ; RUN: /entry:main /verbose > %t.log || true ; RUN: FileCheck -check-prefix=BC %s < %t.log -; BC: Creating a temporary archive for +; BC-NOT: Creating a temporary archive for ; RUN: rm -f %t-main2.a ; RUN: llvm-ar cru %t-main2.a %t.dir/bitcode.obj