[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On generating compilation databases

From: Paul Smith
Subject: Re: On generating compilation databases
Date: Tue, 06 Dec 2022 08:11:12 -0500
User-agent: Evolution 3.46.1 (by

On Mon, 2022-12-05 at 23:09 +0100, Arsen Arsenović wrote:
> Evening,
> Could, and how should, (auto)make be instructed to output compile
> commands?

It's really not at all clear what you are talking about here, until far
down your email where finally you say:

> ... dumped into compile_commands.json.

and we discover you're trying to build a compile_commands.json file.

> So, in conclusion, what do you think is the right approach?

I'm sorry but I'm not sure I understood the approach that you are
referring to here.  Are you talking about the idea of "setting CC, CXX
... variables to a tool"?

That seems like a reasonable way to go in my opinion.

> Do you think a feature like this should even exist in the GNU Build
> System (or, Make more broadly)?

Well, I personally think that compile_commands.json specifically is a
poor format; for example it provides no information on header files,
which are clearly needed in order to have a well-functioning LSP server
(I mean, we edit header files too).  Similar to the LSP spec itself, it
suffers from having been designed by one group for their needs without
much thought, at least initially, to how to make the format generic and
widely useful.  That leads to bad decisions being made up-front then
hard to get away from (for example, LSP's requirement for UTF-16 which
betrays its origins as a purely Microsoft-generated specification).

However I have nothing against having compile_commands.json being
generated, certainly.

> Do you have any implementation ideas?

Not really.  I see no feasible way that that generating
compile_commands.json could be built into make itself, so it would need
to be some kind of add-on package.  For people who are willing or able
to modify makefiles and reset appropriate variables such as CC or CXX,
that seems like quite a reasonable way forward.

The big problem, as with all make-based tools, is that if you don't
actually build the target then your compiler invocation won't run and
that source file and compile command won't be added to the JSON file.

If I were designing a tool such as the putative "report-calls" I would
have it load the compile_commands.json file into memory, then merge in
any new or different information based on the current compiler
invocation, then write it out again.  Of course this would require some
amount of locking, or else using some kind of server model.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]