<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 4, 2014 at 2:18 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Wed, Jun 4, 2014 at 12:57 PM, Eli Bendersky <<a href="mailto:eliben@google.com">eliben@google.com</a>> wrote:<br>


</div><div><div class="h5">> Hello,<br>
><br>
> Currently libclang will refuse to parse code that contains target-specific<br>
> builtin calls, and as far as I can tell it does not support passing in a<br>
> triple (I get a "...libclang: crash detected during parsing").<br>
><br>
> Has anyone else encountered this / filed a bug? It seems that<br>
> <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131104/092632.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131104/092632.html</a><br>
> is related but I didn't find any resolution from it.<br>
><br>
<br>
</div></div>The original idea is that clang should be functional without needing<br>
to link in the targets as its own library. However, given the asm<br>
parsing desires for msvc I don't know that's completely valid anymore.<br>
Tt could be possible to avoid doing the checking.<br>
<br>
That said, it might be worth splitting libclang into two parts - the<br>
codegen/"need to parse assembly" part and the "I just want to parse<br>
C/C++ source and skip over validation on assembly part". If we do that<br>
split we could have a front end bit that's more useful for people<br>
doing tooling and if you really want "gimme all of clang as a library"<br>
we can have the "everything linked in" part. Effectively we'd be<br>
making the larger library as a "gimme clang as a library without the<br>
driver" which may be what people want.<br></blockquote><div><br></div><div>This is an interesting proposal, but I wonder if it will solve the specific problem I'm struggling with. Even to "just parse" the code, you need to be able to know about all builtins that are invoked. Some builtins in Clang, however, come from the backend via the GCCBuiltin construct in .td files; these are exposed to Clang, which then knows to recognize these builtins. Without having a target linked in, these builtins are no longer recognized and parsing fails, even on "pure C/C++/CUDA" without any inline assembly.</div>

<div><br></div><div>Eli</div><div><br></div><div> </div></div></div></div>