|
|
| Bugzilla Link |
47460 |
| Version |
unspecified |
| OS |
Linux |
| Reporter |
LLVM Bugzilla Contributor |
| CC |
@martingalvan |
Extended Description
I spent way too much time troubleshooting this, but it was not obvious at first why tidy is complaining.
Let's consider following example:
Clang installed with official apt package, created symlink:
/usr/bin/clang++ -> ../lib/llvm-10/bin/clang++
Now if you run CMake with clang++ as compiler everything will compile fine. And we have, following entry in compile_commands.json
"command": "/usr/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp"
Run clang-tidy -p build main.cpp
and it doesn't add /usr/lib/llvm-10/bin/../include/c++/v1 to include dirs... (and fails obviously)
But there is more, if we edit compile_commands.json (or run cmake with fullpath to compiler), so that we have:
"command": "/usr/lib/llvm-10/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp"
it will work fine...
I can pass full path to cmake, CXX=$(realpath which clang++), and it will work, but this is clunky if you ask me. Especially if one have /usr/bin/c++ symlinked to clang++ and expect things to just work and don't want to manually resolve symlinks.
--
I took quick look and Driver::getInstalledDir() if InstalledDir is empty, returns Dir, which is apparently invocation dir and doesn't resolve symlinks. And later is used and InstalledDir which obviously is wrong in case of symlink.
Extended Description
I spent way too much time troubleshooting this, but it was not obvious at first why tidy is complaining.
Let's consider following example:
Clang installed with official apt package, created symlink:
/usr/bin/clang++ -> ../lib/llvm-10/bin/clang++
Now if you run CMake with clang++ as compiler everything will compile fine. And we have, following entry in compile_commands.json
"command": "/usr/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp"
Run clang-tidy -p build main.cpp
and it doesn't add /usr/lib/llvm-10/bin/../include/c++/v1 to include dirs... (and fails obviously)
But there is more, if we edit compile_commands.json (or run cmake with fullpath to compiler), so that we have:
"command": "/usr/lib/llvm-10/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp"
it will work fine...
I can pass full path to cmake, CXX=$(realpath
which clang++), and it will work, but this is clunky if you ask me. Especially if one have /usr/bin/c++ symlinked to clang++ and expect things to just work and don't want to manually resolve symlinks.--
I took quick look and Driver::getInstalledDir() if InstalledDir is empty, returns Dir, which is apparently invocation dir and doesn't resolve symlinks. And later is used and InstalledDir which obviously is wrong in case of symlink.