<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi,<br>
    </p>
    <div class="moz-cite-prefix">On 2/19/20 4:02 PM, Richard Smith
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAOfiQqkKwFgJhgKwUnJbuaD_joW9PUCyky2S+ZYxOcu4PKFT_g@mail.gmail.com">
      
      <div dir="ltr">I have a two-stage setup that builds a GCC-free
        Clang except for libgcc_s (I've not looked at what's pulling
        that in yet, but I expect that's resolvable).<br>
        <div class="gmail_quote">
          <div><br>
          </div>
          <div>My stage1 cmake setup
            has: -DCLANG_DEFAULT_CXX_STDLIB=libc++
            -DCLANG_DEFAULT_RTLIB=compiler-rt</div>
          <div>My stage2 cmake setup additionally
            has: -DLIBCXXABI_USE_LLVM_UNWINDER=ON
            -DLIBCXXABI_USE_COMPILER_RT=ON -DLIBCXX_USE_COMPILER_RT=ON</div>
          <div>(and points CMAKE_C_COMPILER and CMAKE_CXX_COMPILER at
            the stage1 clang).</div>
        </div>
      </div>
    </blockquote>
    <p>Many thanks for this. I got further (I think) but I'm still
      hitting a snag (see below).<br>
    </p>
    <p>I'm attempting to use the cache method per the guide (latest
      caches attached), and I'm invoking them with:</p>
    <pre>+ env CC=clang CXX=clang++ cmake -GNinja -C /home/greenc/work/cet-is/test-products/clang/v9_0_1/patch/FNAL.cmake -DCMAKE_INSTALL_PREFIX=/home/greenc/work/cet-is/test-products/clang/v9_0_1/Linux64bit+3.10-2.17 -DBOOTSTRAP_LLVM_CXX_STD=c++17 -S ../../src/clang-9.0.1/llvm -B /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17
</pre>
    <p>and<br>
    </p>
    <pre>+ cmake --build /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17 -j 25 --target stage2 --
</pre>
    <p>where <tt>which clang</tt> returns:</p>
    <pre>/home/greenc/work/cet-is/test-products/clang/v7_0_0/Linux64bit+3.10-2.17/bin/clang
</pre>
    <p>and the default C++ standard library for this compiler is libc++.</p>
    <p>I'm also attempting to build with C++17 (see command line) to
      allow for a later build of flang against the installed new
      compiler. Eventually I hope to get all the right components listed
      to be able to do a distribution installation such that the
      installed distribution is relocatable and able to operate as an
      SDK against which to compile other tools such as flang, castxml
      and include-what-you-use.</p>
    <p>I appear to be getting through the compilation of the compiler,
      builtins, linker and basic tools (llvm-ar, llvm-nm, <i>etc.</i>),
      but I'm experiencing a failure with the next compilation stage
      (full log attached, bzipped to 28K). During the runtimes
      configuration step I'm getting a worrying message about ranlib:</p>
    <pre>/home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/bin/llvm-ar: warning: creating t.a
/home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/bin/llvm-ranlib: error: Exactly one archive should be specified.
</pre>
    <p>There are a couple of CMake policy warnings (CMP0077), and then
      when we try to perform the configure step for "stage2", we get:</p>
    <pre>-- Check for working CXX compiler: /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/./bin/clang++
-- Check for working CXX compiler: /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/./bin/clang++ -- broken
CMake Error at /home/greenc/work/cet-is/test-products/cmake/v3_14_3/Linux64bit+3.10-2.17/share/cmake-3.14/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "/home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/./bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/tools/clang/stage2-bins/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/home/greenc/work/cet-is/test-products/ninja/v1_10_0/Linux64bit+3.10-2.17/bin/ninja cmTC_f1b67 
    [1/2] Building CXX object CMakeFiles/cmTC_f1b67.dir/testCXXCompiler.cxx.o
    [2/2] Linking CXX executable cmTC_f1b67
    FAILED: cmTC_f1b67 
    : && /home/greenc/work/cet-is/test-products/clang/v9_0_1/build/Linux64bit+3.10-2.17/./bin/clang++  -fno-stack-protector -fno-common -Wno-profile-instr-unprofiled   CMakeFiles/cmTC_f1b67.dir/testCXXCompiler.cxx.o  -o cmTC_f1b67   && :
    /usr/bin/ld: cannot find -lc++
</pre>
    <p>Indeed, libc++ has not been built.</p>
    <p>I'm obviously doing something silly, but I'm not able to
      ascertain from the documentation what it might be. I'll try again
      with a modern GCC (I'm on Scientific Linux 7, so the native GCC
      4.8.5 is insufficient) just in case the Clang compiler is not
      recent enough to handle this, but I'm not optimistic. Any pointers
      you can give me would be very much appreciated.</p>
    <p>Thanks for any help,</p>
    <p>Chris.<br>
    </p>
    <br>
  </body>
</html>