[cfe-dev] [RFC] Embedding compilation database info in object files.

Joshua Cranmer 🐧 Pidgeot18 at gmail.com
Fri Jul 19 18:36:12 PDT 2013


On 7/17/2013 11:36 PM, Sean Silva wrote:
> tl;dr: compiler embeds compilation db info in object files; you can 
> then collect it afterwards with simple tools. Good idea?
>
> It seems like for a while now, we have been looking for a way that 
> clang can assist users in creating JSON compilation databases, but 
> solutions seem limited to specific build systems or platforms. I came 
> up with a neat little hack that may be a viable way for clang to help 
> create compilation databases "everywhere clang runs", with fairly good 
> user experience.
>
> I believe the following user experience is achievable "everywhere 
> clang runs":
> 1. Add some option to the compiler command line.
> 2. Rebuild.
> 3. Feed all of your built object files/executables to a small tool we 
> ship and out comes a compilation database.

Quite frankly, I don't see this as being a superior user-experience to 
the following scenario:
1. Add an option to the compiler command line to dump the database to a 
file.
2. Rebuild.
3. You have your compilation database automatically!

The primary difficulty of this approach from an implementation 
perspective is locking the database for writing when compiling with make 
-jN. I've seen concerns about impact on build-times for this, but 
considering natural variation in compilation times (since not all files 
are the same size), and the fact that we're already rebuilding world 
anyways, there should be very little contention for this file in the 
grand scheme of things.

-- 
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist




More information about the cfe-dev mailing list