Skip to content

[clang] Stop adjusting the module cache path #102540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jansvoboda11
Copy link
Contributor

This patch stops adjustments of the module cache path beyond what is done in ParseHeaderSearchArgs (making it absolute and removing dots). This enables more efficient implementation of the caching VFS in #88800.

This patch stops adjustments of the module cache path beyond what is done in `ParseHeaderSearchArgs` (making it absolute and removing dots). This enables more efficient implementation of the caching VFS in llvm#88800.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

This patch stops adjustments of the module cache path beyond what is done in ParseHeaderSearchArgs (making it absolute and removing dots). This enables more efficient implementation of the caching VFS in #88800.


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

2 Files Affected:

  • (modified) clang/lib/Frontend/CompilerInstance.cpp (+2-3)
  • (modified) clang/lib/Lex/HeaderSearch.cpp (-1)
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 6242b5a7d9fe39..1364641a9b71e1 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1659,9 +1659,8 @@ static void pruneModuleCache(const HeaderSearchOptions &HSOpts) {
   // Walk the entire module cache, looking for unused module files and module
   // indices.
   std::error_code EC;
-  SmallString<128> ModuleCachePathNative;
-  llvm::sys::path::native(HSOpts.ModuleCachePath, ModuleCachePathNative);
-  for (llvm::sys::fs::directory_iterator Dir(ModuleCachePathNative, EC), DirEnd;
+  for (llvm::sys::fs::directory_iterator Dir(HSOpts.ModuleCachePath, EC),
+       DirEnd;
        Dir != DirEnd && !EC; Dir.increment(EC)) {
     // If we don't have a directory, there's nothing to look into.
     if (!llvm::sys::fs::is_directory(Dir->path()))
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index d2210e7e18628a..4914c10e62d0c5 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -267,7 +267,6 @@ std::string HeaderSearch::getCachedModuleFileNameImpl(StringRef ModuleName,
     return {};
 
   SmallString<256> Result(CachePath);
-  llvm::sys::fs::make_absolute(Result);
 
   if (HSOpts->DisableModuleHash) {
     llvm::sys::path::append(Result, ModuleName + ".pcm");

@aganea
Copy link
Member

aganea commented Aug 10, 2024

This enables more efficient implementation of the caching VFS in #88800.

Thanks @jansvoboda11 for working on this, I appreciate. One question, what do you mean by "more efficient"?

@jansvoboda11
Copy link
Contributor Author

This enables more efficient implementation of the caching VFS in #88800.

Thanks @jansvoboda11 for working on this, I appreciate. One question, what do you mean by "more efficient"?

Sorry, I should've clarified. I think that without this patch, #88800 would need to apply llvm::sys::path::native() and llvm::sys::fs::make_absolute() on DependencyScanningWorkerFilesystem::BypassedPathPrefix within each invocation to DependencyScanningWorkerFilesystem::shouldBypass() where simple string prefix did not match. Only then would it recognize the modules cache path in all its forms.

Copy link
Member

@aganea aganea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!

@jansvoboda11 jansvoboda11 merged commit 17dc43d into llvm:main Aug 13, 2024
11 checks passed
@jansvoboda11 jansvoboda11 deleted the stop-messing-with-module-cache-path branch August 13, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants