[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 18:50:07 PDT 2017
pcc created this revision.
Herald added a subscriber: mehdi_amini.
The MSVC linker doesn't support them.
https://reviews.llvm.org/D31067
Files:
lld/COFF/Driver.cpp
lld/test/COFF/msvclto-archive.ll
Index: lld/test/COFF/msvclto-archive.ll
===================================================================
--- lld/test/COFF/msvclto-archive.ll
+++ lld/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/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/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.92098.patch
Type: text/x-patch
Size: 1780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/7477d3e9/attachment.bin>
More information about the llvm-commits
mailing list