]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Invalidate PCH upon MSVC toolset update (#1714)
authorPhilipp Kolberg <39984529+PKizzle@users.noreply.github.com>
Tue, 31 Mar 2026 17:32:21 +0000 (19:32 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2026 17:32:21 +0000 (19:32 +0200)
src/ccache/ccache.cpp

index f7069236f4718e6fd595a1493e1974db91923515..3881bdd0eb0e632973c23f1d4efd0a06a9ecc527 100644 (file)
@@ -1728,6 +1728,26 @@ hash_common_info(const Context& ctx, const util::Args& args, Hash& hash)
     }
   }
 
+#ifdef _WIN32
+  // On Windows an update that bumps VCToolsVersion changes the triple that gets
+  // embedded in precompiled headers. MSVC and clang-cl derive the target triple
+  // from the MSVC toolset version, so the cache must be invalidated if it
+  // changes.
+  if (ctx.config.is_compiler_group_msvc()) {
+    const char* msvc_env_vars[] = {
+      "VCToolsVersion",
+      "VCToolsInstallDir",
+    };
+    for (const char* name : msvc_env_vars) {
+      const char* value = getenv(name);
+      if (value) {
+        hash.hash_delimiter(name);
+        hash.hash(value);
+      }
+    }
+  }
+#endif
+
   if (!(ctx.config.sloppiness().contains(core::Sloppy::locale))) {
     // Hash environment variables that may affect localization of compiler
     // warning messages.