Skip to content

Apple: Refactor deployment target version parsing - #129341

Merged
bors merged 3 commits into
rust-lang:masterfrom
madsmtm:refactor-deployment-target
Sep 7, 2024
Merged

Apple: Refactor deployment target version parsing#129341
bors merged 3 commits into
rust-lang:masterfrom
madsmtm:refactor-deployment-target

Conversation

@madsmtm

@madsmtmmadsmtm commented Aug 21, 2024

Copy link
Copy Markdown
Member

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 projectscargo 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.

@rustbotrustbot added O-apple Operating system: Apple / Darwin (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
Copy Markdown
Collaborator

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

@madsmtm

madsmtm commented Aug 22, 2024

Copy link
Copy Markdown
MemberAuthor

@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

bors commented Aug 22, 2024

Copy link
Copy Markdown
Collaborator

@madsmtm: 🔑 Insufficient privileges: not in try users

@thomcc

Copy link
Copy Markdown
Member

@bors rollup=never

@thomccthomcc left a comment

Copy link
Copy Markdown
Member

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.

Comment threadcompiler/rustc_target/src/spec/base/apple/mod.rs
Comment threadcompiler/rustc_target/src/spec/base/apple/mod.rs
@thomcc

Copy link
Copy Markdown
Member

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

@rustbotrustbot assigned BoxyUwU and unassigned thomccAug 23, 2024
@bors

This comment was marked as resolved.

@madsmtm

Copy link
Copy Markdown
MemberAuthor

r? compiler

@rustbotrustbot assigned petrochenkov and unassigned BoxyUwUSep 3, 2024
@madsmtm
madsmtmforce-pushed the refactor-deployment-target branch from 1345f40 to 03ef705CompareSeptember 3, 2024 09:34
Comment threadcompiler/rustc_target/src/spec/base/apple/mod.rs Outdated
Comment threadcompiler/rustc_target/src/spec/base/apple/mod.rs Outdated
@petrochenkovpetrochenkov 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
madsmtmforce-pushed the refactor-deployment-target branch from 03ef705 to d69cfd7CompareSeptember 4, 2024 19:56
@madsmtm

Copy link
Copy Markdown
MemberAuthor

Thanks for the review!

@rustbot ready

@rustbotrustbot 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

@BlackHoleFoxBlackHoleFox left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadcompiler/rustc_target/src/spec/base/apple/mod.rs Outdated
Comment threadcompiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@madsmtm
madsmtmforce-pushed the refactor-deployment-target branch from d69cfd7 to b202b0bCompareSeptember 5, 2024 04:04
@rust-log-analyzer

This comment has been minimized.

@madsmtm
madsmtmforce-pushed the refactor-deployment-target branch from b202b0b to 175f887CompareSeptember 5, 2024 04:45
- 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`).
@madsmtm
madsmtmforce-pushed the refactor-deployment-target branch from 175f887 to bd56857CompareSeptember 5, 2024 04:47
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Sep 5, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit bd56857 has been approved by petrochenkov

It is now in the queue for this repository.

@borsbors 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

bors commented Sep 7, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit bd56857 with merge 9afe713...

@bors

bors commented Sep 7, 2024

Copy link
Copy Markdown
Collaborator

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

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Sep 7, 2024
@bors
bors merged commit 9afe713 into rust-lang:masterSep 7, 2024
@rustbotrustbot added this to the 1.83.0 milestone Sep 7, 2024
@rust-timer

Copy link
Copy Markdown
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.

meanrangecount
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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.O-appleOperating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS)S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

9 participants

@madsmtm@rustbot@bors@thomcc@rust-log-analyzer@petrochenkov@rust-timer@BlackHoleFox@BoxyUwU