From: Joel Rosdahl Date: Sun, 20 Feb 2022 15:26:40 +0000 (+0100) Subject: fix: Hash object file directory for MSVC compilers X-Git-Tag: v4.6~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6cde83fb7c4084304bef1dea185d127d8b614a19;p=thirdparty%2Fccache.git fix: Hash object file directory for MSVC compilers The object file produced by MSVC includes the full path to the object file even without debug flags. --- diff --git a/src/ccache.cpp b/src/ccache.cpp index a822263d0..5cd024680 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1362,6 +1362,19 @@ hash_common_info(const Context& ctx, hash.hash(dir_to_hash); } + // The object file produced by MSVC includes the full path to the object file + // even without debug flags. Hashing the directory should be enough since the + // filename is included in the hash anyway. + if (ctx.config.is_compiler_group_msvc() && ctx.config.hash_dir()) { + const std::string output_obj_dir = + util::is_absolute_path(args_info.output_obj) + ? std::string(Util::dir_name(args_info.output_obj)) + : ctx.actual_cwd; + LOG("Hashing object file directory {}", output_obj_dir); + hash.hash_delimiter("source path"); + hash.hash(output_obj_dir); + } + if ((!should_rewrite_dependency_target(ctx.args_info) && ctx.args_info.generating_dependencies) || ctx.args_info.seen_split_dwarf || ctx.args_info.profile_arcs) {