[PATCH] D116979: [llvm-ar] Add --thin for creating a thin archive

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 10 15:49:02 PST 2022


MaskRay updated this revision to Diff 398764.
MaskRay marked an inline comment as done.
MaskRay added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116979/new/

https://reviews.llvm.org/D116979

Files:
  llvm/test/tools/llvm-ar/thin-archive.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
@@ -90,6 +90,7 @@
   --rsp-quoting         - quoting style for response files
     =posix              -   posix
     =windows            -   windows
+  --thin                - create a thin archive
   --version             - print the version and exit
   @<file>               - read options from <file>
 
@@ -118,7 +119,7 @@
   [P] - use full names when matching (implied for thin archives)
   [s] - create an archive index (cf. ranlib)
   [S] - do not build a symbol table
-  [T] - create a thin archive
+  [T] - deprecated, use --thin instead
   [u] - update only [files] newer than archive contents
   [U] - use actual timestamps and uids/gids
   [v] - be verbose about actions taken
@@ -390,8 +391,6 @@
       break;
     case 'T':
       Thin = true;
-      // Thin archives store path names, so P should be forced.
-      CompareFullPath = true;
       break;
     case 'L':
       AddLibrary = true;
@@ -407,6 +406,10 @@
     }
   }
 
+  // Thin archives store path names, so P should be forced.
+  if (Thin)
+    CompareFullPath = true;
+
   // At this point, the next thing on the command line must be
   // the archive name.
   getArchive();
@@ -1197,6 +1200,11 @@
       continue;
     }
 
+    if (strcmp(*ArgIt, "--thin") == 0) {
+      Thin = true;
+      continue;
+    }
+
     Match = matchFlagWithArg("format", ArgIt, Argv);
     if (Match) {
       FormatType = StringSwitch<Format>(Match)
Index: llvm/test/tools/llvm-ar/thin-archive.test
===================================================================
--- llvm/test/tools/llvm-ar/thin-archive.test
+++ llvm/test/tools/llvm-ar/thin-archive.test
@@ -6,11 +6,15 @@
 
 Test that modules can be added with absolute paths when the archive is created using an absolute path
 
-RUN: llvm-ar rTc %t/absolute-1.ar %t/foo/elf.o %t/delete.o %t/foo/bar/elf.o
-RUN: llvm-ar dT %t/absolute-1.ar delete.o
+RUN: llvm-ar rc --thin %t/absolute-1a.ar %t/foo/elf.o %t/delete.o %t/foo/bar/elf.o
+RUN: llvm-ar --thin d %t/absolute-1a.ar delete.o
 
-RUN: FileCheck -input-file=%t/absolute-1.ar --check-prefixes=THIN,CHECK %s -DPATH=%/t/
-RUN: llvm-ar t %t/absolute-1.ar | FileCheck %s -DPATH=%/t/
+RUN: FileCheck --input-file=%t/absolute-1a.ar --check-prefixes=THIN,CHECK %s -DPATH=%/t/
+RUN: llvm-ar t %t/absolute-1a.ar | FileCheck %s -DPATH=%/t/
+
+RUN: llvm-ar rTc %t/absolute-1b.ar %t/foo/elf.o %t/delete.o %t/foo/bar/elf.o
+RUN: llvm-ar dT %t/absolute-1b.ar delete.o
+RUN: cmp %t/absolute-1a.ar %t/absolute-1b.ar
 
 These tests must be run in %t/foo. cd %t is included on each line to make debugging this test case easier.
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116979.398764.patch
Type: text/x-patch
Size: 2758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220110/232265c0/attachment.bin>


More information about the llvm-commits mailing list