]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Hash object file directory for MSVC compilers
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 20 Feb 2022 15:26:40 +0000 (16:26 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 20 Feb 2022 15:42:59 +0000 (16:42 +0100)
The object file produced by MSVC includes the full path to the object
file even without debug flags.

src/ccache.cpp

index a822263d0bbdf3b22486a53f82abd78bbefb2d00..5cd02468077e3b1fd5f07d332bb5f1e28ea4987f 100644 (file)
@@ -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) {