[clang] [clang] use relative paths for builtin headers during module compilation (PR #68023)

Richard Howell via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 12:56:48 PDT 2023


================
@@ -180,8 +180,9 @@ static void appendSubframeworkPaths(Module *Mod,
 OptionalFileEntryRef ModuleMap::findHeader(
     Module *M, const Module::UnresolvedHeaderDirective &Header,
     SmallVectorImpl<char> &RelativePathName, bool &NeedsFramework) {
-  // Search for the header file within the module's home directory.
-  auto Directory = M->Directory;
+  // Search for the header file within the module's home directory
+  // or the builtin include dir if this is a builtin header.
+  auto Directory = Header.HasBuiltinHeader ? BuiltinIncludeDir : M->Directory;
----------------
rmaz wrote:

Looks like we don't, no. The header ends up resolved against the resource dir as expected:
```
<SUBMODULE_BLOCK NumWords=63 BlockCodeSize=5>
    <SUBMODULE_METADATA op0=1 op1=0/>
    <SUBMODULE_DEFINITION abbrevid=4 op0=1 op1=0 op2=0 op3=18 op4=0 op5=0 op6=1 op7=0 op8=0 op9=0 op10=0 op11=0 op12=0 op13=1/> blob data = 'ModuleWithBuiltinHeader'
    <SUBMODULE_HEADER abbrevid=6/> blob data = 'float.h'
    <SUBMODULE_TOPHEADER abbrevid=7/> blob data = '/home/llvmbuilddbg.noindex/tools/clang/test/Modules/Output/relative-resource-dir.m.tmp/resource-dir/include/float.h'
  </SUBMODULE_BLOCK>
```

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


More information about the cfe-commits mailing list