[PATCH] Make it easier to bootstrap llvm using cmake

Andy Gibbs andyg1001 at hotmail.co.uk
Mon Jun 24 08:20:17 PDT 2013


Hi,

At the moment it is not very easy to compile a complete 
llvm+clang+lld+lldb+polly toolchain using cmake if your system has a C/C++ 
compiler that is too old or too new.  There has been some discussion about 
bootstrapping on this mailing list, but it is still a complex affair.

The attached patch makes the process a little more straight-forward by 
implementing two simple changes.  It is most likely in lieu of a more 
holistic approach, but perhaps it can be considered as a step in the right 
direction.

The first part of the patch is a change to CMakeLists.txt and 
cmake/config-ix.cmake to enable LLVM_TARGETS_TO_BUILD to understand the 
value "host" like the autotools make system.

The second part is a change to tools/CMakeLists.txt to enable 
LLVM_INCLUDE_TOOLS to be set to "bootstrap-only" to enable clang to be 
included in the build but not lld, lldb or polly.  This is necessary since 
lld, for example, requires -std=c++11 and cmake fails if the host compiler 
doesn't support this.

Following this patch, a bootstrap build can now be done the following way:

$ mkdir bootstrap
$ cd bootstrap
$ cmake -G 'Unix Makefiles'
        -DCMAKE_BUILD_TYPE:STRING=Release
        -DCMAKE_PREFIX_PATH:STRING=$(pwd)
        -DLLVM_TARGETS_TO_BUILD:STRING=host
        -DLLVM_INCLUDE_TOOLS:STRING=bootstrap-only
        ../source
$ make clang  # build clang only for host

$ cd ..
$ export CC=$(realpath bootstrap/bin)/clang
$ export CXX=$(realpath bootstrap/bin)/clang++

$ mkdir final
$ cd final
$ cmake -G 'Unix Makefiles' ../source
$ make all check-all

The above build doesn't include libc++ or libc++abi, but these are 
relatively straight-forward steps to include inbetween the bootstrap and 
final stages.

Please would someone like to have a look at the patch attached, and let me 
know if it is useful at all, and if I may commit it or not.

Many thanks,

Andy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bootstrap.diff
Type: application/octet-stream
Size: 2843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130624/f9e44b2d/attachment.obj>


More information about the llvm-commits mailing list