My end goal is to distribute a BOLT-optimzed, PGOed Clang with full LTO, plus static-only libc++. I don’t want any other component, runtime library, or tool, such as compiler-rt, libc++abi, libunwind, llvm-config, and so on, unless any of them are strict dependencies of either Clang or libc++ (I don’t know where to find this information).
I’m basing myself off this Dockerfile from the monorepo:
Except I’m setting -DLLVM_ENABLE_PROJECTS="bolt;clang" (I want to use mold instead of LLD), -DLLVM_DISTRIBUTION_COMPONENTS="" (I just want Clang), and -DLLVM_RUNTIME_DISTRIBUTION_COMPONENTS="libcxx" (and -DPGO_INSTRUMENT_LTO=Full, of course).
cmake --build build -t stage2-clang-bolt stage2-install-distribution runs fine (the only issue is that it always installs clang-format and clang-tidy for some reason, even though I never asked for them), but cmake --build build -t install-distribution errors out with:
gmake[4]: *** No rule to make target 'install-libcxx'. Stop.
CMake Error at /home/user/tmp/bs/cache/llvm-project/llvm/cmake/modules/FileLock.cmake:9 (execute_process):
execute_process failed command indexes:
1: "Child return code: 2"
gmake[3]: *** [runtimes/CMakeFiles/install-libcxx.dir/build.make:70: runtimes/CMakeFiles/install-libcxx] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:159558: runtimes/CMakeFiles/install-libcxx.dir/all] Error 2
gmake[2]: *** Waiting for unfinished jobs....
gmake[4]: *** No rule to make target 'install-libcxxabi'. Stop.
CMake Error at /home/user/tmp/bs/cache/llvm-project/llvm/cmake/modules/FileLock.cmake:9 (execute_process):
execute_process failed command indexes:
1: "Child return code: 2"
gmake[3]: *** [runtimes/CMakeFiles/install-libcxxabi.dir/build.make:70: runtimes/CMakeFiles/install-libcxxabi] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:159494: runtimes/CMakeFiles/install-libcxxabi.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:16263: CMakeFiles/install-distribution.dir/rule] Error 2
gmake: *** [Makefile:332: install-distribution] Error 2
I don’t really know enough about LLVM’s CMake build targets to actually know what I’m doing; I simply tried making the same targets as the Dockerfile.
I want to do what Building a Distribution of LLVM describes: Set both LLVM_DISTRIBUTION_COMPONENTS and LLVM_RUNTIME_DISTRIBUTION_COMPONENTS, and make the correct *-distribution and *-install-distribution targets, since it sounds like this way CMake’ll build only what I strictly request and no extra runtimes or tools, reducing my build times. Quoting the documentation (emphasis mine):
When building with LLVM_DISTRIBUTION_COMPONENTS the build system also generates a
distributiontarget which builds all the components specified in the list. This is a convenience build target to allow building just the distributed pieces without needing to build all configured targets.
I guess my questions are:
- Where are LLVM’s CMake build targets documented? How do I know what targets such as
stage2-clang-bolt,stage2-install-distribution, and so on, actually do and the differences between them? - Which “
*-distribution” and “*-install-distribution” targets should I use to build and install my distribution, respectively? Considering I want BOLT + LTO + PGO via the CMake cache. - Which components depend on which? (E.g., does libc++ depend on libc++abi?)