From: Joel Rosdahl Date: Tue, 9 Jan 2024 20:28:34 +0000 (+0100) Subject: chore: Remove time_of_compilation in favor of time_of_invocation X-Git-Tag: v4.10~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b982306349e5ba3229d1ea9c14ff4ce2efb18233;p=thirdparty%2Fccache.git chore: Remove time_of_compilation in favor of time_of_invocation We can compare source/include files against time of invocation just as well; source files shouldn't be modified when ccache has started anyway. --- diff --git a/src/Context.cpp b/src/Context.cpp index fcf3a1343..47f9407e0 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2023 Joel Rosdahl and other contributors +// Copyright (C) 2020-2024 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -41,13 +41,12 @@ Context::Context() : actual_cwd(util::actual_cwd()), apparent_cwd(util::apparent_cwd(actual_cwd)), - storage(config) + storage(config), #ifdef INODE_CACHE_SUPPORTED - , - inode_cache(config) + inode_cache(config), #endif + time_of_invocation(util::TimePoint::now()) { - time_of_invocation = util::TimePoint::now(); } void diff --git a/src/Context.hpp b/src/Context.hpp index 51b4787b8..e06da471a 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2023 Joel Rosdahl and other contributors +// Copyright (C) 2020-2024 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -67,13 +67,6 @@ public: // The original argument list. Args orig_args; - // Time of ccache invocation. - util::TimePoint time_of_invocation; - - // Time of compilation. Used to see if include files have changed after - // compilation. - util::TimePoint time_of_compilation; - // Files included by the preprocessor and their hashes. std::unordered_map included_files; @@ -100,6 +93,9 @@ public: mutable InodeCache inode_cache; #endif + // Time of ccache invocation. + util::TimePoint time_of_invocation; + // PID of currently executing compiler that we have started, if any. 0 means // no ongoing compilation. pid_t compiler_pid = 0; diff --git a/src/ccache.cpp b/src/ccache.cpp index 68ea3c685..e472a4b75 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -313,14 +313,14 @@ include_file_too_new(const Context& ctx, // starting compilation and writing the include file. See also the notes under // "Performance" in doc/MANUAL.adoc. if (!(ctx.config.sloppiness().contains(core::Sloppy::include_file_mtime)) - && dir_entry.mtime() >= ctx.time_of_compilation) { + && dir_entry.mtime() >= ctx.time_of_invocation) { LOG("Include file {} too new", path); return true; } // The same >= logic as above applies to the change time of the file. if (!(ctx.config.sloppiness().contains(core::Sloppy::include_file_ctime)) - && dir_entry.ctime() >= ctx.time_of_compilation) { + && dir_entry.ctime() >= ctx.time_of_invocation) { LOG("Include file {} ctime too new", path); return true; } @@ -872,7 +872,7 @@ update_manifest(Context& ctx, MTR_SCOPE("manifest", "manifest_put"); - // ctime() may be 0, so we have to check time_of_compilation against + // ctime() may be 0, so we have to check time_of_invocation against // MAX(mtime, ctime). // // ccache only reads mtime/ctime if file_stat_matches sloppiness is enabled, @@ -887,7 +887,7 @@ update_manifest(Context& ctx, DirEntry de(path, DirEntry::LogOnError::yes); bool cache_time = save_timestamp - && ctx.time_of_compilation > std::max(de.mtime(), de.ctime()); + && ctx.time_of_invocation > std::max(de.mtime(), de.ctime()); return core::Manifest::FileStats{ de.size(), de.is_regular_file() && cache_time ? de.mtime() : util::TimePoint(), @@ -1139,7 +1139,6 @@ to_cache(Context& ctx, depend_mode_args.insert(1, depend_extra_args); add_prefix(ctx, depend_mode_args, ctx.config.prefix_command()); - ctx.time_of_compilation = util::TimePoint::now(); result = do_execute(ctx, depend_mode_args); } MTR_END("execute", "compiler"); @@ -1239,8 +1238,6 @@ to_cache(Context& ctx, static tl::expected get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash) { - ctx.time_of_compilation = util::TimePoint::now(); - std::string preprocessed_path; util::Bytes cpp_stderr_data;