ilya-biryukov added a comment. In D54872#1309075 <https://reviews.llvm.org/D54872#1309075>, @malaperle wrote:
> In D54872#1307775 <https://reviews.llvm.org/D54872#1307775>, @ilya-biryukov > wrote: > > > We have to point clangd into the resource dir, corresponding to the version > > of the headers it was built with. It's important we pick the exact version > > of the built-in headers that clangd was built for. > > > Can you clarity/confirm "headers it was built with"? There are two categories of headers we care about: - the built-in headers that correspond to the `clang-headers` build target (they typically live in `./lib/clang/<version>/` if clang lives in `./bin`). These headers should be provided alongside the clang-based tools, it's not ok to use the ones from a different version of the compiler (one might get spurious compiler errors or even crashes). We inject `-resource-dir` in clangd to make sure we pick up the version of built-in headers that we ship. - the C and C++ library headers, e.g. `<vector>`, `<stdio.h>`, etc. Those are not tied to the compiler version, so we just pick up the one based on the compilation database. > For example, if I build Clangd using Xcode's Clang, then running this > Clangd, I would have to point to Xcode's Clang headers? In this example we should point the `-resource-dir` to pick up the headers from the `clangd` distribution, **not** XCode headers. > This is what I have observed when using Clangd on Clangd's code. What if I > compile Clangd with another non-Clang compiler? Users shouldn't point `-resource-dir` into XCode's headers, this might break if the versions are sufficiently different. D54630 <https://reviews.llvm.org/D54630> should fix this, it's under review. > The problematic case is a bit different than I originally thought. The CDB > contains an include path to the built-in headers of the Clang (windows > installer) used to build the project, let's call the compiler Clang1. I also > built Clang+Clangd separately from this Clang1, using CL, let's call it > Clang2. When running that custom Clangd, the fallback resource-dir is the one > from Clang2. I haven't looked deeply to confirm this, but having an include > path to Clang1 (windows installer) and resource-dir to Clang2 (custom build) > seems like would likely not work. In fact, when running Clangd from Clang2 > and setting resource-dir to Clang1, it works properly. Now, I don't know if > it's the CDB that's wrongly including the headers of Clang1 or if the CDB > should include -resource-dir to Clang1. In any case, I'll spend a bit more > time clarifying this. What is the actual error you're getting? It would be nice to have a repro, so that we can look into the details of the issue. I suspect this might be similar to the issues we're running into on Mac (see D54630 <https://reviews.llvm.org/D54630> for details), where the `-resource-dir` is used to find the C++ STL headers in addition to the built-in headers. Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54872/new/ https://reviews.llvm.org/D54872 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits