Skip to content
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

Apple: Refactor deployment target version parsing #129341

Merged
merged 3 commits into from
Sep 7, 2024

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Aug 21, 2024

Refactor deployment target parsing to make it easier to do #129342 (I wanted to make sure of all the places that std::env::var is called).

Specifically, my goal was to minimize the amount of target-specific configuration, so to that end I renamed the opts function that generates the TargetOptions to base, and made it return the LLVM target and target_arch too. In the future, I would like to move even more out of the target files and into spec::apple, as it makes it easier for me to maintain.

For example, this fixed a bug in aarch64-apple-watchos, which wasn't passing the deployment target as part of the LLVM triple. This (probably) fixes #123582 and fixes #107630.

We also now parse the patch version of deployment targets, allowing the user to specify e.g. MACOSX_DEPLOYMENT_TARGET=10.12.6.

Finally, this fixes the LLVM target name for visionOS, it should be *-apple-xros and not *-apple-visionos.

Since I have changed all the Apple targets here, I smoke-tested my changes by running the following:

# Build each target
./x build library --target="aarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-ios-macabi,aarch64-apple-ios-sim,aarch64-apple-tvos,aarch64-apple-tvos-sim,aarch64-apple-visionos,aarch64-apple-visionos-sim,aarch64-apple-watchos,aarch64-apple-watchos-sim,arm64_32-apple-watchos,arm64e-apple-ios,armv7k-apple-watchos,armv7s-apple-ios,i386-apple-ios,x86_64-apple-darwin,x86_64-apple-ios,x86_64-apple-ios-macabi,x86_64-apple-tvos,x86_64-apple-watchos-sim,x86_64h-apple-darwin"

# Test that we can still at least link basic projects
cargo new foobar && cd foobar && cargo +stage1 build --target=aarch64-apple-darwin --target=aarch64-apple-ios --target=aarch64-apple-ios-macabi --target=aarch64-apple-ios-sim --target=aarch64-apple-tvos --target=aarch64-apple-tvos-sim --target=aarch64-apple-visionos --target=aarch64-apple-visionos-sim --target=aarch64-apple-watchos --target=aarch64-apple-watchos-sim --target=arm64_32-apple-watchos --target=armv7s-apple-ios --target=i386-apple-ios --target=x86_64-apple-darwin --target=x86_64-apple-ios --target=x86_64-apple-ios-macabi --target=x86_64-apple-tvos --target=x86_64-apple-watchos-sim --target=x86_64h-apple-darwin

I couldn't build for the arm64e-apple-darwin target, the armv7k-apple-watchos and arm64e-apple-ios targets failed to link, and I know that the i686-apple-darwin target requires a bit of setup, but all of this is as it was before this PR.

r? thomcc

CC @BlackHoleFox

I would recommend using rollup=never when merging this, in case we need to bisect this later.

@rustbot rustbot added O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 21, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

@madsmtm
Copy link
Contributor Author

madsmtm commented Aug 22, 2024

@bors rollup=never

There are quite a few changes here, and we might need to bisect this later.

EDIT: Oh well, I don't have permission to configure that, but I'd still recommend it when merging.

@bors
Copy link
Contributor

bors commented Aug 22, 2024

@madsmtm: 🔑 Insufficient privileges: not in try users

@thomcc
Copy link
Member

thomcc commented Aug 23, 2024

@bors rollup=never

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. Was a hassle to verify all the targets match what they used to.

@thomcc
Copy link
Member

thomcc commented Aug 23, 2024

I'm not a compiler-team or compiler-contributor so I'll roll to someone who is, but I'd have R+ed this if I were.
r? compiler

@rustbot rustbot assigned BoxyUwU and unassigned thomcc Aug 23, 2024
@bors

This comment was marked as resolved.

@madsmtm
Copy link
Contributor Author

madsmtm commented Sep 3, 2024

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned BoxyUwU Sep 3, 2024
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 4, 2024
@madsmtm
Copy link
Contributor Author

madsmtm commented Sep 4, 2024

Thanks for the review!

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 4, 2024
Copy link
Contributor

@BlackHoleFox BlackHoleFox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this has been looked at someone on the compiler team, here's my lookover from the Apple perspective since I was CCed.

compiler/rustc_target/src/spec/base/apple/mod.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

- Merge minimum OS version list into one function (makes it easier to
  see the logic in it).
- Parse patch deployment target versions.
- Consistently specify deployment target in LLVM target (previously
  omitted on `aarch64-apple-watchos`).
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 5, 2024

📌 Commit bd56857 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2024
@bors
Copy link
Contributor

bors commented Sep 7, 2024

⌛ Testing commit bd56857 with merge 9afe713...

@bors
Copy link
Contributor

bors commented Sep 7, 2024

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 9afe713 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 7, 2024
@bors bors merged commit 9afe713 into rust-lang:master Sep 7, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 7, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9afe713): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 2.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.7% [2.7%, 2.7%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 756.217s -> 756.798s (0.08%)
Artifact size: 341.14 MiB -> 341.03 MiB (-0.03%)

@madsmtm madsmtm deleted the refactor-deployment-target branch September 7, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
9 participants