Guidance / examples of adding subprojects to a monorepo branch

Hi,

The move to a single repo has greatly simplified building llvm. Thank you.

I work on a toolchain which is essentially llvm plus a lot of runtime libraries. They’re all checked out next to each other and built in a sequence. Some of the libraries need the just built clang to compile.

I would like to instead check out each runtime as a subproject within llvm and build the whole lot via one cmake invocation. Maybe even with correct incremental builds.

However, my grasp of cmake is limited and the cross compilation aspect has thwarted me. Please could you offer a pointer on how to wire this up, or even better, some project on GitHub which already assembles such a llvm+libs combination that I can copy from.

Thanks!

Jon

I can’t speak with complete experience since my team is still working on it, but I believe the LLVM ‘runtimes’ feature might be what you’re looking for. I believe it has support for adding third party runtime projects that use CMake by checking out the directories into llvm/runtimes. Our team has used it to build libcxx/libcxxabi/libunwind/compiler-rt builtins and profile with just-built compilers, but this code is unfortunately not public to show you. However, examples of cache files are in clang/cmake/caches. Of specific note is the Fuchsia cache files, which have a 2-stage toolchain build followed by a runtimes build using the just-built compiler.

If you utilize this feature, you’ll get the ability to build everything within one cmake invocation, and even be able to install the libraries automatically as part of the distribution. There’s also support for the concept of ‘multilibs’, which allow for building runtimes with the same target but slightly different options. This is helpful if you need variations with C++ exception support and variations without, for example.

There are a few snags we ran into, specifically:

  • https://reviews.llvm.org/D71570
  • An issue where LLVM_* configurations are overridden by the just-built clang value, rather than the runtimes-configured value

I found the following information helpful:

JB