From d579c31d684678d2bf136cc8253616bb616bd5f6 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 28 Mar 2018 17:21:14 +0000 Subject: [llvm-ar] Support multiple dashed options This allows syntax like: $ llvm-ar -c -r -u file.a file.o This is in addition to the other formats that are already supported: $ llvm-ar cru file.a file.o $ llvm-ar -cru file.a file.o Patch by Tom Anderson! Differential Revision: https://reviews.llvm.org/D44452 llvm-svn: 328716 --- llvm/lib/Object/ArchiveWriter.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Object/ArchiveWriter.cpp') diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index b3b812daae2..28955e18357 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -35,15 +35,6 @@ using namespace llvm; -// The SYM64 format is used when an archive's member offsets are larger than -// 32-bits can hold. The need for this shift in format is detected by -// writeArchive. To test this we need to generate a file with a member that has -// an offset larger than 32-bits but this demands a very slow test. To speed -// the test up we use this flag to pretend like the cutoff happens before -// 32-bits and instead happens at some much smaller value. -static cl::opt Sym64Threshold("sym64-threshold", cl::Hidden, - cl::init(32)); - NewArchiveMember::NewArchiveMember(MemoryBufferRef BufRef) : Buf(MemoryBuffer::getMemBuffer(BufRef, false)), MemberName(BufRef.getBufferIdentifier()) {} @@ -490,6 +481,19 @@ Error llvm::writeArchive(StringRef ArcName, // We assume 32-bit symbols to see if 32-bit symbols are possible or not. MaxOffset += M.Symbols.size() * 4; } + + // The SYM64 format is used when an archive's member offsets are larger than + // 32-bits can hold. The need for this shift in format is detected by + // writeArchive. To test this we need to generate a file with a member that + // has an offset larger than 32-bits but this demands a very slow test. To + // speed the test up we use this environment variable to pretend like the + // cutoff happens before 32-bits and instead happens at some much smaller + // value. + const char *Sym64Env = std::getenv("SYM64_THRESHOLD"); + int Sym64Threshold = 32; + if (Sym64Env) + StringRef(Sym64Env).getAsInteger(10, Sym64Threshold); + // If LastOffset isn't going to fit in a 32-bit varible we need to switch // to 64-bit. Note that the file can be larger than 4GB as long as the last // member starts before the 4GB offset. -- cgit v1.2.3