<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <b>System:</b> Debian Linux Sid/Unstable amd64<br>
    <br>
    <b>LLVM/Clang:</b> Trunk<br>
    <br>
    <b>Scenario:</b> In the past couple of days I've been compiling
    against trunk I get two separate and spurious hang ups with CMake.<br>
    <br>
    <b>Note:</b> I build against more than just X86 follow along the
    progress of other platforms, though just building for X86 produces
    the same results below.<br>
    <br>
    <b>Assumption:</b> Configure cmake with prior built clang and
    clang++ via gcc-4.6.3 under /usr/local/bin... /clang .../clang++ as
    follows:<br>
    <br>
    <blockquote type="cite">mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
      cmake -DCMAKE_BUILD_TYPE=MinSizeRel
      -DCMAKE_CXX_COMPILER=/usr/local/bin/clang++
      -DCMAKE_C_COMPILER=/usr/local/bin/clang -DCMAKE_CXX_FLAGS='-O2'
      CMAKE_C_FLAGS='-O2' -DLLVM_BUILD_EXAMPLES=ON -DLLVM_BUILD_TESTS=ON
      -DLLVM_INCLUDE_TESTS=ON
      -DLLVM_TARGETS_TO_BUILD='ARM;CppBackend;PTX;Hexagon;X86'
      ../trunk/llvm/<br>
      -- Target triple: x86_64-unknown-linux-gnu<br>
      -- Native target architecture is X86<br>
      -- Threads enabled.<br>
      -- Building with -fPIC<br>
      -- Constructing LLVMBuild project information<br>
      -- Targeting ARM<br>
      -- Targeting CppBackend<br>
      -- Targeting PTX<br>
      -- Targeting Hexagon<br>
      -- Targeting X86<br>
      -- Clang version: 3.1<br>
      -- Configuring done<br>
      You have changed variables that require your cache to be deleted.<br>
      Configure will be re-run and you may have to reset some variables.<br>
      The following variables have changed:<br>
      CMAKE_C_COMPILER= /usr/local/bin/clang<br>
      CMAKE_CXX_COMPILER= /usr/local/bin/clang++<br>
      <br>
      -- The C compiler identification is Clang<br>
      -- The CXX compiler identification is Clang<br>
      -- Check for working C compiler: /usr/local/bin/clang<br>
      -- Check for working C compiler: /usr/local/bin/clang -- works<br>
      -- Detecting C compiler ABI info<br>
      -- Detecting C compiler ABI info - done<br>
      -- Check for working CXX compiler: /usr/local/bin/clang++<br>
      -- Check for working CXX compiler: /usr/local/bin/clang++ --
      broken<br>
      CMake Error at
      /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45
      (MESSAGE):<br>
        The C++ compiler "/usr/local/bin/clang++" is not able to compile
      a simple<br>
        test program.<br>
      <br>
        It fails with the following output:<br>
      <br>
         Change Dir:
/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp<br>
      <br>
        <br>
      <br>
        Run Build Command:/usr/bin/make "cmTryCompileExec/fast"<br>
      <br>
        /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make<br>
        CMakeFiles/cmTryCompileExec.dir/build<br>
      <br>
        make[1]: Entering directory<br>
       
`/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp'<br>
      <br>
      <br>
        /usr/bin/cmake -E cmake_progress_report<br>
       
/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp/CMakeFiles<br>
        1<br>
      <br>
        Building CXX object
      CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o<br>
      <br>
        /usr/local/bin/clang++ -o<br>
        CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c<br>
       
/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp/testCXXCompiler.cxx<br>
      <br>
      <br>
        Linking CXX executable cmTryCompileExec<br>
      <br>
        /usr/bin/cmake -E cmake_link_script<br>
        CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1<br>
      <br>
        /usr/local/bin/clang++<br>
        CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -o
      cmTryCompileExec<br>
        -rdynamic<br>
      <br>
        /usr/bin/ld: error: cannot find -lstdc++<br>
      <br>
        clang-3: error: linker command failed with exit code 1 (use -v
      to see<br>
        invocation)<br>
      <br>
        make[1]: Leaving directory<br>
       
`/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp'<br>
      <br>
      <br>
        make[1]: *** [cmTryCompileExec] Error 1<br>
      <br>
        make: *** [cmTryCompileExec/fast] Error 2<br>
      <br>
        <br>
      <br>
        <br>
      <br>
        CMake will not be able to correctly generate this project.<br>
      Call Stack (most recent call first):<br>
        CMakeLists.txt:3 (project)<br>
      <br>
      <br>
      -- Configuring incomplete, errors occurred!<br>
      mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$</blockquote>
    <br>
    <br>
    <br>
    Now out of curriousity I change clang++ to clang-3.1 which of course
    has two symlinks [clang and clang++] under /usr/local/bin<br>
    <br>
    If I configure and attempt to make against the following:<br>
    <br>
    <blockquote type="cite">mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
      cmake -DCMAKE_BUILD_TYPE=MinSizeRel
      -DCMAKE_CXX_COMPILER=/usr/local/bin/clang-3.1
      -DCMAKE_C_COMPILER=/usr/local/bin/clang-3.1
      -DCMAKE_CXX_FLAGS='-O2' CMAKE_C_FLAGS='-O2'
      -DLLVM_BUILD_EXAMPLES=ON -DLLVM_BUILD_TESTS=ON
      -DLLVM_INCLUDE_TESTS=ON
      -DLLVM_TARGETS_TO_BUILD='ARM;CppBackend;PTX;Hexagon;X86'
      ../trunk/llvm/<br>
      -- Target triple: x86_64-unknown-linux-gnu<br>
      -- Native target architecture is X86<br>
      -- Threads enabled.<br>
      -- Building with -fPIC<br>
      -- Constructing LLVMBuild project information<br>
      -- Targeting ARM<br>
      -- Targeting CppBackend<br>
      -- Targeting PTX<br>
      -- Targeting Hexagon<br>
      -- Targeting X86<br>
      -- Clang version: 3.1<br>
      -- Configuring done<br>
      -- Generating done<br>
      -- Build files have been written to:
      /home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm<br>
      mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$</blockquote>
    <br>
    <b>Result:</b><br>
    <br>
    <blockquote type="cite">mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
      make -j3<br>
      Scanning dependencies of target LLVMHello<br>
      [  0%] Building CXX object
      lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/Hello.cpp.o                       
       <br>
      Scanning dependencies of target
      profile_rt-shared                                                          
       <br>
      Scanning dependencies of target
      LLVMSupport                                                                
       <br>
      [  0%] Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/BasicBlockTracing.c.o         
       <br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/lib/Transforms/Hello/Hello.cpp:16:<br>
      <b>/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/Pass.h:32:10:
        fatal error: 'string'<br>
              file not found<br>
        #include <string></b><br>
               ^<br>
      [  0%] Building CXX object
      lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o                            
       <br>
      [  0%] Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/CommonProfiling.c.o           
       <br>
      In file included from
      /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/lib/Support/APFloat.cpp:15:
      <br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/APFloat.h:104:<br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/APInt.h:18:<br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/ArrayRef.h:13:<br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/SmallVector.h:17:<br>
      In file included from
