[dsymutil] Create the temporary files in the system temp directory.

llvm-dsymutil used to create the temporary files in the output directory.
This works fine except when the output directory contains a '%' char, which
is then replaced by llvm::sys::fs::createUniqueFile() generating an invalid
path.
Just use the default temp dir for those files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268304 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2016-05-02 21:06:14 +00:00
parent c78f77bc6d
commit 85cd66ebbb
2 changed files with 7 additions and 6 deletions

View File

@ -24,9 +24,7 @@ CHECK: DW_AT_name{{.*}} "x86_64h_var"
CHECK: Running lipo
CHECK-NEXT: lipo -create
CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf
CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf
CHECK-SAME: [[INPUTS_PATH]]fat-test.dylib.tmp{{......}}.dwarf
CHECK-SAME [[TMP_PATH:.*?]]fat-test.dylib.tmp{{......}}.dwarf [[TMP_PATH]]fat-test.dylib.tmp{{......}}.dwarf [[TMP_PATH]]fat-test.dylib.tmp{{......}}.dwarf
CHECK-SAME: -segalign x86_64 20 -segalign i386 20 -segalign x86_64h 20
CHECK-SAME: -output [[INPUTS_PATH]]fat-test.dylib.dwarf

View File

@ -176,14 +176,17 @@ static std::error_code getUniqueFile(const llvm::Twine &Model, int &ResultFD,
static std::string getOutputFileName(llvm::StringRef InputFile,
bool TempFile = false) {
if (TempFile) {
llvm::SmallString<128> TmpFile;
llvm::sys::path::system_temp_directory(true, TmpFile);
llvm::StringRef Basename =
OutputFileOpt.empty() ? InputFile : llvm::StringRef(OutputFileOpt);
llvm::Twine OutputFile = Basename + ".tmp%%%%%%.dwarf";
llvm::sys::path::append(TmpFile, llvm::sys::path::filename(Basename));
int FD;
llvm::SmallString<128> UniqueFile;
if (auto EC = getUniqueFile(OutputFile, FD, UniqueFile)) {
if (auto EC = getUniqueFile(TmpFile + ".tmp%%%%%.dwarf", FD, UniqueFile)) {
llvm::errs() << "error: failed to create temporary outfile '"
<< OutputFile << "': " << EC.message() << '\n';
<< TmpFile << "': " << EC.message() << '\n';
return "";
}
llvm::sys::RemoveFileOnSignal(UniqueFile);