[llvm] [flang-rt][build] Add support for building flang-rt as a standalone project (PR #168321)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 02:28:52 PST 2025
Meinersbur wrote:
The number of ways that flang-rt can built ("build modes") should be minimized. Every build modes induces maintanance overhead. Whenever there is a change to a CMakeLists.txt, one must ensure it continues to work in all build modes. Few developers actually do this so it constantly breaks. So introducing a build mode requres good justification and I don't see what could be done in a standalone build-mode that cannot also be done in a runtimes-default build mode. compiler-rt it also trying to reduce its number of build modes: #124012. AFAIK, there isn't any buildbot left that even test whether compiler-rt's standalone mode is still working.
Consider seeing https://github.com/llvm/llvm-project/blob/main/runtimes/CMakeLists.txt just as the boilerplate code needed for an LLVM-runtime, just like the files in https://github.com/llvm/llvm-project/tree/main/cmake/Modules and https://github.com/llvm/llvm-project/tree/main/cmake/Modules with the difference that it is not `include()`d from the runtimes, but used as a "driver". A separate standalone mode would just require duplicating this boilerplate again into flang-rt's (and every other runtime's) CMakeLists.txt.
What could be done is refactoring that boilerplate into a separate file such as `LLVMRuntimes.cmake`. The remaining boilerplate for https://github.com/llvm/llvm-project/blob/main/runtimes/CMakeLists.txt would mabe be
```cmake
project(Runtimes C CXX ASM)
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
include(LLVMRuntimes)
```
and for each runtime:
```cmake
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(flang-rt C CXX ASM)
set(LLVM_ENABLE_RUNTIMES "flang-rt")
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/../runtimes/cmake"
)
include(LLVMRuntimes)
return ()
endif()
```
as a convinience wrapper for just building a single runtime that keeps the differences between the build modes manageable.
https://github.com/llvm/llvm-project/pull/168321
More information about the llvm-commits
mailing list