[cmake-developers] Supporting monolithic and efficient CMake + Ninja builds for LLVM developers

Chris Bieneman chris.bieneman at me.com
Thu Aug 6 18:55:06 EDT 2015


Stephen Kelly wrote:

> Chris Bieneman wrote:
> 
>> (resending now that I’ve subscribed to cmake-developers)
>> 
>> Hello CMake-Developers,
>> 
>> I’m a contributor to the LLVM project working on improving our CMake-based
>> build process, and I had a request I wanted to discuss with your
>> community.
>> 
>> This is related to a feature request I filed
>> (http://public.kitware.com/Bug/view.php?id=15679
>> <http://public.kitware.com/Bug/view.php?id=15679>), and one of the efforts
>> I’ve been driving in the LLVM community
>> (http://lists.llvm.org/pipermail/llvm-dev/2015-July/088751.html
>> <http://lists.llvm.org/pipermail/llvm-dev/2015-July/088751.html>).
>> 
>> The complication for us is that because we’re building a compiler, and we
>> can be targeting multiple operating systems and architectures within the
>> same build, we want to be able to leverage CMake’s ability to detect the
>> toolchain and target capabilities, which means invoking CMake multiple
>> times.
> 
> What exactly do you mean by 'detect the toolchain and target capabilities'? 
> What are the needs? Detecting things by running the compiler, or making use 
> of the knowledge that is hardcoded into CMake Modules files?

Basically we want to be able to leverage all the checks that CMake runs detecting compiler and linker flags, headers, libraries, and supported features.

One big things I’m working on is improving the way we build our runtime libraries. These libraries are built for the targets that the compiler supports generating code for, so they can use different architectures, headers, and libraries than are used to build the compiler itself. CMake does a great job of finding libraries and constructing the compiler commands, and we want to leverage that instead of re-implementing it.

> 
>> One of our common uses is building clang. When we build clang it is built
>> with the ability to target a set of architectures. We then need to use the
>> just-built clang to build the runtime libraries for each of the supported
>> targets (which may not match the host operating system or architecture).
> 
> You might investigate doing something like
> 
>  # Don't let CMake use the c++ compiler for .cpp files in this directory
>  unset(CMAKE_CXX_SOURCE_FILE_EXTENSIONS)
> 
>  set(CMAKE_CompilerRT_COMPILER $<TARGET_FILE:JustBuiltClang>)
>  # Use the just built clang to build C++ files:
>  set(CMAKE_CompilerRT_SOURCE_FILE_EXTENSIONS cpp)
>  enable_language(CompilerRT)
> 
>  # Language is CompilerRT, not CXX, so JustBuiltClang is used
>  add_library(compiler-rt compiler-rt.cpp)
> 
> and some other hacks maybe. Note that the above won't work currently because 
> CMAKE_FOO_COMPILER does not support generator expressions. I also haven't 
> tried it.

This would be interesting (and may actually be a great way to hook up our test suite), but we wouldn’t be able to leverage the checks that CMake does for C++ header and library support.

-Chris

> 
> Thanks,
> 
> Steve.


More information about the cmake-developers mailing list