Fix incorrect 'llvm_target' value used on watchOS target#123446
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 7, 2024
Merged
Fix incorrect 'llvm_target' value used on watchOS target#123446bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
The expected value is "<arch>-apple-watchos<major>.<minor>.0", i.e. "arm64_32-apple-watchos8.0.0". compiler/rustc_target/src/spec/base/apple/mod.rs contains functions that construct such string. There is an existing function `watchos_sim_llvm_target` which returns llvm target value for watchOS simulator. But there is none for watchOS device. This commit adds that missing function to align watchOS with other Apple platform targets.
Collaborator
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Collaborator
|
These commits modify compiler targets. |
Contributor
|
cc @rust-lang/compiler for changes to watch OS target The changes look reasonable. @bors r+ |
Collaborator
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
Apr 6, 2024
…t, r=estebank Fix incorrect 'llvm_target' value used on watchOS target ## Issue `xcodebuild -create-xcframework` command doesn't recognize static libraries that are built on "arm64_32-apple-watchos" target. Here are steps to reproduce the issue on a Mac: 1. Install nightly toolchain `nightly-2024-03-27`. Needs this specific version, because newer nightly versions are broken on watchos target. 1. Create an empty library: `mkdir watchos-lib && cd watchos-lib && cargo init --lib`. 1. Add configuration `lib.crate-type=["staticlib"]` to Cargo.toml. 1. Build the library: `cargo +nightly-2024-03-27 build --release -Zbuild-std --target arm64_32-apple-watchos` 1. Run `xcodebuild -create-xcframework` to put the static library into a xcframework, which results in an error: ``` $ xcodebuild -create-xcframework -library target/arm64_32-apple-watchos/release/libwatchos_lib.a -output test.xcframework error: unable to determine the platform for the given binary '.../watchos-lib/target/arm64_32-apple-watchos/release/libwatchos_lib.a'; check your deployment version settings ``` ## Fix The root cause of this error is `xcodebuild` couldn't read `LC_BUILD_VERSION` from the static library to determine the library's target platform. And the reason it's missing is that an incorrect `llvm_target` value is used in `arm64_32-apple-watchos` target. The expected value is `<arch>-apple-watchos<major>.<minor>.0`, i.e. "arm64_32-apple-watchos8.0.0". The [.../apple/mod.rs](https://github.com/rust-lang/rust/blob/43f4f2a3b1a3d3fb3dbbbe4fde33fb97c780ee98/compiler/rustc_target/src/spec/base/apple/mod.rs#L321) file contains functions that construct such string. There is an existing function `watchos_sim_llvm_target` which returns llvm target value for watchOS simulator. But there is none for watchOS device. This PR adds that missing function to align watchOS with other Apple platform targets. To verify the fix, you can simply build a toolchain on this PR branch and repeat the steps above using the built local toolchain to verify the `xcodebuild -create-xcframework` command can create a xcframework successfully. Furthermore, you can verify `LC_BUILD_VERSION` contains correct info by using the simple shell script below to print `LC_BUILD_VERSION` of the static library that's built on watchos target: ```shell bin=target/arm64_32-apple-watchos/release/libwatchos_lib.a file=$(ar -t "$bin" | grep -E '\.o$' | head -n 1) ar -x "$bin" "$file" vtool -show-build-version "$file" ``` Here is an example output from my machine: ``` watchos_rust-495d6aaf3bccc08d.watchos_rust.35ba42bf9255ca9d-cgu.0.rcgu.o: Load command 1 cmd LC_BUILD_VERSION cmdsize 24 platform WATCHOS minos 8.0 sdk n/a ntools 0 ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 6, 2024
…llaumeGomez Rollup of 4 pull requests Successful merges: - rust-lang#119224 (Drop panic hook after running tests) - rust-lang#123411 (Put checks that detect UB under their own flag below debug_assertions) - rust-lang#123446 (Fix incorrect 'llvm_target' value used on watchOS target) - rust-lang#123516 (Do not ICE on field access check on expr with `ty::Error`) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 7, 2024
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#123410 (Relax framework linking test) - rust-lang#123446 (Fix incorrect 'llvm_target' value used on watchOS target) - rust-lang#123579 (add some more tests) - rust-lang#123581 (Add `f16` and `f128` to rustdoc's `PrimitiveType`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 7, 2024
Rollup merge of rust-lang#123446 - crazytonyli:fix-watchos-llvm-target, r=estebank Fix incorrect 'llvm_target' value used on watchOS target ## Issue `xcodebuild -create-xcframework` command doesn't recognize static libraries that are built on "arm64_32-apple-watchos" target. Here are steps to reproduce the issue on a Mac: 1. Install nightly toolchain `nightly-2024-03-27`. Needs this specific version, because newer nightly versions are broken on watchos target. 1. Create an empty library: `mkdir watchos-lib && cd watchos-lib && cargo init --lib`. 1. Add configuration `lib.crate-type=["staticlib"]` to Cargo.toml. 1. Build the library: `cargo +nightly-2024-03-27 build --release -Zbuild-std --target arm64_32-apple-watchos` 1. Run `xcodebuild -create-xcframework` to put the static library into a xcframework, which results in an error: ``` $ xcodebuild -create-xcframework -library target/arm64_32-apple-watchos/release/libwatchos_lib.a -output test.xcframework error: unable to determine the platform for the given binary '.../watchos-lib/target/arm64_32-apple-watchos/release/libwatchos_lib.a'; check your deployment version settings ``` ## Fix The root cause of this error is `xcodebuild` couldn't read `LC_BUILD_VERSION` from the static library to determine the library's target platform. And the reason it's missing is that an incorrect `llvm_target` value is used in `arm64_32-apple-watchos` target. The expected value is `<arch>-apple-watchos<major>.<minor>.0`, i.e. "arm64_32-apple-watchos8.0.0". The [.../apple/mod.rs](https://github.com/rust-lang/rust/blob/43f4f2a3b1a3d3fb3dbbbe4fde33fb97c780ee98/compiler/rustc_target/src/spec/base/apple/mod.rs#L321) file contains functions that construct such string. There is an existing function `watchos_sim_llvm_target` which returns llvm target value for watchOS simulator. But there is none for watchOS device. This PR adds that missing function to align watchOS with other Apple platform targets. To verify the fix, you can simply build a toolchain on this PR branch and repeat the steps above using the built local toolchain to verify the `xcodebuild -create-xcframework` command can create a xcframework successfully. Furthermore, you can verify `LC_BUILD_VERSION` contains correct info by using the simple shell script below to print `LC_BUILD_VERSION` of the static library that's built on watchos target: ```shell bin=target/arm64_32-apple-watchos/release/libwatchos_lib.a file=$(ar -t "$bin" | grep -E '\.o$' | head -n 1) ar -x "$bin" "$file" vtool -show-build-version "$file" ``` Here is an example output from my machine: ``` watchos_rust-495d6aaf3bccc08d.watchos_rust.35ba42bf9255ca9d-cgu.0.rcgu.o: Load command 1 cmd LC_BUILD_VERSION cmdsize 24 platform WATCHOS minos 8.0 sdk n/a ntools 0 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
xcodebuild -create-xcframeworkcommand doesn't recognize static libraries that are built on "arm64_32-apple-watchos" target.Here are steps to reproduce the issue on a Mac:
nightly-2024-03-27. Needs this specific version, because newer nightly versions are broken on watchos target.mkdir watchos-lib && cd watchos-lib && cargo init --lib.lib.crate-type=["staticlib"]to Cargo.toml.cargo +nightly-2024-03-27 build --release -Zbuild-std --target arm64_32-apple-watchosxcodebuild -create-xcframeworkto put the static library into a xcframework, which results in an error:Fix
The root cause of this error is
xcodebuildcouldn't readLC_BUILD_VERSIONfrom the static library to determine the library's target platform. And the reason it's missing is that an incorrectllvm_targetvalue is used inarm64_32-apple-watchostarget. The expected value is<arch>-apple-watchos<major>.<minor>.0, i.e. "arm64_32-apple-watchos8.0.0".The .../apple/mod.rs file contains functions that construct such string. There is an existing function
watchos_sim_llvm_targetwhich returns llvm target value for watchOS simulator. But there is none for watchOS device. This PR adds that missing function to align watchOS with other Apple platform targets.To verify the fix, you can simply build a toolchain on this PR branch and repeat the steps above using the built local toolchain to verify the
xcodebuild -create-xcframeworkcommand can create a xcframework successfully.Furthermore, you can verify
LC_BUILD_VERSIONcontains correct info by using the simple shell script below to printLC_BUILD_VERSIONof the static library that's built on watchos target:Here is an example output from my machine: