[ZORG] Update ClangBuilder to build libc++ with clang

This change makes the Clang builder checkout libc++/abi and build on stage 2
of a selfhosting build (since we can't guarantee the host compiler will be
able to build it).
diff --git a/zorg/buildbot/builders/ClangBuilder.py b/zorg/buildbot/builders/ClangBuilder.py
index 027c8a1..96f0f18 100644
--- a/zorg/buildbot/builders/ClangBuilder.py
+++ b/zorg/buildbot/builders/ClangBuilder.py
@@ -3,6 +3,7 @@
 import copy
 import os
 from datetime import datetime
+import copy
 
 from buildbot.process.properties import WithProperties, Property
 from buildbot.steps.shell import Configure, ShellCommand, SetProperty
@@ -363,6 +364,7 @@
 def addSVNUpdateSteps(f,
                       checkout_clang_tools_extra,
                       checkout_compiler_rt,
+                      checkout_libcxx,
                       checkout_test_suite):
     # We *must* checkout at least Clang+LLVM
     f.addStep(SVN(name='svn-llvm',
@@ -518,7 +520,9 @@
 
             # Extra repositories
             checkout_clang_tools_extra=True,
-            checkout_compiler_rt=True):
+            checkout_compiler_rt=True,
+            checkout_libcxx=True):
+
     return _getClangCMakeBuildFactory(
                clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
                vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
@@ -559,6 +563,7 @@
             # Extra repositories
             checkout_clang_tools_extra=True,
             checkout_compiler_rt=True,
+            checkout_libcxx=True,
 
             # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
             stage1_upload_directory=None,
@@ -572,6 +577,7 @@
     addSVNUpdateSteps(f,
                       checkout_clang_tools_extra=checkout_clang_tools_extra,
                       checkout_compiler_rt=checkout_compiler_rt,
+                      checkout_libcxx=checkout_libcxx,
                       checkout_test_suite=runTestSuite)
 
     # If jobs not defined, Ninja will choose a suitable value
@@ -597,6 +603,10 @@
     stage2_build = 'stage2'
     stage2_install = 'stage2.install'
 
+    # LibUnwind extra CMake argument
+    if checkout_libcxx:
+      extra_cmake_args.extend(["-DLIBCXXABI_USE_LLVM_UNWINDER=True", "-DCMAKE_CXX_FLAGS=-std=c++11"])
+
     # Set up VS environment, if appropriate.
     if vs:
         f.addStep(SetProperty(
@@ -622,6 +632,14 @@
                               flunkOnFailure=False,
                               property="exists_ninja_1"))
 
+    # Make sure libcxx/cxxabi/unwind are not present for stage 1
+    f.addStep(ShellCommand(name='clean libcxx for stage 1',
+                           command=['rm','-f','libcxx','libcxxabi','libunwind'],
+                           warnOnFailure=True,
+                           description='cleaning libcxx for stage 1',
+                           descriptionDone='clean',
+                           workdir='llvm/projects',
+                           env=env))
 
     ############# STAGE 1
     f.addStep(ShellCommand(name='cmake stage 1',
@@ -689,6 +707,30 @@
                                workdir='.',
                                env=env))
 
+        # If we checked out libcxx, link it here
+        if checkout_libcxx:
+            f.addStep(ShellCommand(name='setup libcxx',
+                                   command=['ln','-s','../../libcxx'],
+                                   warnOnFailure=True,
+                                   description='linking libcxx into projects',
+                                   descriptionDone='libcxx set up',
+                                   workdir='llvm/projects',
+                                   env=env))
+            f.addStep(ShellCommand(name='setup libcxxabi',
+                                   command=['ln','-s','../../libcxxabi'],
+                                   warnOnFailure=True,
+                                   description='linking libcxxabi into projects',
+                                   descriptionDone='libcxxabi set up',
+                                   workdir='llvm/projects',
+                                   env=env))
+            f.addStep(ShellCommand(name='setup libunwind',
+                                   command=['ln','-s','../../libunwind'],
+                                   warnOnFailure=True,
+                                   description='linking libunwind into projects',
+                                   descriptionDone='libunwind set up',
+                                   workdir='llvm/projects',
+                                   env=env))
+
         # Set the compiler using the CC and CXX environment variables to work around
         # backslash string escaping bugs somewhere between buildbot and cmake. The
         # env.exe helper is required to run the tests, so hopefully it's already on
@@ -752,6 +794,7 @@
         cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
 
         # LNT Command line
+        # FIXME: If twoStage && libcxx, add --std=libc++ flags.
         if jobs is None:
             jobs = 1
         test_suite_cmd = [python, lnt, 'runtest', 'nt',