logoalt Hacker News

lstoddyesterday at 7:02 AM1 replyview on HN

What is an "accurate compilation database"?

If you mean that dependencies better resolve = project better be in a mostly buildable state or they complain of undefined stuff that's true.


Replies

nickelproyesterday at 2:41 PM

The compilation database[1] given to clangd needs to be complete, understood by the clangd argument parser, and capable of producing a build.

This starts to hurt bad when the compiler producing the build is not clang. If you try to use a compile database describing C++20 module compile lines for GCC, clangd will choke badly. If you're using MSVC flags that clang-cl hasn't been taught yet, clangd falls over. If you're using CMake to produce the compile database, it will leave out synthetic targets from the database and you will see errors because clangd cannot find the interfaces described by those targets. If you're not using CMake you need to configure bear or ninja or whatever to produce a compilation database for you. Etc, etc.

[1]: https://clang.llvm.org/docs/JSONCompilationDatabase.html