Index: test/tools/llvm-ar/mri-thin-archive.test =================================================================== --- test/tools/llvm-ar/mri-thin-archive.test +++ test/tools/llvm-ar/mri-thin-archive.test @@ -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: ! +CHECK: elf.o +CHECK-NEXT: addlib/elf.o/ +CHECK-NOT: delete.o Index: tools/llvm-ar/llvm-ar.cpp =================================================================== --- tools/llvm-ar/llvm-ar.cpp +++ tools/llvm-ar/llvm-ar.cpp @@ -952,7 +952,7 @@ } 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> Buf = MemoryBuffer::getSTDIN(); failIfError(Buf.getError()); @@ -976,6 +976,7 @@ .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 @@ case MRICommand::AddMod: addMember(NewMembers, Rest); break; + case MRICommand::CreateThin: + Thin = true; + LLVM_FALLTHROUGH; case MRICommand::Create: Create = true; if (!ArchiveName.empty())