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

Ben Pope benpope81 at gmail.com
Tue Nov 25 02:35:24 PST 2014


On Tuesday, November 25, 2014 05:03 PM, Dave Yost wrote:
>
> Does someone have a working shell script that builds and installs clang
> and libc++ on linux using gcc?

No.

> I’ve been trying to follow the instructions at http://libcxx.llvm.org to
> build on linux, where it says

These should be fine.

>     The following instructions are for building libc++ on FreeBSD,
>     Linux, or Mac using libc++abi <http://libcxxabi.llvm.org/> as the
>     C++ ABI library. On Linux, it is also possible to use libsupc++
>     <http://libcxx.llvm.org/#libsupcxx> or libcxxrt
>     <http://libcxx.llvm.org/#libcxxrt>.
>
>     In-tree build:
>
>       o Check out libcxx and libcxxabi <http://libcxxabi.llvm.org/> into
>         llvm/projects
>       o |cd llvm|
>       o |mkdir build && cd build|
>       o |cmake .. # Linux may require -DCMAKE_C_COMPILER=clang
>         -DCMAKE_CXX_COMPILER=clang++|
>       o |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.

No, clang or llvm does not need to be built first.

> Here’s an example of an attempt:
> ...
> 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)

Right, so it's trying to compile with your system compiler, which is gcc 
4.4.7, and it needs gcc of at least 4.7.

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

Are you trying to use gcc to build or clang to build?

> 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.

It's telling you that YOU need to delete CMakeCache...

> 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++

Because these variables have changed.

> -- 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.

Delete CMakeCache, and point cmake to a version of GCC of at least 4.7.

Ben





More information about the cfe-dev mailing list