[cfe-dev] trouble building clang with libc++ on linux

Dave Yost Dave at Yost.com
Tue Nov 25 01:03:39 PST 2014


Does someone have a working shell script that builds and installs clang and libc++ on linux using gcc?

I’ve been trying to follow the instructions at http://libcxx.llvm.org to build on linux, where it says
The following instructions are for building libc++ on FreeBSD, Linux, or Mac using libc++abi as the C++ ABI library. On Linux, it is also possible to use libsupc++ or libcxxrt.

In-tree build:

Check out libcxx and libcxxabi into llvm/projects
cd llvm
mkdir build && cd build
cmake .. # Linux may require -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
make cxx
I can’t tell what libsupc++ or libcxxrt are for from these pages, so I’m ignoring that.

I take it that the above instructions assume that I have already built clang. Right? It doesn’t say so.

Here’s an example of an attempt:

0 Tue 0:56:53 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src
568 Z% ls -l projects
total 12
-rw-r--r--. 1 yost mill  999 Feb 27  2014 CMakeLists.txt
lrwxrwxrwx. 1 yost mill   27 Nov 24 15:10 compiler-rt -> ../../compiler-rt-3.5.0.src
lrwxrwxrwx. 1 yost mill   22 Nov 24 15:10 libcxx -> ../../libcxx-3.5.0.src
lrwxrwxrwx. 1 yost mill   25 Nov 24 15:10 libcxxabi -> ../../libcxxabi-3.5.0.src
-rw-r--r--. 1 yost mill  664 Dec 12  2011 LLVMBuild.txt
-rw-r--r--. 1 yost mill 1013 Mar 12  2014 Makefile
0 Tue 0:56:54 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src
569 Z% mkdir build ; cd build
0 Tue 0:56:59 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
570 Z% cmake ..
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
...
CMake Error at cmake/modules/HandleLLVMOptions.cmake:13 (message):
  Host GCC version must be at least 4.7!
Call Stack (most recent call first):
  CMakeLists.txt:315 (include)


-- Configuring incomplete, errors occurred!
See also "/usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build/CMakeFiles/CMakeOutput.log".
See also "/usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build/CMakeFiles/CMakeError.log".
1 Tue 0:57:10 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
571 Z% which g++
/usr/local/gcc/4.8.2/bin/g++
0 Tue 0:57:26 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
572 Z% 

It seems that cmake doesn’t bother to look in my PATH, so I try saying exactly where to find clang.

0 Tue 1:00:18 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
815 Z% cmake -DCMAKE_C_COMPILER=/usr/local/llvm/3.5.0/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/llvm/3.5.0/bin/clang++ ..
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Sphinx disabled.
CMake Error at cmake/modules/HandleLLVMOptions.cmake:13 (message):
  Host GCC version must be at least 4.7!
Call Stack (most recent call first):
  CMakeLists.txt:315 (include)


-- Configuring incomplete, errors occurred!
See also "/usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build/CMakeFiles/CMakeOutput.log".
See also "/usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build/CMakeFiles/CMakeError.log".
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/llvm/3.5.0/bin/clang
CMAKE_CXX_COMPILER= /usr/local/llvm/3.5.0/bin/clang++

-- Generating done
-- Build files have been written to: /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
1 Tue 1:00:49 yost s6 /usr/local/modulebuild/llvm/3.5.0..libc++/build/llvm-3.5.0.src/build
816 Z% 

Still it seems to be looking for gcc in /usr/bin/. Why?

I am on a CentOS system, with old versions of tools in /usr and /usr/bin. Everything I build with has to come from PATH, etc.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141125/765c3770/attachment.html>


More information about the cfe-dev mailing list