[lld] r298034 - COFF: Do not create empty temporary archives for /msvclto.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 19:04:22 PDT 2017
Author: pcc
Date: Thu Mar 16 21:04:22 2017
New Revision: 298034
URL: http://llvm.org/viewvc/llvm-project?rev=298034&view=rev
Log:
COFF: Do not create empty temporary archives for /msvclto.
The MSVC linker doesn't support them.
Differential Revision: https://reviews.llvm.org/D31067
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/test/COFF/msvclto-archive.ll
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=298034&r1=298033&r2=298034&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu Mar 16 21:04:22 2017
@@ -475,9 +475,6 @@ filterBitcodeFiles(StringRef Path, std::
if (!needsRebuilding(MBRef))
return Path.str();
- log("Creating a temporary archive for " + Path +
- " to remove bitcode files");
-
std::unique_ptr<Archive> File =
check(Archive::create(MBRef),
MBRef.getBufferIdentifier() + ": failed to parse archive");
@@ -487,6 +484,11 @@ filterBitcodeFiles(StringRef Path, std::
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))
Modified: lld/trunk/test/COFF/msvclto-archive.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/msvclto-archive.ll?rev=298034&r1=298033&r2=298034&view=diff
==============================================================================
--- lld/trunk/test/COFF/msvclto-archive.ll (original)
+++ lld/trunk/test/COFF/msvclto-archive.ll Thu Mar 16 21:04:22 2017
@@ -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
More information about the llvm-commits
mailing list