[clang] Make PCH's respect any VFS specified. (PR #106577)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 10:26:35 PDT 2024


benlangmuir wrote:

It looks like it almost works:  if I create a module in a virtual path and use `use-external-names: false`, then the module stores the virtual path for its input files.

E.g.

```
{
  "version": 0,
  "use-external-names": false,
  "roots": [
    {
      "contents": [
        {
          "external-contents": "/tmp/a/t.h",
          "name": "t.h",
          "type": "file"
        },
        {
          "external-contents": "/tmp/b/prefix.h",
          "name": "prefix.h",
          "type": "file"
        },
        {
          "external-contents": "/tmp/a/module.modulemap",
          "name": "module.modulemap",
          "type": "file"
        }
      ],
      "name": "/root",
      "type": "directory"
    },
  ]
}
```

Compiled with
```
clang -x c-header /tmp/b/prefix.h -I/root -ivfsoverlay vfs -fmodules -o prefix.h.pch
```

The references to t.h and module.modulemap seem to be stored with `/root` (the virtual path).

However, I can't remap the prefix header itself
```
clang -x c-header /root/prefix.h -I/root -ivfsoverlay vfs -fmodules -o prefix.h.pch
clang: error: no such file or directory: '/root/prefix.h'
clang: error: no input files
```

I guess it's resolving that path outside the VFS.  Maybe that's fixable though?

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


More information about the cfe-commits mailing list