From cf48cf23de9207e4000df91aadc0beaa0989e33d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 29 Jul 2013 12:40:31 +0000 Subject: Add support for the 's' operation to llvm-ar. If no other operation is specified, 's' becomes an operation instead of an modifier. The s operation just creates a symbol table. It is the same as running ranlib. We assume the archive was created by a sane ar (like llvm-ar or gnu ar) and if the symbol table is present, then it is current. We use that to optimize the most common case: a broken build system that thinks it has to run ranlib. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187353 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-ar/llvm-ar.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tools/llvm-ar') diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 261446cc78..6026fa7cfe 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -112,7 +112,8 @@ enum ArchiveOperation { QuickAppend, ///< Quickly append to end of archive ReplaceOrInsert, ///< Replace or Insert members DisplayTable, ///< Display the table of contents - Extract ///< Extract files back to file system + Extract, ///< Extract files back to file system + CreateSymTab ///< Create a symbol table in an existing archive }; // Modifiers to follow operation to vary behavior @@ -186,6 +187,8 @@ static ArchiveOperation parseCommandLine() { // Keep track of which operation was requested ArchiveOperation Operation; + bool MaybeJustCreateSymTab = false; + for(unsigned i=0; ihasSymbolTable()) + return; + + performWriteOperation(CreateSymTab, OldArchive); +} + static void performOperation(ArchiveOperation Operation, object::Archive *OldArchive) { switch (Operation) { @@ -825,6 +850,9 @@ static void performOperation(ArchiveOperation Operation, case ReplaceOrInsert: performWriteOperation(Operation, OldArchive); return; + case CreateSymTab: + createSymbolTable(OldArchive); + return; } llvm_unreachable("Unknown operation."); } -- cgit v1.2.3