[cfe-dev] Building past few days with Clang++ and Clang produces errors on Cmake for Debian Linux

Marc J. Driftmeyer mjd at reanimality.com
Mon Apr 2 23:38:33 PDT 2012


*Resolution:* After doing an strace on the clang++ executable generated 
from gcc builds of llvm/clang I discovered some polluted gcc-4.7 
intermixed and I had yet to install libstdc++6 (4.7) to build against.

After doing so clang/clang++ worked as expected and have been doing so 
for well over a year of nightly builds from trunk.

Unfortunately, I have a dilemma seeing as gcc/g++/cpp are all presently 
configured by Debian to target gcc-4.6 and therefore should not even 
have polluted the includes directories with anything but libstdc++6 
(4.6.3) but that is an issue for Debian who seems to update it's libs in 
a mixed fashion without properly updating updates-alternatives for gcc 
to point to gcc-4.7 or until they have more of their distribution 
updated to hold both versions of libstdc++6 for 4.6.3 and a 
differentiated naming convention for the upcoming version, 4.7 instead 
of blatantly rewriting over the 4.6.3 libstdc++6 package with the 4.7 
revision.

- Marc

On 03/27/2012 06:14 PM, Marc J. Driftmeyer wrote:
> *System:* Debian Linux Sid/Unstable amd64
>
> *LLVM/Clang:* Trunk
>
> *Scenario:* In the past couple of days I've been compiling against 
> trunk I get two separate and spurious hang ups with CMake.
>
> *Note:* I build against more than just X86 follow along the progress 
> of other platforms, though just building for X86 produces the same 
> results below.
>
> *Assumption:* Configure cmake with prior built clang and clang++ via 
> gcc-4.6.3 under /usr/local/bin... /clang .../clang++ as follows:
>
>> mdriftmeyer at 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/
>> -- Target triple: x86_64-unknown-linux-gnu
>> -- Native target architecture is X86
>> -- Threads enabled.
>> -- Building with -fPIC
>> -- Constructing LLVMBuild project information
>> -- Targeting ARM
>> -- Targeting CppBackend
>> -- Targeting PTX
>> -- Targeting Hexagon
>> -- Targeting X86
>> -- Clang version: 3.1
>> -- Configuring done
>> You have changed variables that require your cache to be deleted.
>> Configure will be re-run and you may have to reset some variables.
>> The following variables have changed:
>> CMAKE_C_COMPILER= /usr/local/bin/clang
>> CMAKE_CXX_COMPILER= /usr/local/bin/clang++
>>
>> -- The C compiler identification is Clang
>> -- The CXX compiler identification is Clang
>> -- Check for working C compiler: /usr/local/bin/clang
>> -- Check for working C compiler: /usr/local/bin/clang -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Check for working CXX compiler: /usr/local/bin/clang++
>> -- Check for working CXX compiler: /usr/local/bin/clang++ -- broken
>> CMake Error at 
>> /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 (MESSAGE):
>>   The C++ compiler "/usr/local/bin/clang++" is not able to compile a 
>> simple
>>   test program.
>>
>>   It fails with the following output:
>>
>>    Change Dir: 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp
>>
>>
>>
>>   Run Build Command:/usr/bin/make "cmTryCompileExec/fast"
>>
>>   /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
>>   CMakeFiles/cmTryCompileExec.dir/build
>>
>>   make[1]: Entering directory
>>   
>> `/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp'
>>
>>
>>   /usr/bin/cmake -E cmake_progress_report
>>   
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp/CMakeFiles
>>   1
>>
>>   Building CXX object 
>> CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o
>>
>>   /usr/local/bin/clang++ -o
>>   CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c
>>   
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
>>
>>
>>   Linking CXX executable cmTryCompileExec
>>
>>   /usr/bin/cmake -E cmake_link_script
>>   CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
>>
>>   /usr/local/bin/clang++
>>   CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -o 
>> cmTryCompileExec
>>   -rdynamic
>>
>>   /usr/bin/ld: error: cannot find -lstdc++
>>
>>   clang-3: error: linker command failed with exit code 1 (use -v to see
>>   invocation)
>>
>>   make[1]: Leaving directory
>>   
>> `/home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/CMakeFiles/CMakeTmp'
>>
>>
>>   make[1]: *** [cmTryCompileExec] Error 1
>>
>>   make: *** [cmTryCompileExec/fast] Error 2
>>
>>
>>
>>
>>
>>   CMake will not be able to correctly generate this project.
>> Call Stack (most recent call first):
>>   CMakeLists.txt:3 (project)
>>
>>
>> -- Configuring incomplete, errors occurred!
>> mdriftmeyer at horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
>
>
>
> Now out of curriousity I change clang++ to clang-3.1 which of course 
> has two symlinks [clang and clang++] under /usr/local/bin
>
> If I configure and attempt to make against the following:
>
>> mdriftmeyer at 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/
>> -- Target triple: x86_64-unknown-linux-gnu
>> -- Native target architecture is X86
>> -- Threads enabled.
>> -- Building with -fPIC
>> -- Constructing LLVMBuild project information
>> -- Targeting ARM
>> -- Targeting CppBackend
>> -- Targeting PTX
>> -- Targeting Hexagon
>> -- Targeting X86
>> -- Clang version: 3.1
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm
>> mdriftmeyer at horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
>
> *Result:*
>
>> mdriftmeyer at horus:~/DeveloperProjects/LLVMProject/cmake-llvm$ make -j3
>> Scanning dependencies of target LLVMHello
>> [  0%] Building CXX object 
>> lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/Hello.cpp.o
>> Scanning dependencies of target profile_rt-shared
>> Scanning dependencies of target LLVMSupport
>> [  0%] Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/BasicBlockTracing.c.o 
>>
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/lib/Transforms/Hello/Hello.cpp:16:
>> */home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/Pass.h:32:10: 
>> fatal error: 'string'
>>       file not found
>> #include <string>*
>>          ^
>> [  0%] Building CXX object 
>> lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o
>> [  0%] Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/CommonProfiling.c.o
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/lib/Support/APFloat.cpp:15: 
>>
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/APFloat.h:104:
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/APInt.h:18:
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/ArrayRef.h:13:
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/ADT/SmallVector.h:17:
>> In file included from 
>> /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/include/llvm/Support/type_traits.h:20:
>> */home/mdriftmeyer/DeveloperProjects/LLVMProject/cmake-llvm/include/llvm/Support/DataTypes.h:36:10: 
>> fatal error:
>>       'cmath' file not found
>> #include <cmath>*
>>          ^
>> [  0%] Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/GCDAProfiling.c.o
>> [  0%] Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/PathProfiling.c.o
>> 1 error generated.
>> make[2]: *** 
>> [lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/Hello.cpp.o] Error 1
>> make[1]: *** [lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/all] Error 2
>> make[1]: *** Waiting for unfinished jobs....
>> 1 error generated.
>> [  0%] make[2]: *** 
>> [lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o] Error 1
>> make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
>> [  0%] Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/EdgeProfiling.c.o
>> Building C object 
>> runtime/libprofile/CMakeFiles/profile_rt-shared.dir/OptimalEdgeProfiling.c.o 
>>
>> Linking C shared library ../../lib/profile_rt.so
>> [  0%] Built target profile_rt-shared
>> make: *** [all] Error 2
>> mdriftmeyer at horus:~/DeveloperProjects/LLVMProject/cmake-llvm$
>
> Of course if I configure as follows:;
>
>> mdriftmeyer at 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/
>
> *Results:* after rebuilding the cache and rerunning the configuration 
> twice the end is that LLVM/Clang *builds cleanly*. 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.
>
> 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. 
> [http://www.linuxfoundation.org/collaborate/workgroups/lsb/lsb-41-release-notes]
>
> 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)
>
> - Marc
> -- 
> Marc J. Driftmeyer
> Email :: mjd at reanimality.com <mailto:mjd at reanimality.com>
> Web :: http://www.reanimality.com
> Cell :: (509) 435-5212
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-- 
Marc J. Driftmeyer
Email :: mjd at reanimality.com <mailto:mjd at reanimality.com>
Web :: http://www.reanimality.com
Cell :: (509) 435-5212
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120402/d6797334/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mjd.vcf
Type: text/x-vcard
Size: 317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120402/d6797334/attachment.vcf>


More information about the cfe-dev mailing list