Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
Qt Creator 14.0.1
-
clangd version 18.1.8
cmake version 3.30.0
Description
Qt Creator can use custom LSP server in Language Client settings. I can set up clangd as the custom LSP server, with the custom arguments that matches mostly with the builtin one:
```
--compile-commands-dir=%
-j=8 --background-index --background-index-priority=low --header-insertion=never --limit-references=0 --rename-file-limit=0 --clang-tidy=0 --use-dirty-headers --ranking-model=decision_forest
```
And make sure the startup behavior is set to Start Server per Project.
Then open a project with precompiled headers enabled that contains many headers, like this:
```cmake
target_precompile_headers(
${TARGET_NAME}
PRIVATE
- — stdlib —
<string>
<vector>
<array>
<map>
<unordered_map>
<set>
<unordered_set>
<queue>
<stack>
<deque>
<ranges>
<string_view>
<tuple>
<optional>
<variant>
<any>
<bit>
<iostream>
<fstream>
<sstream>
<algorithm>
<functional>
<memory>
<utility>
<numeric>
<limits>
<mutex>
<atomic>
<thread>
<chrono> - — Boost —
<boost/asio.hpp>
<boost/cobalt.hpp>
<boost/container/stable_vector.hpp>
<boost/container/static_vector.hpp>
<boost/container/vector.hpp>
<boost/hof.hpp>
<boost/lambda2.hpp>
<boost/move/utility.hpp>
<boost/safe_numerics/exception.hpp>
<boost/safe_numerics/safe_integer.hpp>
<boost/safe_numerics/safe_integer_literal.hpp>
<boost/safe_numerics/safe_integer_range.hpp>
<boost/scope/defer.hpp>
<boost/scope/scope_exit.hpp>
<boost/scope/scope_fail.hpp>
<boost/scope/scope_success.hpp>
<boost/smart_ptr.hpp>
<boost/smart_ptr/atomic_shared_ptr.hpp>
<boost/smart_ptr/local_shared_ptr.hpp>
<boost/smart_ptr/make_local_shared.hpp> - — Qt —
<QGuiApplication>
<QVulkanInstance>
<QWindow>
<QApplication>
<QWidget>
<QtCore>
)
```
then the builtin clangd integration is much slower than the clangd running as custom LSP server in Language Client settings.
If I open a very small C++ source/header file, the custom clangd takes about 2 seconds to highlight the syntax, while the builtin one takes like 10 seconds.
I'm not sure about the reason but I suppose the PCH handling in Qt Creator is to be blamed. The only difference in arguments between those two is the `--compile-commands-dir`: the custom one points to the build folder where `compile_commands.json` is generated by CMake, while the builtin one points to the `.qtc_clang` directory.