Skip to content

Commit

Permalink
[AIX] llvm-link support big archive.
Browse files Browse the repository at this point in the history
Summary:
Use object::Archive::create so that the returned archive object has a dynamic type of either Archive or BigArchive.

Reviewers: James Henderson,Fangrui Song
Differential Revision: https://reviews.llvm.org/D124940
  • Loading branch information
diggerlin committed May 16, 2022
1 parent 0533253 commit c38ef55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion llvm/test/tools/llvm-link/archivell.ll
@@ -1,4 +1,3 @@
# XFAIL: system-aix
# RUN: llvm-ar cr %t.fg.a %S/Inputs/f.ll %S/Inputs/g.ll
# RUN: not llvm-link %S/Inputs/h.ll %t.fg.a -o %t.linked.bc 2>&1 | FileCheck %s

Expand Down
13 changes: 9 additions & 4 deletions llvm/tools/llvm-link/llvm-link.cpp
Expand Up @@ -164,11 +164,16 @@ static std::unique_ptr<Module> loadArFile(const char *Argv0,
if (Verbose)
errs() << "Reading library archive file '" << ArchiveName
<< "' to memory\n";
Error Err = Error::success();
object::Archive Archive(*Buffer, Err);
ExitOnErr(std::move(Err));
Expected<std::unique_ptr<object::Archive>> ArchiveOrError =
object::Archive::create(Buffer->getMemBufferRef());
if (!ArchiveOrError)
ExitOnErr(ArchiveOrError.takeError());

std::unique_ptr<object::Archive> Archive = std::move(ArchiveOrError.get());

Linker L(*Result);
for (const object::Archive::Child &C : Archive.children(Err)) {
Error Err = Error::success();
for (const object::Archive::Child &C : Archive->children(Err)) {
Expected<StringRef> Ename = C.getName();
if (Error E = Ename.takeError()) {
errs() << Argv0 << ": ";
Expand Down

0 comments on commit c38ef55

Please sign in to comment.