[llvm] r362704 - [llvm-ar] Create thin archives with MRI scripts
Owen Reynolds via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 06:19:50 PDT 2019
Author: gbreynoo
Date: Thu Jun 6 06:19:50 2019
New Revision: 362704
URL: http://llvm.org/viewvc/llvm-project?rev=362704&view=rev
Log:
[llvm-ar] Create thin archives with MRI scripts
This patch implements the "CREATE_THIN" MRI script command, allowing thin archives to be created via MRI scripts.
Differential Revision: https://reviews.llvm.org/D62919
Added:
llvm/trunk/test/tools/llvm-ar/mri-thin-archive.test
Modified:
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Added: llvm/trunk/test/tools/llvm-ar/mri-thin-archive.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-thin-archive.test?rev=362704&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-thin-archive.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-thin-archive.test Thu Jun 6 06:19:50 2019
@@ -0,0 +1,23 @@
+RUN: rm -rf %t && mkdir -p %t/addlib/
+
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o
+RUN: cp %t/elf.o %t/addlib/elf.o
+RUN: cp %t/elf.o %t/delete.o
+
+RUN: cd %t && llvm-ar rTc addlib/addlib.ar addlib/elf.o
+
+RUN: echo "createthin %t/archive.ar" > %t/mri.script
+RUN: echo "addmod elf.o" >> %t/mri.script
+RUN: echo "addlib addlib/addlib.ar" >> %t/mri.script
+RUN: echo "addmod delete.o" >> %t/mri.script
+RUN: echo "delete delete.o" >> %t/mri.script
+RUN: echo "save" >> %t/mri.script
+RUN: echo "end" >> %t/mri.script
+
+RUN: cd %t && llvm-ar -M < mri.script
+RUN: FileCheck -input-file=%t/archive.ar %s
+
+CHECK: !<thin>
+CHECK: elf.o
+CHECK-NEXT: addlib/elf.o/
+CHECK-NOT: delete.o
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=362704&r1=362703&r2=362704&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Jun 6 06:19:50 2019
@@ -952,7 +952,7 @@ static int performOperation(ArchiveOpera
}
static void runMRIScript() {
- enum class MRICommand { AddLib, AddMod, Create, Delete, Save, End, Invalid };
+ enum class MRICommand { AddLib, AddMod, Create, CreateThin, Delete, Save, End, Invalid };
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getSTDIN();
failIfError(Buf.getError());
@@ -976,6 +976,7 @@ static void runMRIScript() {
.Case("addlib", MRICommand::AddLib)
.Case("addmod", MRICommand::AddMod)
.Case("create", MRICommand::Create)
+ .Case("createthin", MRICommand::CreateThin)
.Case("delete", MRICommand::Delete)
.Case("save", MRICommand::Save)
.Case("end", MRICommand::End)
@@ -995,6 +996,9 @@ static void runMRIScript() {
case MRICommand::AddMod:
addMember(NewMembers, Rest);
break;
+ case MRICommand::CreateThin:
+ Thin = true;
+ LLVM_FALLTHROUGH;
case MRICommand::Create:
Create = true;
if (!ArchiveName.empty())
More information about the llvm-commits
mailing list