diff options
author | Devang Patel <dpatel@apple.com> | 2006-10-09 19:04:51 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-10-09 19:04:51 +0000 |
commit | 3f0e5e205772af1529d980cb1fb2c910ef38417c (patch) | |
tree | 5234aee266eb38a589f1070e19583eece8298b4c /tools/lto | |
parent | 0376ade972840217ae708f634509646a15c84b3b (diff) | |
download | external_llvm-3f0e5e205772af1529d980cb1fb2c910ef38417c.zip external_llvm-3f0e5e205772af1529d980cb1fb2c910ef38417c.tar.gz external_llvm-3f0e5e205772af1529d980cb1fb2c910ef38417c.tar.bz2 |
Use GetTemporaryDirectory. Fix http://llvm.org/bugs/show_bug.cgi?id=894
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index cd3cc34..aeced8d 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -341,18 +341,28 @@ LTO::optimizeModules(const std::string &OutputFilename, exportList[i] = allSymbols[name]->getName(); } - sys::Path tmpAsmFilePath("/tmp/"); + std::string ErrMsg; + sys::Path TempDir = sys::Path::GetTemporaryDirectory(&ErrMsg); + sys::Path tmpAsmFilePath(TempDir); + if (!tmpAsmFilePath.appendComponent("lto")) { + std::cerr << "lto: " << ErrMsg << "\n"; + TempDir.eraseFromDisk(true); + return LTO_WRITE_FAILURE; + } if (tmpAsmFilePath.createTemporaryFileOnDisk(&ErrMsg)) { std::cerr << "lto: " << ErrMsg << "\n"; + TempDir.eraseFromDisk(true); return LTO_WRITE_FAILURE; } sys::RemoveFileOnSignal(tmpAsmFilePath); std::ofstream asmFile(tmpAsmFilePath.c_str(), io_mode); if (!asmFile.is_open() || asmFile.bad()) { - if (tmpAsmFilePath.exists()) + if (tmpAsmFilePath.exists()) { tmpAsmFilePath.eraseFromDisk(); + TempDir.eraseFromDisk(true); + } return LTO_WRITE_FAILURE; } @@ -360,6 +370,7 @@ LTO::optimizeModules(const std::string &OutputFilename, asmFile.close(); if (status != LTO_OPT_SUCCESS) { tmpAsmFilePath.eraseFromDisk(); + TempDir.eraseFromDisk(true); return status; } @@ -374,6 +385,7 @@ LTO::optimizeModules(const std::string &OutputFilename, const sys::Path gcc = FindExecutable("gcc", "/"); if (gcc.isEmpty()) { tmpAsmFilePath.eraseFromDisk(); + TempDir.eraseFromDisk(true); return LTO_ASM_FAILURE; } @@ -390,6 +402,7 @@ LTO::optimizeModules(const std::string &OutputFilename, sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1); tmpAsmFilePath.eraseFromDisk(); + TempDir.eraseFromDisk(true); return LTO_OPT_SUCCESS; } |