title: Building and using a pure llvm toolchain for c++ on linux
body: <p>Assuming this is possible, could someone tell me, how I have to configure the cmake build to create a "pure" llvm toolchain on ubuntu-16.04 consisting of </p>
  
  <ul>
  <li>clang </li>
  <li>lld</li>
  <li>libc++</li>
  <li>libc++abi </li>
  <li>libunwind (llvm)</li>
  <li>compiler-rt</li>
  <li>any other pieces that might be relevant and are "production ready"</li>
  </ul>
  
  <p>The resulting compiler should </p>
  
  <ul>
  <li>be as fast as possible (optimizations turned on, no unnecessary asserts or other checks in the compiler binary itself) </li>
  <li>be installed in a separate, local directory (lets call it <code>&lt;llvm_install&gt;</code>)</li>
  <li>not have dependencies to the llvm tolchain provided by packet manager</li>
  <li>use libc++, libc++abi etc by default. </li>
  <li>support the sanitizers (ubsan, address, memory, thread) (which probably means that I have to compile libc++ a <a href="https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo" rel="nofollow noreferrer">second time</a>)</li>
  </ul>
  
  <p>So far I have cloned </p>
  
  <ul>
  <li>llvm from <code>http://llvm.org/git/llvm.git</code> into <code>&lt;llvm_root&gt;</code></li>
  <li>clang from <code>http://llvm.org/git/clang.git</code> into <code>&lt;llvm_root&gt;/tools/clang</code></li>
  <li>lld from <code>http://llvm.org/git/lld.git</code> into <code>&lt;llvm_root&gt;/tools/lld</code></li>
  <li>compiler-rt, libcxx, libcxxabi, libunwind from <code>http://llvm.org/git/&lt;project_name&gt;</code> into <code>&lt;llvm_root&gt;/projects/&lt;project_name&gt;</code></li>
  </ul>
  
  <p>Then run ccmake in a separate directory - I have tried various settings, but as soon as I try anything more fancy beyond turning optimizations on, I almost always get some sort of build error. Unfortunately, I have yet to find a way to export my changes from ccmake otherwise I'd give you an example with the settings and according error, but I'm more interested in a best practice than a fix to my test configs anyway.</p>
  
  <p>Bonus points: By default, this should build with the default g++ toolchain, but I'd also be interested in a two stage build if that improves the performance of the final toolchain (e.g. by using LTO).</p>
  
  <p>Btw.: The whole Idea came from watching chandler's talk<br>
  <a href="https://www.youtube.com/watch?v=uZI_Qla4pNA" rel="nofollow noreferrer">Pacific++ 2017: Chandler Carruth "LLVM: A Modern, Open C++ Toolchain"</a>  </p>