[LLVMdev] compiler-rt CMake build

Brad King brad.king at kitware.com
Thu Feb 6 07:20:41 PST 2014


On 02/06/2014 08:12 AM, Alexey Samsonov wrote:
> Please note that it makes a lot of sense to built compiler-rt (and sanitizers) with just-built
> Clang. In fact, even though we should support building it with another compilers (gcc, MSVC),
> using just-built-Clang should be a default scenario, like it is in configure+make build.

This is possible with CMake using the ExternalProject module:

 http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:ExternalProject

The add_llvm_external_project macro already in LLVM could be taught
to call ExternalProject_Add instead of add_subdirectory.  This could
create a custom target with dependencies appropriately configured to
build after Clang.  The custom target would run CMake to configure the
project like an outside build and then launch the build.

IIUC there is a desire for Clang to be able to be built externally to
LLVM rather than subsumed into its build process.  The top-level
CMakeLists.txt file of Clang already has code to do that, though it
can be much cleaner after my patches to LLVM to provide LLVMConfig.cmake
are integrated.  Then it will even be possible to build Clang using
CMake against a LLVM that was built and installed using configure+make.

If one would like to drive compiler-rt as part of testing a Clang built
outside of LLVM then the appropriate place for the ExternalProject_Add
call would be inside the build of Clang.

Either way, from a quick glance at the top-level CMakeLists.txt file
in compiler-rt it appears to want to know a bunch of information about
Clang rather than LLVM.  In this case having Clang export enough info
for applications to write find_package(Clang) would make sense.  This
is possible to do an can be implemented using techniques similar to
that in my proposed LLVMConfig.cmake patch series.

-Brad




More information about the llvm-dev mailing list