summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2008-02-28 22:24:48 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2008-02-28 22:24:48 +0000
commit09b64a4ed1d02585a29571f91fe792ab11c5d14a (patch)
treea2e3c53b000a9663c74f5749b07bb2b5a0c92cf1
parent714eeb2d55703a5bf124efc6a7221f8c9a7814de (diff)
downloadbcm5719-llvm-09b64a4ed1d02585a29571f91fe792ab11c5d14a.tar.gz
bcm5719-llvm-09b64a4ed1d02585a29571f91fe792ab11c5d14a.zip
Make llvm-ar behave like ar, if you create an empty archive, ar creates an empty archive. llvm-ar would not generate an output file in this case
llvm-svn: 47733
-rw-r--r--llvm/lib/Archive/ArchiveWriter.cpp2
-rw-r--r--llvm/tools/llvm-ar/llvm-ar.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Archive/ArchiveWriter.cpp b/llvm/lib/Archive/ArchiveWriter.cpp
index 07f7d88dd82..04cc981f796 100644
--- a/llvm/lib/Archive/ArchiveWriter.cpp
+++ b/llvm/lib/Archive/ArchiveWriter.cpp
@@ -348,7 +348,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
{
// Make sure they haven't opened up the file, not loaded it,
// but are now trying to write it which would wipe out the file.
- if (members.empty() && mapfile->size() > 8) {
+ if (members.empty() && mapfile && mapfile->size() > 8) {
if (ErrMsg)
*ErrMsg = "Can't write an archive not opened for writing";
return true;
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index a72a4c00190..a6611a3e809 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -717,6 +717,7 @@ int main(int argc, char **argv) {
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);
OpenPOWER on IntegriCloud