From cfaa636a1d31f2db71df627e4882e9d5c066c419 Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Mon, 12 Aug 2013 21:07:31 +0000 Subject: Revert r188188 and r188200. In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. Thank Eric for fixing a compile-warning. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188204 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/gold/gold-plugin.cpp | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'tools/gold') diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 7918324702..77717098d6 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -74,6 +74,7 @@ namespace options { static bool generate_api_file = false; static generate_bc generate_bc_file = BC_NO; static std::string bc_path; + static std::string obj_path; static std::string extra_library_path; static std::string triple; static std::string mcpu; @@ -98,6 +99,8 @@ namespace options { extra_library_path = opt.substr(strlen("extra_library_path=")); } else if (opt.startswith("mtriple=")) { triple = opt.substr(strlen("mtriple=")); + } else if (opt.startswith("obj-path=")) { + obj_path = opt.substr(strlen("obj-path=")); } else if (opt == "emit-llvm") { generate_bc_file = BC_ONLY; } else if (opt == "also-emit-llvm") { @@ -422,14 +425,6 @@ static ld_plugin_status all_symbols_read_hook(void) { (*message)(LDPL_ERROR, "Could not produce a combined object file\n"); } - // Get files that need to be removed in cleanup_hook. - const char *ToRm; - lto_codegen_get_files_need_remove(code_gen, &ToRm); - while (*ToRm) { - Cleanup.push_back(std::string(ToRm)); - ToRm += strlen(ToRm) + 1; - } - lto_codegen_dispose(code_gen); for (std::list::iterator I = Modules.begin(), E = Modules.end(); I != E; ++I) { @@ -451,28 +446,17 @@ static ld_plugin_status all_symbols_read_hook(void) { return LDPS_ERR; } + if (options::obj_path.empty()) + Cleanup.push_back(objPath); + return LDPS_OK; } static ld_plugin_status cleanup_hook(void) { for (int i = 0, e = Cleanup.size(); i != e; ++i) { - const char *FN = Cleanup[i].c_str(); - sys::fs::file_status Stat; - error_code EC = sys::fs::status(Twine(FN), Stat); - if (EC) { - (*message)(LDPL_ERROR, "Failed to stat '%s': %s", FN, - EC.message().c_str()); - continue; - } - - uint32_t Dummy; - if (sys::fs::is_directory(FN)) - EC = sys::fs::remove_all(Twine(FN), Dummy); - else - EC = sys::fs::remove(Twine(FN)); - + error_code EC = sys::fs::remove(Cleanup[i]); if (EC) - (*message)(LDPL_ERROR, "Failed to remove '%s': %s", FN, + (*message)(LDPL_ERROR, "Failed to delete '%s': %s", Cleanup[i].c_str(), EC.message().c_str()); } -- cgit v1.2.3