I think we should deprecate -DLLVM_ENABLE_PROJECTS=compiler-rt
altogether and only support -DLLVM_ENABLE_RUNTIMES=compiler-rt
. Note that doing so doesn’t mean that you won’t be able to build compiler-rt with another compiler.
There are two different ways to build runtimes:
For example, to build compiler-rt with GCC in the runtimes build, you’d use:
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_ENABLE_RUNTIMES=compiler-rt <other CMake flags> ${LLVM_SRC_DIR}/runtimes
Today, you can achieve the same with either:
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_ENABLE_PROJECTS=compiler-rt <other CMake flags> ${LLVM_SRC_DIR}/llvm
or:
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ <other CMake flags> ${LLVM_SRC_DIR}/compiler-rt
The main advantage of using the runtimes build is that we can avoid the CMake duplication between different runtimes builds and simplify maintenance.
For example, in libcxx, libcxxabi and libunwind, we had similar logic duplicated three times. That’s because someone would write it first in one of the runtimes, and then someone else would copy & paste it into other two, but then others would start making changes and wouldn’t often replicate those changes in every copy, and we would end up with similar but different copies making maintenance a nightmare. With the runtimes build, we can deduplicate all of that logic and have only a single copy that’s shared by all runtimes.
You can already build compiler-rt with -DLLVM_ENABLE_RUNTIMES=compiler-rt
, but we can’t start removing a lot of this complexity until we deprecate -DLLVM_ENABLE_PROJECTS=compiler-rt
like we did for libcxx, libcxxabi and libunwind. I believe this would be a huge improvement.
For example, compiler-rt build already supports building tests with the just built Clang, but rather than relying on the bootstrapping build, it does so by manually invoking Clang as a custom command which means that a lot of the standard flag handling provided by CMake doesn’t work, and it requires developers to use various workarounds.
Note that we may not be quite ready to deprecate -DLLVM_ENABLE_PROJECTS=compiler-rt
yet. Even though -DLLVM_ENABLE_RUNTIMES=compiler-rt
has been supported for some time, it’s not widely used—most notably, it’s not used by buildbots—so there might be scenarios that are broken, but it would be great if we can start promoting its use so we find and address all the issues, and aim for deprecation and removal of -DLLVM_ENABLE_PROJECTS=compiler-rt
ideally after the LLVM 16 branch point.
Updating all buildbots to use -DLLVM_ENABLE_RUNTIMES=compiler-rt
would be a first great step towards the eventual deprecation.