I work for a team that is productizing an LLVM compiler toolchain focused on embedded ARM devices.
We are converting from standalone runtimes builds to using lvm/runtimes and LLVM_ENABLE_RUNTIMES.
In our development, a few issues arose due to cross-compilation and the embedded nature of the targets.
· When utilizing LLVM_RUNTIME_MULTILIBS, it is ill-defined whether the multilib option override or the default option override takes precedence. Instead, it is up to whatever order cmake decides to list the variables in the CMakeCache.txt file. This change has been reviewed, but is awaiting a committer (or me getting commit access, J )
· In runtimes which utilize the LLVM configuration, variables found in LLVMConfig.cmake override the runtimes’ configuration. Specifically, LLVM_ENABLE_PIC is set to the value used to build the toolchain. This is undesirable, because the value used to build the toolchain is not necessarily the same value that should be used to build the runtimes, especially when the target being built for is completely different.
· In compiler-rt’s builtins, -fPIC is added to the command line unconditionally in a standalone build, citing that the LLVM cmake step would have added it too. However, the LLVM cmake step checks LLVM_ENABLE_PIC before doing so. I’ve added a COMPILER_RT_BUILTINS_ENABLE_PIC options to guard this option’s addition in a standlone build.
· libcxx, libcxxabi, and libunwind utilize HandleLLVMOptions. This cmake configuration file contains a block which sets LLVM_ON_WIN32, LLVM_ON_UNIX, and LLVM_HAVE_LINK_VERSION_SCRIPT. This block errors out if one of WIN32, UNIX, or FUCSHIA is not set. Our embedded ARM target has the CMAKE_SYSTEM_NAME ‘Generic’, so that none of these variables are set, causing an error. I believe that this block of code can safely set all 3 of these variables to 0 for the 3 projects I’ve mentioned. Doing so has allowed me to build functional runtimes for a Generic system.
· CMAKE_ASM_OPTIONS doesn’t work for the assembly source in libunwind because those files are marked with ‘C’ language properties. I believe there’s some history that necessitated this behavior that has since been made defunct.
I see that Chandler Carruth is responsible for CMake in CODE_OWNERS, so I’ll add him to these revisions initially unless others step in.