[PATCH] D132258: clang/apple: Infer simulator env from -mios-simulator-version-min flag
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 19 16:12:06 PDT 2022
thakis added a comment.
To reproduce the warnings that this attempts to fix:
% /Applications/CMake.app/Contents/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_ENABLE_RUNTIMES='compiler-rt' -DLLVM_APPEND_VC_REV=NO -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64' ../llvm-project/llvm
% ninja runtimes
...
[167/1159] Linking CXX shared library /Users/thakis/src/llvm-build-runtimes/lib/clang/16.0.0/lib/darwin/libclang_rt.ubsan_minimal_iossim_dynamic.dylib
ld: warning: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/usr/lib/libc++abi.tbd) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/usr/lib/libc++.tbd) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/usr/lib/libc.tbd) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcache.dylib) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcommonCrypto.dylib) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcompiler_rt.dylib) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcopyfile.dylib) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcorecrypto.dylib) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libdispatch.dylib) built for iOS Simulator
(and many more warnings like this.)
This ultimately boils down to:
% echo 'int main () {}' > main.c
% bin/clang -mios-simulator-version-min=9.0 main.c -isysroot $(xcrun -show-sdk-path --sdk iphonesimulator)
ld: warning: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk/usr/lib/libSystem.tbd) built for iOS Simulator
ld: warning: building for iOS, but linking in .tbd file (/usr/lib/system/libcache.dylib) built for iOS Simulator
Interestingly, this doesn't happen with Xcode's clang:
% clang -mios-simulator-version-min=9.0 main.c -isysroot $(xcrun -show-sdk-path --sdk iphonesimulator)
# no diags
Passing `-v` to both clangs shows that `bin/clang` passes `-triple arm64-apple-ios9.0.0` to `-cc1` and `-platform_version ios 9.0.0 15.5` to ld64, while Xcode's clang passes `-triple arm64-apple-ios9.0.0-simulator` and ` -platform_version ios-simulator` respectively.
This patch makes open-source clang match Xcode clang's behavior.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132258/new/
https://reviews.llvm.org/D132258
More information about the cfe-commits
mailing list