[PATCH] D117443: [llvm-ar] -s: don't convert a thin archive to a regular one
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 16 17:07:46 PST 2022
MaskRay created this revision.
MaskRay added reviewers: gbreynoo, jhenderson.
Herald added a subscriber: rupprecht.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In binutils, ar -s and randlib don't convert a thin archive to a regular one.
This behavior makes sense and this patch ports the behavior.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117443
Files:
llvm/test/tools/llvm-ar/symtab.test
llvm/tools/llvm-ar/llvm-ar.cpp
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -965,6 +965,8 @@
if (OldArchive->hasSymbolTable())
return;
+ if (OldArchive->isThin())
+ Thin = true;
performWriteOperation(CreateSymTab, OldArchive, nullptr, nullptr);
}
Index: llvm/test/tools/llvm-ar/symtab.test
===================================================================
--- llvm/test/tools/llvm-ar/symtab.test
+++ llvm/test/tools/llvm-ar/symtab.test
@@ -58,9 +58,23 @@
# RUN: llvm-nm --print-armap %t-thin.a \
# RUN: | FileCheck %s --check-prefix=SYMTAB
+## llvm-ranlib does not change a thin archive to a regular one.
+# RUN: rm -f %t-thin.a && llvm-ar rcTS %t-thin.a %t.o
+# RUN: llvm-nm --print-armap %t-thin.a | FileCheck %s --check-prefix=NO-SYMTAB
+# RUN: llvm-ranlib %t-thin.a
+# RUN: llvm-nm --print-armap %t-thin.a | FileCheck %s --check-prefix=SYMTAB
+# RUN: FileCheck --input-file=%t-thin.a %s --check-prefixes=THIN
+
+## llvm-ar -s is identical to ranlib and a duplicated operation does not change the output.
+# RUN: rm -f %t-thin2.a && llvm-ar rcTS %t-thin2.a %t.o
+# RUN: llvm-ar s %t-thin2.a && cmp %t-thin.a %t-thin2.a
+# RUN: llvm-ar s %t-thin2.a && cmp %t-thin.a %t-thin2.a
+
# SYMTAB: symbol in
# NO-SYMTAB-NOT: symbol in
+# THIN: !<thin>
+
--- !ELF
FileHeader:
Class: ELFCLASS64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117443.400407.patch
Type: text/x-patch
Size: 1435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220117/a82a14fe/attachment.bin>
More information about the llvm-commits
mailing list