llvm-project/clang/tools/clang-scan-deps
Kousik Kumar 26fa9e31f5 Add support to find out resource dir and add it as compilation args
Summary:
If -resource-dir is not specified as part of the compilation command, then by default
clang-scan-deps picks up a directory relative to its own path as resource-directory.
This is probably not the right behavior - since resource directory should be picked relative
to the path of the clang-compiler in the compilation command.
This patch adds support for it along with a cache to store the resource-dir paths based on
compiler paths.

Notes:
1. "-resource-dir" is a behavior that's specific to clang, gcc does not have that flag. That's why if I'm not able to find a resource-dir, I quietly ignore it.
2. Should I also use the mtime of the compiler in the cache? I think its not strictly necessary since we assume the filesystem is immutable.
3. From my testing, this does not regress performance.
4. Will try to get this tested on Windows.

But basically the problem that this patch is trying to solve is, clients might not always want to specify
"-resource-dir" in their compile commands, so scan-deps must auto-infer it correctly.

Reviewers: arphaman, Bigcheese, jkorous, dexonsmith, klimek

Reviewed By: Bigcheese

Subscribers: MaskRay, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69122
2019-11-22 07:43:54 -08:00
..
CMakeLists.txt cmake: Add CLANG_LINK_CLANG_DYLIB option 2019-07-03 22:45:55 +00:00
ClangScanDeps.cpp Add support to find out resource dir and add it as compilation args 2019-11-22 07:43:54 -08:00