[PATCH] D31067: COFF: Do not create empty temporary archives for /msvclto.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 19:16:33 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL298034: COFF: Do not create empty temporary archives for /msvclto. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D31067?vs=92098&id=92100#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31067

Files:
  lld/trunk/COFF/Driver.cpp
  lld/trunk/test/COFF/msvclto-archive.ll


Index: lld/trunk/test/COFF/msvclto-archive.ll
===================================================================
--- lld/trunk/test/COFF/msvclto-archive.ll
+++ lld/trunk/test/COFF/msvclto-archive.ll
@@ -1,14 +1,16 @@
 ;; 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
 ; RUN: mkdir -p %t.dir
 ; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s
 ; 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
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<Archive> 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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31067.92100.patch
Type: text/x-patch
Size: 1816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/3028990c/attachment-0001.bin>


More information about the llvm-commits mailing list