<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 14, 2013 at 6:49 AM, David Röthlisberger <span dir="ltr"><<a href="mailto:david@rothlis.net" target="_blank">david@rothlis.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 14 Mar 2013, at 10:10, Laszlo Nagy wrote:<br>

><br>
> you might have seen my tool, which trying to address the compilation database problem. (Just in case if you missed <<a href="https://github.com/rizsotto/Bear" target="_blank">https://github.com/rizsotto/Bear</a>>) Which is using LD_PRELOAD to catch the compiler calls... And now I am wondering what does it mean 'feels yucky'? What other, more technical, point you have against it? ;) Was testing against: scons, GNU make, qmake, cmake, bash... and it works reliable most of the cases. On solaris/BSD systems, you could use D-Trace, which also capture all exec calls, more easy. But that's another platform specific solution.<br>

><br>
> My conclusion was at that time, I either write OS specific solution, which works on any build system. Or write build-tool specific solution, which works on every OS. Since I'm interested in sources which are compiles on Linux, I went for the LD_PRELOAD trick.<br>

<br>
</div>Ryan Prichard's "sw-btrace" is similar to "bear" but supports OS X &<br>
FreeBSD as well as Linux. "bear" is already mentioned in<br>
<a href="http://clang.llvm.org/docs/JSONCompilationDatabase.html" target="_blank">http://clang.llvm.org/docs/JSONCompilationDatabase.html</a> -- we could also<br>
add a mention of "sw-btrace".<br>
<div class="im"><br>
<br>
> I got the feeling that putting this kind code into Clang would not solve the problem at all, but would Clang driver itself more complex... You still need to teach your build system to use Clang. And since you were able to do that, you can write a fake compiler, which only emit the message about it's command line arguments and generate a fake object file. (Of course you need to write fake ar/ld commands as well) But more importantly need a process which collect these messages and format into a JSON file. (By the way this is exactly what the LD_PRELOAD solution is doing, except no need for fake compiler/linker. And no need to put code into Clang.)<br>

<br>
</div>Maybe not add this to the Clang binary itself, but add a "bear" /<br>
"sw-btrace" tool to the clang repository? I think it would be nice to<br>
have such tools available directly from the clang project, instead of<br>
having each clang-based tool invent its own or depend on yet another<br>
project.<br>
<br>
One benefit of this approach is that it gives the clang project the<br>
flexibility to change the compilation database format without the fear<br>
of breaking all these other tools. (There's still CMake, though.)</blockquote><div><br></div><div style>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.</div>
<div style><br></div><div style>-- Sean Silva</div></div><br></div></div>