[llvm] c38ef55 - [AIX] llvm-link support big archive.
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 13:29:34 PDT 2022
Author: zhijian
Date: 2022-05-16T16:29:16-04:00
New Revision: c38ef550de81631641cb1485e0641d1d2227dce4
URL: https://github.com/llvm/llvm-project/commit/c38ef550de81631641cb1485e0641d1d2227dce4
DIFF: https://github.com/llvm/llvm-project/commit/c38ef550de81631641cb1485e0641d1d2227dce4.diff
LOG: [AIX] llvm-link support big archive.
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
Added:
Modified:
llvm/test/tools/llvm-link/archivell.ll
llvm/tools/llvm-link/llvm-link.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-link/archivell.ll b/llvm/test/tools/llvm-link/archivell.ll
index e8e40a2a572e6..5a90990d46639 100644
--- a/llvm/test/tools/llvm-link/archivell.ll
+++ b/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
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 9abe8efaa4e88..1c09eb581f2be 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -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 << ": ";
More information about the llvm-commits
mailing list