Skip to content

Conversation

@jansvoboda11
Copy link
Contributor

This PR switches from using llvm::sys::fs::make_absolute() to FileManager::makeAbsolutePath() so that FileSystemOptions (i.e. the -working-directory option) and the VFS's CWD have a say in how the prebuilt module paths are resolved. This matches how the rest of the compiler treats input files.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2025

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

This PR switches from using llvm::sys::fs::make_absolute() to FileManager::makeAbsolutePath() so that FileSystemOptions (i.e. the -working-directory option) and the VFS's CWD have a say in how the prebuilt module paths are resolved. This matches how the rest of the compiler treats input files.


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

1 Files Affected:

  • (modified) clang/lib/Lex/HeaderSearch.cpp (+2-2)
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 65c324c10ca5d..f05c28fd7a123 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -221,7 +221,7 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
   // file.
   for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> Result(Dir);
-    llvm::sys::fs::make_absolute(Result);
+    FileMgr.makeAbsolutePath(Result);
     if (ModuleName.contains(':'))
       // The separator of C++20 modules partitions (':') is not good for file
       // systems, here clang and gcc choose '-' by default since it is not a
@@ -246,7 +246,7 @@ std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
   StringRef ModuleCacheHash = HSOpts.DisableModuleHash ? "" : getModuleHash();
   for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> CachePath(Dir);
-    llvm::sys::fs::make_absolute(CachePath);
+    FileMgr.makeAbsolutePath(CachePath);
     llvm::sys::path::append(CachePath, ModuleCacheHash);
     std::string FileName =
         getCachedModuleFileNameImpl(ModuleName, ModuleMapPath, CachePath);

Copy link
Collaborator

@cachemeifyoucan cachemeifyoucan left a comment

Choose a reason for hiding this comment

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

LGTM

@jansvoboda11 jansvoboda11 merged commit 3056727 into llvm:main Oct 30, 2025
16 of 17 checks passed
@jansvoboda11 jansvoboda11 deleted the prebuilt-module-paths-vfs branch October 30, 2025 17:25
luciechoi pushed a commit to luciechoi/llvm-project that referenced this pull request Nov 1, 2025
…llvm#165347)

This PR switches from using `llvm::sys::fs::make_absolute()` to
`FileManager::makeAbsolutePath()` so that `FileSystemOptions` (i.e. the
`-working-directory` option) and the `VFS`'s CWD have a say in how the
prebuilt module paths are resolved. This matches how the rest of the
compiler treats input files.
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
…llvm#165347)

This PR switches from using `llvm::sys::fs::make_absolute()` to
`FileManager::makeAbsolutePath()` so that `FileSystemOptions` (i.e. the
`-working-directory` option) and the `VFS`'s CWD have a say in how the
prebuilt module paths are resolved. This matches how the rest of the
compiler treats input files.
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