[cfe-dev] Producing compilation databases (was Re: Clang-based indexer and code navigator)

Sean Silva silvas at purdue.edu
Thu Mar 14 18:23:38 PDT 2013


On Thu, Mar 14, 2013 at 5:35 PM, Joshua Cranmer 🐧 <Pidgeot18 at gmail.com>wrote:

> On 3/14/2013 3:58 PM, Sean Silva wrote:
>
>> The problem is that there are no mature and established tools for
>> generating the database. As the tools improve, the problem will solve
>> itself; there's no reason to bring them into clang really since the major
>> problem is just developing mature tools in the first place. Having a
>> "standardized" format for the compilation database decouples this
>> development from clang itself.
>>
>
> Like David Blaikie, I find this view mistifying. If I wish to be able to
> use Clang's tooling on my codebase, why must I rewrite the entire project's
> build system just to be able to get a file? Adding flags to CFLAGS/CXXFLAGS
> is generally well-supported in almost all build systems, so why not enable
> more people to use other tooling by letting them compile with make
> CFLAGS=-fdump-compilation-**database=/path/to/db.json ?
>
>
Better and simpler would be to ship a wrapper script that writes this data
and then invokes clang as usual (or both could be done in parallel). Then
you set the wrapper script to CXX and be done with it. The "wrapper CXX"
paradigm seems even simpler to integrate with a build system.

With python, we could write the data into a sqlite db (which is in the
stdlib), which would automatically solve all the correctness issues related
to parallel file writing. Then we just need a simple little script (a
handful of lines of python) to pull that data out into the JSON format that
clang parses natively. If we go this route we should standardize the sqlite
schema. Anybody willing to write that?

I think that would be a lot more palatable to ship with clang (vs.
LD_PRELOAD or other fragile system-specific trickery).

-- Sean Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130314/79b4845a/attachment.html>


More information about the cfe-dev mailing list