legacy::PassManager CodeGenPasses;
SmallString<128> Filename;
+ if (!options::obj_path.empty())
+ Filename = options::obj_path;
+ else if (options::TheOutputType == options::OT_SAVE_TEMPS)
+ Filename = output_name + ".o";
+
int FD;
- if (options::obj_path.empty()) {
+ bool TempOutFile = Filename.empty();
+ if (TempOutFile) {
std::error_code EC =
sys::fs::createTemporaryFile("lto-llvm", "o", FD, Filename);
if (EC)
message(LDPL_FATAL, "Could not create temporary file: %s",
EC.message().c_str());
} else {
- Filename = options::obj_path;
std::error_code EC =
sys::fs::openFileForWrite(Filename.c_str(), FD, sys::fs::F_None);
if (EC)
"Unable to add .o file to the link. File left behind in: %s",
Filename.c_str());
- if (options::obj_path.empty())
+ if (TempOutFile)
Cleanup.push_back(Filename.c_str());
}