A couple things.<div><br></div><div>We don't want .clangrc files just being willy nilly all over the place, and we don't want them tied at all to a particular person's machine. The .clangrc files should be a part of the project and checked into VCS. I think that the way .gitignore files work is a good model, e.g. how you have a canonical one in the top-level directory of your source tree, and then you can customize on a per-directory basis. I'm not sure what you expect to be in these files, but the thought of each person having their .clangrc files strewn about their computer frightens me (difficult to set up). Perhaps .clangdconfig or something is a better name for these files, since rc files generally are for personal (per-user) settings (we can have those too, but for options like how to sort search results, which is a user-preference).</div>
<div><br></div><div>A use case that I think is worth considering is the case of completing a TableGen'd diagnostic (e.g. diag::err_missing_typ<complete>). By necessity, this service will need to be able to find any generated files so that it can look in them. Thus, clangd has to either</div>
<div>1) be aware of the build system </div><div>2) or that the build system has to generate files that appropriately inform clangd about the setup.</div><div>I think that 1 is clearly undesirable since we don't want to code into clangd the idiosyncrasies of every build system known to man. Therefore, 2 it is.</div>
<div><br></div><div>As for the proposal and implementation strategy, I disagree with the implementation strategy and think that the rest of the proposal is a bit premature (things like settling on using LLVM bitcode format for the protocol). With the current implementation strategy, you have no way of knowing whether you are building "the right thing" until it is too late. For example, there is nothing in the proposal about having this be easy to use and setup.</div>
<div><br></div><div>I think that the following should work before anything else happens (based roughly on how I set up my dev environment):</div><div><br></div><div>git clone <a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a></div>
<div>cd llvm/tools</div><div>git clone <a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a></div><div>cd ../../</div><div>mkdir release</div><div>cd release</div><div>cmake -G Ninja ../source /* ... other flags ... */ -DLLVM_ENABLE_CLANGD_INTEGRATION=ON</div>
<div>ninja clangd-init</div><div><br></div><div>At this point, I should be able to do something like:</div><div>clang-cli complete --file=llvm/tools/clang/lib/Sema/SemaStmt.cpp --line=1302 --column=24</div><div>and get completions. Since clangd knows about the project, it knows exactly what project to complete for based on just the filename.</div>
<div><br></div><div>At this point, stable binary interfaces don't have to happen yet, stable IPC protocols don't have to happen yet, etc. Just something that works.</div><div><br></div><div>Now we're in business, and can make real progress:</div>
<div>* Too slow? --> Can benchmark and make it faster</div><div>* Wow it would be really useful if we could do X? --> Do X, and be able to immediately test it and dogfood it.</div><div>* Oh shit, there are certain kinds of modifications of the source file that cause extremely long delays that are completely unavoidable? -> come up with a way to handle this, which might require rethinking the protocol or client API.</div>
<div><br></div><div>Since this is primarily for interactive use, a clang-cli based RESTful interface is all you need (I'd honestly say use JSON).  I don't like the idea of having a persistent client-server connection since I don't want vim to have a socket open constantly (emacs users probably would be comfortable with that though ;). Also, what if I change directory while in Vim? Or have two files open from different projects? Now vim has to handle the logic of managing N connections and renegotiating sessions? That's just silly. If the overhead of fork/exec'ing a new process ever becomes significant then we will already be unnoticeably fast (try `:%!sort` on a large file, fast no?).</div>
<div><br></div><div>I also think it is mind-numbingly stupid to add a socket I/O library into LLVM/Clang. There is no reason why the Clang/LLVM part of clangd should *ever* have to touch the network or have to include request-processing logic. Leave that to node.js (or whatever). Let the people that are good with that kind of thing mash it up and make cool things. We of course can make our own cool things, but don't decrease the usefulness of LLVM/Clang for this kind of thing by enshrining what will become "that shitty web-server-written-from-scratch-by-compiler-writers-in-C++ that only talks this weird binary format". Just because clang provides functionality useful for GUI IDEs doesn't mean that you need to write a GUI library in-tree and enshrine a specific IDE with Clang/LLVM. Similarly, it is braindead to attempt to add a networking library to LLVM/Clang and enshrine a specific server implementation in-tree. The networking code will always be total crap, never production quality, and a huge pain in the ass for anyone that wants to do anything nontrivial with it; for example, if users want to use encryption over the network, are you going to add OpenSSL as a dependency for LLVM? Or write a crypto library from scratch for LLVM? What if a node.js user wants to use this? Are you going to make all the networking code asynchronous?. What I'm talking about here of course doesn't preclude stuff like fixing the fs layer, which is necessary for LLVM/Clang to be useful in this capability (at production quality) in the first place.</div>
<div><br></div><div>To recap:</div><div>1) Get something working ASAP</div><div>2) Iterate, dogfooding it every step of the way.</div><div>3) Don't add things in-tree that are outside the domain of what LLVM/Clang do (e.g. networking, GUIs, crypto, 3D-rendering, etc).</div>
<div>4) In-tree changes should focus (as always) on increasing the utility/flexibility of the LLVM/Clang libraries to clients (e.g. can safely be used multithreaded, etc), and should be motivated by compelling use-cases derived from part 2)</div>
<div><br></div><div>--Sean Silva</div><div><br></div><br><div class="gmail_quote">On Tue, Jun 12, 2012 at 3:43 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings all!<div><br></div><div>What follows is a fairly lengthy and detailed design document for a proposed persistent Clang server (or clangd in unix-terms) to serve as infrastructure for increasingly advanced and interactive C++ tools. It should generalize and build upon libclang, and will allow us to effectively target Vim, Emacs, and other editors. This is something we're planning to pursue in the near term, so I'd appreciate any and all feedback.</div>

<div><br></div><div>Here is a Google Docs link you can use to view and comment on the proposal:</div><div><a href="https://docs.google.com/document/d/1kNv2jJK0I0JGnxJxU6w5lUOlrIBoecU4fi9d_o5e2-c/edit" target="_blank">https://docs.google.com/document/d/1kNv2jJK0I0JGnxJxU6w5lUOlrIBoecU4fi9d_o5e2-c/edit</a></div>

<div><br></div><div>Its interim home is on github here, where you can see the history and the actual rest version in all its glory:</div><div><a href="https://github.com/chandlerc/llvm-designs/blob/master/ClangService.rst" target="_blank">https://github.com/chandlerc/llvm-designs/blob/master/ClangService.rst</a></div>

<div><br></div><div>I've also attached the text for email-based comments.</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div>-Chandler</div><div><br></div>
</font></span><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>