[cfe-dev] Getting involved with Clang refactoring

Manuel Klimek klimek at google.com
Thu May 24 23:37:30 PDT 2012

On Thu, May 24, 2012 at 11:39 PM, James K. Lowden
<jklowden at schemamania.org>wrote:

> On Tue, 22 May 2012 15:49:42 +0200
> Manuel Klimek <klimek at google.com> wrote:
> > > Gentlemen, could you tell me please what you mean by a "compilation
> > > database"?  It sounds like a list of files to compile, something I'd
> > > normally look to make(1) to provide.  Apparently that's not what you
> > > mean, or there's some reason make won't do the job.
> > >
> > > If I understood the problem better perhaps there's something I
> > > could do about it.
> >
> > The problem with make is that it executes the compiler based on
> > changes in the dependency graph.
> >
> > Imagine you want to run a tool on all files that use a specific
> > symbol. To do this you need to:
> > 1. figure out the compile command line for the file into which you're
> > pointing to figure out the symbol under the cursor
> > 2. run the tool over all files that reference that symbol
> 3.  In an order determined by the dependency graph.  :-)

One more reason: dependency order introduces artificial serialization. When
you want to analyze code (e.g. run a tool over all code in a project to
collect data), you can do so fully parallel with the compilation database
and a simple call to xargs. This might not be a huge issue for small code
bases (for llvm I get ~2x speedup vs. the cmake generated Makefiles, which
are again ~2x vs. the autoconf Makefiles), but for larger projects
serialization becomes a major issue.


> Thank you for the explanation.  At least now I partly understand what
> you're talking about.
> But I'm still puzzled.  Why would one need to recompile all files that
> use a specific symbol? Changes to a symbol normally occur in a header
> file, affecting the dependency graph in just the way that makes make
> useful.  To solve the problem you describe -- to have Clang recompile
> "all files that use a specific symbol"  -- one could touch(1) all such
> files and then run make.
> The "figure out the command line" part is also intrinsic to make, as
> you know, based on the filename suffix.  That's 30 years of prior art
> that the compilation database seems to be reinventing.
> I understand the project has an existing build infrastructure, and that
> the compilation database is already embedded in it.  It's not yet clear
> to me why it was invented, and whether it's a solution or a problem.
> --jkl
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120525/199814f4/attachment.html>

More information about the cfe-dev mailing list