]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Handle Apple Clang -index-unit-output-path option
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 24 Jan 2026 14:25:19 +0000 (15:25 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 24 Jan 2026 14:25:19 +0000 (15:25 +0100)
We can't cache -index-unit-output-path, so fall back to running the
compiler unless clang_index_store sloppiness is requested.

Related to discussion #1670.

doc/manual.adoc
src/ccache/argprocessing.cpp

index 44b32047f0bf5804c6d4ab057a357efb6138a469..3cbcb0b6f5b3dbb71740eeff2b9f4230883191be 100644 (file)
@@ -1054,8 +1054,9 @@ NOTE: In previous ccache versions this option was called *secondary_storage*
 *clang_index_store*::
 
     *Use case*: Xcode projects with varying index store paths. +
-    *Effect*: Ignores the `-index-store-path` option when hashing. +
-    *Trade-off*: Index store won't update correctly on cache hits.
+    *Effect*: Ignores the `-index-store-path` and `-index-unit-output-path`
+     options when hashing. +
+    *Trade-off*: Index won't update correctly on cache hits.
 
 *file_stat_matches*::
 
index f1d569531e4551ec3a8f640997e62a11ccf3a043..425875bb675014346850dc2d339450250ca74f99 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2026 Joel Rosdahl and other contributors
 //
 // See doc/authors.adoc for a complete list of contributors.
 //
@@ -1203,15 +1203,25 @@ process_option_arg(const Context& ctx,
     args_info.build_session_file = arg.substr(arg.find('=') + 1);
   }
 
-  if (config.sloppiness().contains(core::Sloppy::clang_index_store)
-      && arg == "-index-store-path") {
-    // Xcode 9 or later calls Clang with this option. The given path includes a
-    // UUID that might lead to cache misses, especially when cache is shared
-    // among multiple users.
-    i++;
-    if (i <= args.size() - 1) {
-      LOG("Skipping argument -index-store-path {}", args[i]);
+  if (arg == "-index-store-path" || arg == "-index-unit-output-path") {
+    if (i == args.size() - 1) {
+      LOG("Missing argument to {}", args[i]);
+      return Statistic::bad_compiler_arguments;
     }
+
+    // Xcode 9 or later calls Clang with -index-store-path. The given path
+    // includes a UUID that might lead to cache misses, especially when the
+    // cache is shared among multiple users.
+    //
+    // Newer Xcode versions use -index-unit-output-path which we can't cache.
+    if (!config.sloppiness().contains(core::Sloppy::clang_index_store)) {
+      LOG("Option {} is unsupported without clang_index_store sloppiness",
+          args[i]);
+      return Statistic::unsupported_compiler_option;
+    }
+
+    LOG("Skipping {} {}", args[i], args[i + 1]);
+    i++;
     return Statistic::none;
   }