[llvm] [dsymutil] Bump .dSYM bundle directory mtime after a rewrite (PR #199257)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 22 11:54:00 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

When dsymutil rewrites an existing .dSYM bundle, only the inner DWARF file is replaced and the bundle directory's mtime stays frozen at the time of the original build.

macOS Spotlight's bundle re-import path keys off the bundle directory's mtime to decide whether the importer should re-run. With the mtime frozen, Spotlight keeps the previous build's UUID indexed forever, DebugSymbols.framework's Spotlight lookup misses on the new UUID.

Bump the bundle directory's mtime explicitly at the end of a successful run, reusing the .dSYM extraction already used by the codesign path.

rdar://177725866

---
Full diff: https://github.com/llvm/llvm-project/pull/199257.diff


2 Files Affected:

- (added) llvm/test/tools/dsymutil/X86/bundle-mtime.test (+24) 
- (modified) llvm/tools/dsymutil/dsymutil.cpp (+19) 


``````````diff
diff --git a/llvm/test/tools/dsymutil/X86/bundle-mtime.test b/llvm/test/tools/dsymutil/X86/bundle-mtime.test
new file mode 100644
index 0000000000000..cca0e355b7997
--- /dev/null
+++ b/llvm/test/tools/dsymutil/X86/bundle-mtime.test
@@ -0,0 +1,24 @@
+## Verify dsymutil bumps the .dSYM bundle directory's mtime when rewriting an
+## existing bundle in place. macOS Spotlight keys off this mtime to decide
+## whether to reimport the bundle's UUID; without the bump, Spotlight serves
+## the previous build's UUID and DebugSymbols falls through to slow
+## dsymForUUID lookups.
+
+RUN: rm -rf %t.dir
+RUN: mkdir -p %t.dir
+RUN: cat %p/../Inputs/basic.macho.x86_64 > %t.dir/basic
+RUN: dsymutil -oso-prepend-path=%p/.. %t.dir/basic
+
+## Backdate the bundle dir to a known epoch so any update is visible.
+RUN: env TZ=GMT touch -t 197001020000 %t.dir/basic.dSYM
+## Marker with a newer-than-backdated timestamp; the second dsymutil run
+## must move the bundle dir's mtime past this marker.
+RUN: env TZ=GMT touch -t 200001010000 %t.dir/marker
+
+RUN: dsymutil -oso-prepend-path=%p/.. %t.dir/basic
+
+## `find -maxdepth 0 -newer` prints the bundle path iff its mtime is newer
+## than the marker. Without the mtime bump, the directory keeps its 1970
+## stamp and find prints nothing.
+RUN: find %t.dir/basic.dSYM -maxdepth 0 -newer %t.dir/marker | FileCheck %s
+CHECK: basic.dSYM
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index f9cee74a2fd50..cc50fa86fda65 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -1042,6 +1042,25 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
         }
       }
     }
+
+    // Bump the .dSYM bundle directory's mtime so macOS Spotlight reimports
+    // the (possibly new) UUID. Rewriting the inner DWARF file alone leaves
+    // the bundle directory mtime frozen, and Spotlight keeps serving the
+    // previous build's UUID, falling through to slow dsymForUUID lookups.
+    {
+      StringRef DWARFFile = OutputLocationOrErr->DWARFFile;
+      auto Pos = DWARFFile.find(".dSYM/");
+      if (Pos == StringRef::npos)
+        Pos = DWARFFile.find(".dSYM");
+      if (Pos != StringRef::npos) {
+        StringRef BundlePath = DWARFFile.substr(0, Pos + 5);
+        auto Now = std::chrono::system_clock::now();
+        if (auto EC =
+                sys::fs::setLastAccessAndModificationTime(BundlePath, Now))
+          WithColor::warning() << "could not update mtime of " << BundlePath
+                               << ": " << EC.message() << '\n';
+      }
+    }
   }
 
   return EXIT_SUCCESS;

``````````

</details>


https://github.com/llvm/llvm-project/pull/199257


More information about the llvm-commits mailing list