[cmake-developers] Using CMake to bootstrap clang builtins

Chris Bieneman chris.bieneman at me.com
Fri Oct 30 15:05:46 EDT 2015


CMake-developers,

An issue with our compiler-rt CMake builds came to my attention yesterday, and I’m wondering how to best deal with it.

Compiler-rt is a bit of a special flower. One part of it is a bunch of runtime libraries, which are basically just dylibs and static archives, nothing to wonky. The other part of compiler-rt is the clang builtins library. That’s the complicated bit.

We do a bunch of checks throughout our cmake/config-ix.cmake file that test for compiler flags and supported architectures. This is all great except try_compile does exactly what we want for tests relating to the runtime libraries, but builtins are special. When we build the builtins we don’t care if the linker works. In fact, we only need the compiler and archiver to work, and there are situations where the linker won’t work. For example, the linker won’t work if you are bootstrapping a cross compiler from nothing.

In the bootstrapping scenario you have a host toolchain that you use to build a compiler that runs on host targeting another OS or architecture. Then you use that compiler to build the builtins. The linker is never invoked, which is important because the linker can’t succeed until you have a builtin library.

Here’s my question. Is there any equivalent of try_compile that will test building a static archive instead of an executable? I can hand roll something, but I’d prefer not to because we need try_compile and check_cxx_compiler_flag, and I suspect this could get complicated.

Thanks,
-Chris


More information about the cmake-developers mailing list