From: Thomas Otto Date: Fri, 24 Jan 2020 19:11:24 +0000 (+0100) Subject: Context: move profile_dir X-Git-Tag: v4.0~622^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=01ff8f63ed48822a8fadd3cc98bbcaf9b69b1e00;p=thirdparty%2Fccache.git Context: move profile_dir --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 97daf2209..688271759 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1678,8 +1678,8 @@ hash_common_info(Context& ctx, // Possibly hash the coverage data file path. if (ctx.args_info.generating_coverage && ctx.args_info.profile_arcs) { char* dir = x_dirname(ctx.args_info.output_obj.c_str()); - if (profile_dir) { - dir = x_strdup(profile_dir); + if (!ctx.args_info.profile_dir.empty()) { + dir = x_strdup(ctx.args_info.profile_dir.c_str()); } else { char* real_dir = x_realpath(dir); free(dir); @@ -1926,21 +1926,23 @@ calculate_result_name(Context& ctx, // The profile directory can be specified as an argument to // -fprofile-generate=, -fprofile-use= or -fprofile-dir=. if (profile_generate) { - if (!profile_dir) { - profile_dir = get_cwd(); + if (ctx.args_info.profile_dir.empty()) { + ctx.args_info.profile_dir = from_cstr(get_cwd()); } - cc_log("Adding profile directory %s to our hash", profile_dir); + cc_log("Adding profile directory %s to our hash", + ctx.args_info.profile_dir.c_str()); hash_delimiter(hash, "-fprofile-dir"); - hash_string(hash, profile_dir); + hash_string(hash, ctx.args_info.profile_dir); } if (profile_use) { // Calculate gcda name. - if (!profile_dir) { - profile_dir = get_cwd(); + if (ctx.args_info.profile_dir.empty()) { + ctx.args_info.profile_dir = from_cstr(get_cwd()); } string_view base_name = Util::remove_extension(ctx.args_info.output_obj); - std::string gcda_name = fmt::format("{}/{}.gcda", profile_dir, base_name); + std::string gcda_name = + fmt::format("{}/{}.gcda", ctx.args_info.profile_dir, base_name); cc_log("Adding profile data %s to our hash", gcda_name.c_str()); // Add the gcda to our hash. hash_delimiter(hash, "-fprofile-use"); @@ -3550,7 +3552,6 @@ cc_reset(void) g_config.clear_and_reset(); free_and_nullify(current_working_dir); - free_and_nullify(profile_dir); free_and_nullify(included_pch_file); args_free(orig_args); orig_args = NULL; @@ -3704,8 +3705,6 @@ do_cache_compilation(Context& ctx, char* argv[]) failed(); // stats_update is called in cc_process_args. } - profile_dir = x_strdup(ctx.args_info.profile_dir.c_str()); - direct_i_file = ctx.args_info.direct_i_file; output_is_precompiled_header = ctx.args_info.output_is_precompiled_header; profile_use = ctx.args_info.profile_use; diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp index 58aa78298..06d51a762 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -58,9 +58,6 @@ char** ignore_headers; // Size of headers to ignore list. size_t ignore_headers_len; -// Name of the custom profile directory (default: object dirname). -char* profile_dir; - // The name of the temporary preprocessed file. char* i_tmpfile; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index 831f3c8ca..2e5208278 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -54,8 +54,6 @@ extern char** ignore_headers; extern size_t ignore_headers_len; -extern char* profile_dir; - extern char* i_tmpfile; extern bool direct_i_file; diff --git a/unittest/test_argument_processing.cpp b/unittest/test_argument_processing.cpp index f8b5fe318..914e771ef 100644 --- a/unittest/test_argument_processing.cpp +++ b/unittest/test_argument_processing.cpp @@ -84,8 +84,6 @@ cc_process_args(Context& ctx, extra_args_to_hash, compiler_args); - profile_dir = x_strdup(ctx.args_info.profile_dir.c_str()); - direct_i_file = ctx.args_info.direct_i_file; output_is_precompiled_header = ctx.args_info.output_is_precompiled_header; profile_use = ctx.args_info.profile_use;