diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-03-22 20:57:13 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-03-22 20:57:13 +0000 |
commit | 6421a8815e14189121a5e20731fd005ea08793e1 (patch) | |
tree | 9bac7d62f3d88e0b1902b72db8b951782135aabe /tools/gold | |
parent | 97ab5803df4a549db9cd93e80426971e64562672 (diff) | |
download | external_llvm-6421a8815e14189121a5e20731fd005ea08793e1.zip external_llvm-6421a8815e14189121a5e20731fd005ea08793e1.tar.gz external_llvm-6421a8815e14189121a5e20731fd005ea08793e1.tar.bz2 |
Add a lto_codegen_compile_to_file to avoid producing a file, reading it to
memory and writing it back to disk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128108 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gold')
-rw-r--r-- | tools/gold/gold-plugin.cpp | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 7aa8c91..ce85789 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -398,38 +398,10 @@ static ld_plugin_status all_symbols_read_hook(void) { exit(0); } size_t bufsize = 0; - const char *buffer = static_cast<const char *>(lto_codegen_compile(code_gen, - &bufsize)); - - std::string ErrMsg; - const char *objPath; - sys::Path uniqueObjPath("/tmp/llvmgold.o"); - if (!options::obj_path.empty()) { - objPath = options::obj_path.c_str(); - } else { - if (uniqueObjPath.createTemporaryFileOnDisk(true, &ErrMsg)) { - (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); - return LDPS_ERR; - } - objPath = uniqueObjPath.c_str(); - } - tool_output_file objFile(objPath, ErrMsg, - raw_fd_ostream::F_Binary); - if (!ErrMsg.empty()) { - (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); - return LDPS_ERR; - } - - objFile.os().write(buffer, bufsize); - objFile.os().close(); - if (objFile.os().has_error()) { - (*message)(LDPL_ERROR, "Error writing output file '%s'", - objPath); - objFile.os().clear_error(); - return LDPS_ERR; + if (lto_codegen_compile_to_file(code_gen, &objPath)) { + (*message)(LDPL_ERROR, "Could not produce a combined object file\n"); } - objFile.keep(); lto_codegen_dispose(code_gen); for (std::list<claimed_file>::iterator I = Modules.begin(), |