Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lld/COFF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,19 @@ std::vector<MemoryBufferRef>
lld::coff::getArchiveMembers(COFFLinkerContext &ctx, Archive *file) {
std::vector<MemoryBufferRef> v;
Error err = Error::success();

// Thin archives refer to .o files, so --reproduces needs the .o files too.
bool addToTar = file->isThin() && ctx.driver.tar;

for (const Archive::Child &c : file->children(err)) {
MemoryBufferRef mbref =
CHECK(c.getMemoryBufferRef(),
file->getFileName() +
": could not get the buffer for a child of the archive");
if (addToTar) {
ctx.driver.tar->append(relativeToRoot(check(c.getFullName())),
mbref.getBuffer());
}
v.push_back(mbref);
}
if (err)
Expand Down
23 changes: 23 additions & 0 deletions lld/test/COFF/linkrepro-thin-archives.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# REQUIRES: x86

# RUN: rm -rf %t.dir; split-file %s %t.dir

# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-windows %t.dir/foo.s -o %t.dir/foo.obj
# RUN: cd %t.dir
# RUN: llvm-ar rcsT foo.lib foo.obj

# RUN: lld-link foo.lib /out:/dev/null /reproduce:repro.tar \
# RUN: /subsystem:console /machine:x64
# RUN: tar tf repro.tar | FileCheck -DPATH='repro/%:t.dir' %s

# RUN: lld-link /wholearchive foo.lib /out:/dev/null /reproduce:repro2.tar \
# RUN: /subsystem:console /machine:x64
# RUN: tar tf repro2.tar | FileCheck -DPATH='repro2/%:t.dir' %s

# CHECK-DAG: [[PATH]]/foo.lib
# CHECK-DAG: [[PATH]]/foo.obj

#--- foo.s
.globl mainCRTStartup
mainCRTStartup:
nop
Loading