llvm.org GIT mirror llvm / 3f0e5e2
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 Devang Patel 13 years ago
1 changed file(s) with 15 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
340340 exportList[i] = allSymbols[name]->getName();
341341 }
342342
343 sys::Path tmpAsmFilePath("/tmp/");
343
344344 std::string ErrMsg;
345 sys::Path TempDir = sys::Path::GetTemporaryDirectory(&ErrMsg);
346 sys::Path tmpAsmFilePath(TempDir);
347 if (!tmpAsmFilePath.appendComponent("lto")) {
348 std::cerr << "lto: " << ErrMsg << "\n";
349 TempDir.eraseFromDisk(true);
350 return LTO_WRITE_FAILURE;
351 }
345352 if (tmpAsmFilePath.createTemporaryFileOnDisk(&ErrMsg)) {
346353 std::cerr << "lto: " << ErrMsg << "\n";
354 TempDir.eraseFromDisk(true);
347355 return LTO_WRITE_FAILURE;
348356 }
349357 sys::RemoveFileOnSignal(tmpAsmFilePath);
350358
351359 std::ofstream asmFile(tmpAsmFilePath.c_str(), io_mode);
352360 if (!asmFile.is_open() || asmFile.bad()) {
353 if (tmpAsmFilePath.exists())
361 if (tmpAsmFilePath.exists()) {
354362 tmpAsmFilePath.eraseFromDisk();
363 TempDir.eraseFromDisk(true);
364 }
355365 return LTO_WRITE_FAILURE;
356366 }
357367
359369 asmFile.close();
360370 if (status != LTO_OPT_SUCCESS) {
361371 tmpAsmFilePath.eraseFromDisk();
372 TempDir.eraseFromDisk(true);
362373 return status;
363374 }
364375
373384 const sys::Path gcc = FindExecutable("gcc", "/");
374385 if (gcc.isEmpty()) {
375386 tmpAsmFilePath.eraseFromDisk();
387 TempDir.eraseFromDisk(true);
376388 return LTO_ASM_FAILURE;
377389 }
378390
389401 sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1);
390402
391403 tmpAsmFilePath.eraseFromDisk();
404 TempDir.eraseFromDisk(true);
392405
393406 return LTO_OPT_SUCCESS;
394407 }