[clang] [modules] Accept equivalent module caches from different symlink (PR #90925)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Fri May 3 09:52:59 PDT 2024


================
@@ -839,17 +839,15 @@ static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
                                      DiagnosticsEngine *Diags,
                                      const LangOptions &LangOpts,
                                      const PreprocessorOptions &PPOpts) {
-  if (LangOpts.Modules) {
-    if (SpecificModuleCachePath != ExistingModuleCachePath &&
-        !PPOpts.AllowPCHWithDifferentModulesCachePath) {
-      if (Diags)
-        Diags->Report(diag::err_pch_modulecache_mismatch)
-          << SpecificModuleCachePath << ExistingModuleCachePath;
-      return true;
-    }
-  }
-
-  return false;
+  if (!LangOpts.Modules || PPOpts.AllowPCHWithDifferentModulesCachePath ||
+      SpecificModuleCachePath == ExistingModuleCachePath ||
+      llvm::sys::fs::equivalent(SpecificModuleCachePath,
----------------
benlangmuir wrote:

This should go through the `VirtualFileSystem` to be consistent with the code that reads module files. The callers of this API should both have easy access to a VFS to pass in: for `SimplePCHValidator` it's `FileMgr.getVirtualFileSystem()` and for `PCHValidator` it's `Reader.getFileManager().getVirtualFileSystem()`.

You could also add a helper method to VirtualFileSystem for `equivalent` that does `status(Path1).equivalent(status(Path2))` (plus error handling).

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


More information about the cfe-commits mailing list