-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Update Mac Catalyst support for Clang 13 #96392
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. Please see the contribution instructions for more information. |
|
|
||
pub fn macabi_llvm_target(arch: &str) -> String { | ||
let (major, minor) = ios_deployment_target(); | ||
format!("{}-apple-ios{}.{}.0-macabi", arch, major, minor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether this is suitable for the catalyst use case...
Please feel free to give hints.
My change needs to be tested using the nightly channel because it is related to Mac Catalyst. |
New question: Should I use stage 2 or stage 3 to test my change locally? I cannot build stage 3 locally. When I use stage 2 to test my change:
It does not change anything: |
I have no experience with Apple platforms so I'll reassign this. r? rust-lang/compiler |
r? rust-lang/compiler |
@rust-lang/compiler who's the resident mac expert? |
Hi @terhechte! I followed the README of https://github.com/terhechte/rust-catalyst-example with this project (https://github.com/BLAKE3-team/BLAKE3.git) but it didn't work: (Toggle to see the output)``` ➜ BLAKE3 git:(master) ✗ cargo +stage2 build -Z build-std --target x86_64-apple-ios-macabi Compiling rustc-std-workspace-core v1.99.0 (/Volumes/SharedVol/rust-projects/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/src/rust/library/rustc-std-workspace-core) Compiling blake3 v1.3.1 (/Volumes/SharedVol/rust-projects/BLAKE3) Compiling compiler_builtins v0.1.71 Compiling libc v0.2.121 The following warnings were emitted during compilation:warning: The C compiler "clang" does not support -mavx512f and -mavx512vl. error: failed to run custom build command for Caused by: --- stderr error occurred: Command "clang" "-O0" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=x86_64-apple-ios13.0-macabi" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" "-fembed-bitcode" "-Wall" "-Wextra" "-std=c11" "-o" "/Volumes/SharedVol/rust-projects/BLAKE3/target/x86_64-apple-ios-macabi/debug/build/blake3-5c91a7166ed285cc/out/c/blake3_sse2_x86-64_unix.o" "-c" "c/blake3_sse2_x86-64_unix.S" with args "clang" did not execute successfully (status code exit status: 1). warning: build failed, waiting for other jobs to finish...
|
@@ -114,3 +114,8 @@ pub fn ios_sim_llvm_target(arch: &str) -> String { | |||
let (major, minor) = ios_deployment_target(); | |||
format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor) | |||
} | |||
|
|||
pub fn macabi_llvm_target(arch: &str) -> String { | |||
let (major, minor) = ios_deployment_target(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether it is a good way. But as an iOS developer, I believe it looks good. Because in Xcode, Mac Catalyst minimal version is highly related to minimal iOS version. For example, if I choose iOS 14.0, I can only pick macOS 11+ for this situation:
(Copied from rust-lang/cc-rs#678)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good solution!
@imWildCat Sorry for the delay! It has been some time since I last looked into this topic. I just checked my notes and can only offer some guesses:
|
Thanks @terhechte! I tried Rust libs without C and found that: without the change of this PR, everything is fine with Xcode 13.3 or 13.4.
Good point! For clang, I think we can drop ➜ temp cat i.c
int main() {
return 0;
}
➜ temp clang -target x86_64-apple-ios-macabi i.c
➜ temp echo $?
0 |
r? rust-lang/compiler |
I'm raising this to discuss this PR next thursday meeting so we can assign someone with expertise with this platform |
good idea, because highfive bot chose me, but I am also not an expert :^) |
@rustbot ping macos |
Error: This team ( Please let |
That should be fixed (since macos is basically for this purpose) but I don't have time to do it. Also, even though I'm in the ping group, I've never used catalyst. So I'll just CC @hkratz, @inflation, @shepmaster, @nvzqz manually. Thanks. |
…k-Simulacrum Update `triagebot.toml` for macos ping group idk what i'm doing but i saw rust-lang#96392 (comment) cc: `@thomcc`
☔ The latest upstream changes (presumably #98075) made this pull request unmergeable. Please resolve the merge conflicts. |
@hkratz or @shepmaster, would either of you have time look at this and give us a 👍/👎 if this looks ok to you? Thanks! 🙂 |
@wesleywiser Actually, I'm not confident about this change as pure Rust libs can compile targeting Catalyst using Clang 13+ without this PR. |
I'll remove the @rustbot label -I-compiler-nominated |
I am unsure about that status of this PR. IIUC by reading the last comment, I infer its status to be "iffy" i.e. not really necessary, am I reading it correctly? @rustbot author |
I'm having trouble building for Mac Catalyst - and my research has taken me back to this issue. It looks like the minimum version did get moved to 13.1. @imWildCat - Not sure why you're able to build with your configuration, but on Xcode 13.4 I am seeing: When attempting to build the std lib. |
Another odd thing is that error is from the aarch64 version of Catalyst, but from what I can see in the source, that aarch64 version specifically should be set to 14.0, not 13.0. So something is weird here: |
It looks like my issue is cured by rust-lang/cc-rs#678. The CC tooling is overriding even any change here. |
Yeah. If it is a pure Rust project, we're good without needing to change the |
ping from triage - can you post your status on this PR? Thanks FYI: when a PR is ready for review, send a message containing |
Any update on this issue or a workaround how to get past this problem? We're stuck making builds for |
…ed-ios-macbi-target-version, r=wesleywiser Remove hardcoded iOS version of clang target for Mac Catalyst ## Background From `clang` 13.x, `-target x86_64-apple-ios13.0-macabi` fails while linking: ``` = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' ``` <details> <summary>Verbose output</summary> ``` error: linking with `cc` failed: exit status: 1 | = note: LC_ALL="C" PATH="[removed]" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-Wl,-exported_symbols_list,/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/list" "-target" "x86_64-apple-ios13.0-macabi" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/symbols.o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/[user].[user].a2ccc648-cgu.0.rcgu.o" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps" "-L" "/path/to/my/[project]/[user]/target/release/deps" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/libblake3-343c1616c8f62c66.rlib" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/libcompiler_builtins-15d4f20b641cf9ef.rlib" "-framework" "Security" "-framework" "CoreFoundation" "-framework" "Security" "-liconv" "-lSystem" "-lobjc" "-framework" "Security" "-framework" "Foundation" "-lc" "-lm" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "-o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/lib[user].dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' warning: `[user]` (lib) generated 6 warnings error: could not compile `[user]` due to previous error; 6 warnings emitted ``` </details> ### Minimal example C code: ```c #include <stdio.h> void main() { int a = 1; int b = 2; int c = a + b; printf("%d", c); } ``` `clang` command sample: ``` ➜ 202301 clang -target x86_64-apple-ios13.0-macabi main.c clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' ➜ 202301 clang -target x86_64-apple-ios14.0-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang -target x86_64-apple-ios15.0-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang -target x86_64-apple-ios-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang --version Apple clang version 14.0.0 (clang-1400.0.29.202) Target: arm64-apple-darwin22.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ``` This PR is a simplified version of rust-lang#96392, inspired by rust-lang/cc-rs#727
…-ios-macbi-target-version, r=wesleywiser Remove hardcoded iOS version of clang target for Mac Catalyst ## Background From `clang` 13.x, `-target x86_64-apple-ios13.0-macabi` fails while linking: ``` = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' ``` <details> <summary>Verbose output</summary> ``` error: linking with `cc` failed: exit status: 1 | = note: LC_ALL="C" PATH="[removed]" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-Wl,-exported_symbols_list,/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/list" "-target" "x86_64-apple-ios13.0-macabi" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/symbols.o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/[user].[user].a2ccc648-cgu.0.rcgu.o" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps" "-L" "/path/to/my/[project]/[user]/target/release/deps" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/build/blake3-74e6ba91506ce712/out" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "/var/folders/p8/qpmzbsdn07g5gxykwfxxw7y40000gn/T/rustci8tkvp/libblake3-343c1616c8f62c66.rlib" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/libcompiler_builtins-15d4f20b641cf9ef.rlib" "-framework" "Security" "-framework" "CoreFoundation" "-framework" "Security" "-liconv" "-lSystem" "-lobjc" "-framework" "Security" "-framework" "Foundation" "-lc" "-lm" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk" "-L" "/Users/[user]/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/x86_64-apple-ios-macabi/lib" "-o" "/path/to/my/[project]/[user]/target/x86_64-apple-ios-macabi/release/deps/lib[user].dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" = note: clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' warning: `[user]` (lib) generated 6 warnings error: could not compile `[user]` due to previous error; 6 warnings emitted ``` </details> ### Minimal example C code: ```c #include <stdio.h> void main() { int a = 1; int b = 2; int c = a + b; printf("%d", c); } ``` `clang` command sample: ``` ➜ 202301 clang -target x86_64-apple-ios13.0-macabi main.c clang: error: invalid version number in '-target x86_64-apple-ios13.0-macabi' ➜ 202301 clang -target x86_64-apple-ios14.0-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang -target x86_64-apple-ios15.0-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang -target x86_64-apple-ios-macabi main.c main.c:2:1: warning: return type of 'main' is not 'int' [-Wmain-return-type] void main() { ^ main.c:2:1: note: change return type to 'int' void main() { ^~~~ int 1 warning generated. ➜ 202301 clang --version Apple clang version 14.0.0 (clang-1400.0.29.202) Target: arm64-apple-darwin22.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ``` This PR is a simplified version of rust-lang#96392, inspired by rust-lang/cc-rs#727
LLVM 13 (bundled in Xcode 13.3+) bumped the minimal x86_64 Catalyst version.
In this case, we'd better provide a way to change the minimal version number.
This would also work:
Similar PR: conan-io/conan#10880