/home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/Support/type_traits.h:20:<br>
      <b>/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/include/llvm/Support/DataTypes.h:36:10:
        fatal
        error:                                                                                                         
         <br>
              'cmath' file not found<br>
        #include <cmath></b><br>
               ^<br>
      [  0%] Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/GCDAProfiling.c.o             
       <br>
      [  0%] Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/PathProfiling.c.o             
       <br>
      1 error
      generated.                                                                                         
       <br>
      make[2]: ***
      [lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/Hello.cpp.o] Error
      1<br>
      make[1]: *** [lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/all]
      Error 2<br>
      make[1]: *** Waiting for unfinished jobs....<br>
      1 error generated.<br>
      [  0%] make[2]: ***
      [lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o] Error 1<br>
      make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2<br>
      [  0%] Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/EdgeProfiling.c.o<br>
      Building C object
      runtime/libprofile/CMakeFiles/profile_rt-shared.dir/OptimalEdgeProfiling.c.o             
       <br>
      Linking C shared library
      ../../lib/profile_rt.so                                                           
       <br>
      [  0%] Built target
      profile_rt-shared                                                                      
       <br>
      make: *** [all] Error 2<br>
      mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$</blockquote>
    <br>
    Of course if I configure as follows:;<br>
    <br>
    <blockquote type="cite">mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
      cmake -DCMAKE_BUILD_TYPE=MinSizeRel
      -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc
      -DCMAKE_CXX_FLAGS='-O2' CMAKE_C_FLAGS='-O2'
      -DLLVM_BUILD_EXAMPLES=ON -DLLVM_BUILD_TESTS=ON
      -DLLVM_INCLUDE_TESTS=ON
      -DLLVM_TARGETS_TO_BUILD='ARM;CppBackend;PTX;Hexagon;X86'
      ../trunk/llvm/<br>
    </blockquote>
    <br>
    <b>Results:</b> after rebuilding the cache and rerunning the
    configuration twice the end is that LLVM/Clang <b>builds cleanly</b>.
    None of the noise above about clang++ failing to be able to build a
    simple c++ program nor the missing string and cmath header files.<br>
    <br>
    Perhaps this is just a Debian Linux issue and has to do with
    upgrades to LSB 4.1 [Linux Standard Base 4.1], but then I don't know
    enough about LSB to know exactly how a compiler infrastructure would
    be impacted by it, if at all. [<a
href="http://www.linuxfoundation.org/collaborate/workgroups/lsb/lsb-41-release-notes]">http://www.linuxfoundation.org/collaborate/workgroups/lsb/lsb-41-release-notes]</a><br>
    <br>
    NOTE: (The work on Libc++ under libcxx being put under /runtime and
    recognized by Cmake is still not working, from what I've seen,
    though work on it around 2 weeks prior was mentioned it would get
    added for Linux)<br>
    <br>
    - Marc<br>
    <div class="moz-signature">-- <br>
      Marc J. Driftmeyer<br>
      Email :: <a href="mailto:mjd@reanimality.com">mjd@reanimality.com</a><br>
      Web :: <a href="http://www.reanimality.com">http://www.reanimality.com</a><br>
      Cell :: (509) 435-5212
    </div>
  </body>
</html>