Good morning,
I am working on teachin the build system for the Swift compiler to use LLVM_ENABLE_RUNTIMES instead of LLVM_BUILD_EXTERNAL_COMPILER_RT1 – in doing so I realized that we may need a change in LLVM to avoid silently dropping build products for some Apple platforms, and I seeking your input to assess if the solution 2 I have in mind goes in the right direction.
The issues seems to stem from the fact that the llvm_ExternalProject_Add invocation used to build the default targets for builtins and runtimes always specify a target triple – when building on macOS that’s set to <arch>-apple-macos<version>.
That is subsequently used by in every compiler invocation generated by CMake, including the ones used to detect valid architectures for other platforms like iOS – the detection fails as a result and we silent skip building for such platforms.
My current solution 2 would be to add a flag to decide whether we set TARGET_TRIPLE for those external project invocation (maintaining by default the current behaviour), and then on Swift side we set that appropriately – however I cannot gauge effectively if this will impact other platforms or other runtime products using this infrastructure.
Can you share your CMake invocation for building runtimes with LLVM_ENABLE_RUNTIMES? We have been building runtimes for Apple platforms with LLVM_ENABLE_RUNTIMESas part of our toolchain for years and we never encountered this issue so I’m curious how your build differs from ours.
We do something similar, except we add x86_64-apple-darwin to our LLVM_BUILTIN_TARGETS and LLVM_RUNTIME_TARGETS explicitly. Clang has special logic for overriding darwin triples with the appropriate OS and architecture, and the Apple runtime builds do so. ⚙ D86313 [runtimes] Allow LLVM_BUILTIN_TARGETS to include Darwin has some related discussion.
Answering to aid future searches and troubleshooting: this is the invocation that did not build iOS and iOS Sim – if I drop LLVM_HOST_TRIPLE, those are built
Using the Fuchsia configuration I am able to build runtimes for the iOS simulator, but not for iOS proper – possibly because we set CMAKE_OSX_ARCHITECTURES in RUNTIMES_CMAKE_ARGS, and that seems to interfere with the SDK detection
Thanks for the feedback and apologies for my late acknowledgement – the approach described by @smeenai allows us to build all the Apple platforms, so my LLVM change is not needed.