From f2cd5dec0a7b7a8e1354e1a905bc48be966909cb Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Fri, 24 Jan 2020 20:16:47 +0100 Subject: [PATCH] Context: move output_is_precompiled_header --- src/ccache.cpp | 10 ++++------ src/ccache.hpp | 2 +- src/legacy_globals.cpp | 3 --- src/legacy_globals.hpp | 2 -- src/manifest.cpp | 2 +- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ccache.cpp b/src/ccache.cpp index 7c85309f8..7d4f5764e 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1047,7 +1047,7 @@ update_manifest_file(Context& ctx) // See comment in get_file_hash_index for why saving of timestamps is forced // for precompiled headers. bool save_timestamp = (ctx.config.sloppiness() & SLOPPY_FILE_STAT_MATCHES) - || output_is_precompiled_header; + || ctx.args_info.output_is_precompiled_header; MTR_BEGIN("manifest", "manifest_put"); cc_log("Adding result name to %s", manifest_path); @@ -1776,7 +1776,7 @@ calculate_result_name(Context& ctx, // hash. The theory is that these arguments will change the output of -E if // they are going to have any effect at all. For precompiled headers this // might not be the case. - if (!direct_mode && !output_is_precompiled_header + if (!direct_mode && !ctx.args_info.output_is_precompiled_header && !ctx.args_info.using_precompiled_header) { if (compopt_affects_cpp(args->argv[i])) { if (compopt_takes_arg(args->argv[i])) { @@ -2040,7 +2040,8 @@ from_cache(Context& ctx, // file 'foo.h' has been modified since the precompiled header 'foo.pch' // was built if ((guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN) - && output_is_precompiled_header && mode == FROMCACHE_CPP_MODE) { + && ctx.args_info.output_is_precompiled_header + && mode == FROMCACHE_CPP_MODE) { cc_log("Not considering cached precompiled header in preprocessor mode"); return; } @@ -3540,7 +3541,6 @@ cc_reset() has_absolute_include_headers = false; i_tmpfile = NULL; free_and_nullify(cpp_stderr); - output_is_precompiled_header = false; } // Make a copy of stderr that will not be cached, so things like distcc can @@ -3684,8 +3684,6 @@ do_cache_compilation(Context& ctx, char* argv[]) failed(); // stats_update is called in cc_process_args. } - output_is_precompiled_header = ctx.args_info.output_is_precompiled_header; - arch_args_size = ctx.args_info.arch_args_size; for (size_t i = 0; i < ctx.args_info.arch_args_size; ++i) { arch_args[i] = x_strdup(ctx.args_info.arch_args[i]); diff --git a/src/ccache.hpp b/src/ccache.hpp index 8d0bf2569..990ec7098 100644 --- a/src/ccache.hpp +++ b/src/ccache.hpp @@ -62,7 +62,7 @@ enum guessed_compiler { #define SLOPPY_MODULES (1U << 9) extern time_t time_of_compilation; -extern bool output_is_precompiled_header; + void block_signals(); void unblock_signals(); bool cc_process_args(Context& ctx, diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp index d856dbd97..468ed6d8e 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -64,9 +64,6 @@ char* cpp_stderr; // The stats file to use for the manifest. char* manifest_stats_file; -// Whether the output is a precompiled header. -bool output_is_precompiled_header = false; - // Compiler guessing is currently only based on the compiler name, so nothing // should hard-depend on it if possible. enum guessed_compiler guessed_compiler = GUESSED_UNKNOWN; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index d3fa54452..fb0bd27c0 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -56,8 +56,6 @@ extern char* cpp_stderr; extern char* manifest_stats_file; -extern bool output_is_precompiled_header; - extern enum guessed_compiler guessed_compiler; extern char* included_pch_file; diff --git a/src/manifest.cpp b/src/manifest.cpp index 07d416b42..965b4f055 100644 --- a/src/manifest.cpp +++ b/src/manifest.cpp @@ -413,7 +413,7 @@ verify_result(const Context& ctx, // and will error out if that header is later used without rebuilding. if ((guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN) - && output_is_precompiled_header && fi.mtime != fs.mtime) { + && ctx.args_info.output_is_precompiled_header && fi.mtime != fs.mtime) { cc_log("Precompiled header includes %s, which has a new mtime", path.c_str()); return false; -- 2.47.2