logoalt Hacker News

maccard10/11/20244 repliesview on HN

One of the major problems approach with this is that you need to run the compile before you can generate this database.


Replies

mathstuf10/14/2024

You need to, in general, run the build for compilation databases to actually work anyways. Consider the following cases:

- headers generated during the build: tools may find the wrong header or fail when the header isn't found - generated sources: does the source file in the database even exist yet?

For those cases, one still needs to consider the "out of date" situation where a previous build left an old version around. This is something tools can't really even know today.

Beyond that, modules present an issue. The command line doesn't have any indication of what `import foo;` means to the TU in question (and in CMake's case, the file which does tell it that information is build-time generated anyways). Even if it did, the BMI may be in an incompatible format (e.g., using GCC for the build, but using `clang-analyzer` on the database) so the tool needs to go and make its own BMI. I gave a talk at CppCon about "build databases" which is basically "compilation databases, but consider what it means to support modules". (The video isn't available yet.)

I'm also working on getting a paper on them through ISO C++'s SG15 (Tooling) for proper specification.

FD: CMake developer

suprjami10/11/2024

How do you propose to generate the compilation database without compiling? I would really like that for the Linux kernel.

show 1 reply
wakawaka2810/12/2024

Is this really a major problem? Is there any tool that supports generating the database without compiling? I think the answer to both of these is "no". In fact I can't even think of a reasonable case where it would be even a minor problem.

show 2 replies