//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Builds up (relatively) standard unix archive files (.a) containing LLVM
-// bytecode or other files.
+// bitcode or other files.
//
//===----------------------------------------------------------------------===//
#include "llvm/Module.h"
-#include "llvm/Bytecode/Archive.h"
+#include "llvm/Bitcode/Archive.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Compressor.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/System/Signals.h"
#include <iostream>
#include <memory>
using namespace llvm;
-// Option for compatibility with ASIX, not used but must allow it to be present.
+// Option for compatibility with AIX, not used but must allow it to be present.
static cl::opt<bool>
X32Option ("X32_64", cl::Hidden,
cl::desc("Ignored option for compatibility with AIX"));
" [b] - put file(s) before [relpos] (same as [i])\n"
" [f] - truncate inserted file names\n"
" [i] - put file(s) before [relpos] (same as [b])\n"
- " [k] - always print bytecode files (default is to skip them)\n"
+ " [k] - always print bitcode files (default is to skip them)\n"
" [N] - use instance [count] of name\n"
" [o] - preserve original dates\n"
" [P] - use full path names when matching\n"
bool Create = false; ///< 'c' modifier
bool TruncateNames = false; ///< 'f' modifier
bool InsertBefore = false; ///< 'i' modifier
-bool DontSkipBytecode = false; ///< 'k' modifier
+bool DontSkipBitcode = false; ///< 'k' modifier
bool UseCount = false; ///< 'N' modifier
bool OriginalDates = false; ///< 'o' modifier
bool FullPath = false; ///< 'P' modifier
case 'd': ++NumOperations; Operation = Delete; break;
case 'm': ++NumOperations; Operation = Move ; break;
case 'p': ++NumOperations; Operation = Print; break;
+ case 'q': ++NumOperations; Operation = QuickAppend; break;
case 'r': ++NumOperations; Operation = ReplaceOrInsert; break;
case 't': ++NumOperations; Operation = DisplayTable; break;
case 'x': ++NumOperations; Operation = Extract; break;
case 'c': Create = true; break;
case 'f': TruncateNames = true; break;
- case 'k': DontSkipBytecode = true; break;
+ case 'k': DontSkipBitcode = true; break;
case 'l': /* accepted but unused */ break;
case 'o': OriginalDates = true; break;
case 'P': FullPath = true; break;
for (std::set<sys::Path>::iterator I = content.begin(), E = content.end();
I != E; ++I) {
// Make sure it exists and is a directory
- const sys::FileStatus *Status = I->getFileStatus(false, ErrMsg);
+ sys::PathWithStatus PwS(*I);
+ const sys::FileStatus *Status = PwS.getFileStatus(false, ErrMsg);
if (!Status)
return true;
if (Status->isDir) {
if (!aPath.exists())
throw std::string("File does not exist: ") + Members[i];
std::string Err;
- const sys::FileStatus *si = aPath.getFileStatus(false, &Err);
+ sys::PathWithStatus PwS(aPath);
+ const sys::FileStatus *si = PwS.getFileStatus(false, &Err);
if (!si)
throw Err;
if (si->isDir) {
// doPrint - Implements the 'p' operation. This function traverses the archive
// looking for members that match the path list. It is careful to uncompress
-// things that should be and to skip bytecode files unless the 'k' modifier was
+// things that should be and to skip bitcode files unless the 'k' modifier was
// given.
bool doPrint(std::string* ErrMsg) {
if (buildPaths(false, ErrMsg))
// Skip things that don't make sense to print
if (I->isLLVMSymbolTable() || I->isSVR4SymbolTable() ||
- I->isBSD4SymbolTable() || (!DontSkipBytecode &&
- (I->isBytecode() || I->isCompressedBytecode())))
+ I->isBSD4SymbolTable() || (!DontSkipBitcode && I->isBitcode()))
continue;
if (Verbose)
std::cout << "Printing " << I->getPath().toString() << "\n";
- if (I->isCompressedBytecode())
- Compressor::decompressToStream(data+4,I->getSize()-4,std::cout);
- else if (I->isCompressed()) {
- Compressor::decompressToStream(data,I->getSize(),std::cout);
- } else {
- unsigned len = I->getSize();
- std::cout.write(data, len);
- }
+ unsigned len = I->getSize();
+ std::cout.write(data, len);
} else {
countDown--;
}
if (Verbose) {
// FIXME: Output should be this format:
// Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile
- if (I->isBytecode())
+ if (I->isBitcode())
std::cout << "b";
- else if (I->isCompressedBytecode())
- std::cout << "B";
else if (I->isCompressed())
std::cout << "Z";
else
const char* data = reinterpret_cast<const char*>(I->getData());
unsigned len = I->getSize();
- // Write the data, making sure to uncompress things first
- if (I->isCompressed()) {
- Compressor::decompressToStream(data,len,file);
- } else {
- file.write(data,len);
- }
+ // Write the data.
+ file.write(data,len);
file.close();
// If we're supposed to retain the original modification times, etc. do so
if (found != remaining.end()) {
std::string Err;
- const sys::FileStatus *si = found->getFileStatus(false, &Err);
+ sys::PathWithStatus PwS(*found);
+ const sys::FileStatus *si = PwS.getFileStatus(false, &Err);
if (!si)
return true;
if (si->isDir) {
// Have the command line options parsed and handle things
// like --help and --version.
cl::ParseCommandLineOptions(argc, argv,
- " LLVM Archiver (llvm-ar)\n\n"
- " This program archives bytecode files into single libraries\n"
+ "LLVM Archiver (llvm-ar)\n\n"
+ " This program archives bitcode files into single libraries\n"
);
// Print a stack trace if we signal out.
if (!Create)
std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
TheArchive = Archive::CreateEmpty(ArchivePath);
+ TheArchive->writeToDisk();
} else {
std::string Error;
TheArchive = Archive::OpenAndLoad(ArchivePath, &Error);