From bd126df21fdbd1338a5e3065f8cca8a1655f99a9 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Mon, 2 May 2016 21:06:14 +0000 Subject: [PATCH] [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. llvm-svn: 268304 --- llvm/test/tools/dsymutil/fat-binary-output.test | 4 +--- llvm/tools/dsymutil/dsymutil.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/test/tools/dsymutil/fat-binary-output.test b/llvm/test/tools/dsymutil/fat-binary-output.test index fafef14ebe9b..94345a893e63 100644 --- a/llvm/test/tools/dsymutil/fat-binary-output.test +++ b/llvm/test/tools/dsymutil/fat-binary-output.test @@ -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 diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index e9ee57f3dee6..aeb0fd2074ef 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -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);