diff options
Diffstat (limited to 'tools/gold/gold-plugin.cpp')
-rw-r--r-- | tools/gold/gold-plugin.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 724e93cb8c74..68c9d1a6f6e4 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -787,15 +787,20 @@ static void codegen(Module &M) { 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) @@ -816,7 +821,7 @@ static void codegen(Module &M) { "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()); } |