Fixes problem when calling llvm-ar from an unmodifiable directory.
authorManuel Klimek <klimek@google.com>
Mon, 8 Jul 2013 14:44:57 +0000 (14:44 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 8 Jul 2013 14:44:57 +0000 (14:44 +0000)
This fixes a regression introduced by r185726: the new call to get
a unique file does not prepend the system temporary directory, so
we need to anchor on the file that the temporary file gets moved
to to ensure we're on the same file system.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185825 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-ar/ArchiveWriter.cpp

index 52ce045c16c2acd55ff7de2fc3faab36f6038bfc..ef910019df40319e53b7a79a69c50113091e9b61 100644 (file)
@@ -260,8 +260,8 @@ bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) {
   // Create a temporary file to store the archive in
   int TmpArchiveFD;
   SmallString<128> TmpArchive;
-  error_code EC = sys::fs::createUniqueFile("temp-archive-%%%%%%%.a",
-                                            TmpArchiveFD, TmpArchive);
+  error_code EC = sys::fs::createUniqueFile(
+      archPath + ".temp-archive-%%%%%%%.a", TmpArchiveFD, TmpArchive);
   if (EC)
     return true;