Repository: rust
Issue: CMake components fails to build on Mac Catalyst
Labels: A-LLVM,C-bug,O-apple

Running:
```console
./x.py build --set=build.sanitizers=true --target=aarch64-apple-ios-macabi
```

Currently fails with:
```console
... snip

running: cd "/rust/build/aarch64-apple-ios-macabi/native/sanitizers/build" && DESTDIR="" "cmake" "--build" "." "--target" "clang_rt.asan_osx_dynamic" "--config" "Release" "--" "-j" "12"
[1/14] Building CXX object lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_win.cpp.o
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: argument unused during compilation: '-L/usr/lib' [-Wunused-command-line-argument]
[2/14] Building CXX object lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_premap_shadow.cpp.o
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: argument unused during compilation: '-L/usr/lib' [-Wunused-command-line-argument]
[3/14] Building CXX object lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_malloc_mac.cpp.o
FAILED: lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_malloc_mac.cpp.o 
/usr/bin/clang++ -DASAN_DYNAMIC=1 -I/rust/src/llvm-project/compiler-rt/lib/asan/.. -fPIC --target=arm64-apple-ios-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -isystem /usr/include -iframework /System/Library/Frameworks -L/usr/lib -F/System/Library/Frameworks -Wall -O3 -DNDEBUG -std=c++17 -arch arm64 -arch x86_64 -arch x86_64h -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -g -nostdinc++ -fno-rtti -Wno-format -ftls-model=initial-exec -MD -MT lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_malloc_mac.cpp.o -MF lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_malloc_mac.cpp.o.d -o lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_malloc_mac.cpp.o -c /rust/src/llvm-project/compiler-rt/lib/asan/asan_malloc_mac.cpp
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: overriding '-mmacosx-version-min=10.10' option with '--target=arm64-apple-ios-macabi' [-Woverriding-t-option]
clang: warning: argument unused during compilation: '-L/usr/lib' [-Wunused-command-line-argument]
In file included from /rust/src/llvm-project/compiler-rt/lib/asan/asan_malloc_mac.cpp:66:
/rust/src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10: fatal error: 'CoreFoundation/CFBase.h' file not found
#include <CoreFoundation/CFBase.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~
/rust/src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10: note: did not find header 'CFBase.h' in framework 'CoreFoundation' (loaded from '/System/Library/Frameworks')
1 error generated.

... snip
```

This is preventing us from distributing a sanitizer runtime with rustup on Mac Catalyst, see https://github.com/rust-lang/rust/pull/126450.

Still have to do some more digging, but it seems like the issue is that `iOSSupport` libraries aren't passed to CMake, as is [otherwise](https://github.com/rust-lang/rust/blob/1a2b57b426667c60a82214526be949b9e599c914/compiler/rustc_codegen_ssa/src/back/link.rs#L2158-L2159) [done](https://github.com/rust-lang/cc-rs/blob/eb3390615747fde57f7098797b2acb1aec80f539/src/lib.rs#L2790-L2819) in the ecosystem. In general, it seems like CMake [has poor support for Mac Catalyst](https://gitlab.kitware.com/cmake/cmake/-/issues/20132).

I'll try to fix this, both in the `cmake` crate and perhaps in CMake itself.
@rustbot claim

Linking https://github.com/leetal/ios-cmake and https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Platform/Apple-Clang.cmake to myself for later (might contain some of the relevant CMake configuration needed for this).

@rustbot label O-apple

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"madsmtm"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->