I have clang, clang-check, libc++, libc++abi, etc. installed in a tree rooted in a non-standard location. The directory structure looks like this:
$CLANG_ROOT
_bin
_ clang
_ clang-check
…
_include
_ various built-in C header files
_c++
_v1
_ various libc++ header files
_lib → lib64
_lib64
_ various libraries
Note that the above directory structure is standard, only the root directory is in a non-standard location. A simple C++ file like this:
// /tmp/fill.cpp
#include
#include
std::vector v{1, 2, 3};
int main() {
std::fill(v.begin(), v.end(), -1);
return 0;
}
compiles fine with clang++:
$ clang++ -std=c++11 -stdlib=libc++ /tmp/fill.cpp
$
But with clang-check, it doesn’t compile fine even though compile_commands.json has the exact same clang “command”. Even specifying -stdlib=libc++ on the command line doesn’t work:
$ clang-check /tmp/fill.cpp – -stdlib=libc++ -std=c++11 -xc++
/tmp/fill.cpp:1:10: fatal error: ‘algorithm’ file not found
#include
^~~~~~~~~~~
1 error generated.
Error while processing /tmp/fill.cpp.
$
But the following works:
$ clang-check /tmp/fill.cpp – -std=c++11 -cxx-isystem ${CLANG_ROOT}/include/c++/v1
$
Why is clang-check not automatically inferring libc++ header paths the same way clang++ driver finds them? Is there some build configuration that can make clang tools find libc++ headers automatically when -stdlib=libc++ is specified.
BTW, clang-check finds libstdc++ headers if –gcc-toolchain option is specified.