Skip to content

Add target_env = "macabi" and target_env = "sim" #139451

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

Merged
merged 1 commit into from
Aug 9, 2025

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Apr 6, 2025

RFC 2992 (tracking issue) introduced cfg(target_abi = ...) with the original motivation being Mac Catalyst and Apple Simulator targets. These do not actually have a changed calling convention in the same sense that e.g. cfg(target_abi = "eabihf") or pointer authentication (arm64e) does, see #133331.

Specifically, for Apple Simulator targets, the binary runs under the following conditions:

  • Runs with the host macOS kernel (but in a mode configured for iOS/tvOS/...).
  • Uses frameworks for the specific simulator version being targetted.
  • System file accesses need to be made relative to the IPHONE_SIMULATOR_ROOT environment variable.
  • Uses host GPUs directly.

And for Mac Catalyst:

  • Runs with the host macOS kernel (but in a mode configured for iOS).
  • Uses mostly host macOS frameworks (though with a few things changed, e.g. the NSImageResizingModeStretch enum has a different value).
  • Uses host GPUs, camera and other peripherals directly.

As can be seen, these seem better suited as target_envs, since it really is the environment that the binary is running under that's changed (regardless of the Mac Catalyst "macabi" having "abi" in the name). So this PR adds target_env = "sim" and target_env = "macabi", with the idea of possibly deprecating target_abi = "sim" and target_abi = "macabi" in the far future.

This affects iOS Tier 2 targets (aarch64-apple-ios-sim, x86_64-apple-ios, aarch64-apple-ios-macabi and x86_64-apple-ios-macabi), and probably needs a compiler FCP.

Fixes #133331.
Reference PR: rust-lang/reference#1781.
Cargo doc PR: rust-lang/cargo#15404.

r? compiler
CC @workingjubilee
CC target maintainers @deg4uss3r @thomcc @badboy @BlackHoleFox @madsmtm @agg23

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc 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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2025

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

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@madsmtm madsmtm force-pushed the apple-target-env-abi branch from b42ca5f to 0245efb Compare April 6, 2025 14:29
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm force-pushed the apple-target-env-abi branch from 8a2104f to 8ab20f3 Compare April 6, 2025 15:41
@madsmtm madsmtm force-pushed the apple-target-env-abi branch from 8ab20f3 to bb4d1b1 Compare April 6, 2025 23:43
github-merge-queue bot pushed a commit to rust-lang/cargo that referenced this pull request Apr 6, 2025
`target_abi = "sim"` may be deprecated in the future. See
rust-lang/rust#139451.
Copy link
Member

@SparrowLii SparrowLii left a comment

Choose a reason for hiding this comment

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

It looks fine, but I'm not familar with target options so
r? @workingjubilee since this is from #133331

@rustbot rustbot assigned workingjubilee and unassigned SparrowLii Apr 7, 2025
@workingjubilee
Copy link
Member

workingjubilee commented Apr 8, 2025

Hm. Reviewing https://github.com/rust-lang/rust-forge/blob/master/src/compiler/proposals-and-stabilization.md#targets this is an unspecified case for approving changes to targets, cc @davidtwco and @wesleywiser

But it is user-facing, I suppose, so an FCP does make sense. Tentatively applying labels assuming that is correct.

@workingjubilee workingjubilee added I-compiler-nominated Nominated for discussion during a compiler team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. and removed T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 8, 2025
@apiraino
Copy link
Contributor

apiraino commented Apr 10, 2025

I'm also not very familiar with target options but I feel that target_env = "sim" is a bit generic. Would it make sense something that says more explicitly that this is an Apple thing? Example target_env = "ios-sim" or something along this line?

@wesleywiser
Copy link
Member

Yes, I think an FCP is appropriate for this change.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 10, 2025

Team member @wesleywiser has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Apr 10, 2025
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 24, 2025
@madsmtm madsmtm force-pushed the apple-target-env-abi branch from 8be24de to 1d22c37 Compare August 6, 2025 10:59
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 6, 2025
@madsmtm madsmtm removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 6, 2025
@madsmtm
Copy link
Contributor Author

madsmtm commented Aug 6, 2025

Rebased

@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 Aug 6, 2025
@wesleywiser
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit 1d22c37 has been approved by wesleywiser

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 Aug 8, 2025
@bors
Copy link
Collaborator

bors commented Aug 8, 2025

☔ The latest upstream changes (presumably #145077) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 8, 2025
@madsmtm madsmtm force-pushed the apple-target-env-abi branch from 1d22c37 to d434cae Compare August 8, 2025 11:50
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 8, 2025
@madsmtm
Copy link
Contributor Author

madsmtm commented Aug 8, 2025

Rebased (conflict was in tests/ui/check-cfg/well-known-values.stderr).

@bors r=wesleywiser

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit d434cae has been approved by wesleywiser

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 8, 2025
@madsmtm madsmtm removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 8, 2025
bors added a commit that referenced this pull request Aug 8, 2025
Rollup of 8 pull requests

Successful merges:

 - #139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - #144039 (Use `tcx.short_string()` in more diagnostics)
 - #144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - #144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - #144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - #144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - #144775 (more strongly dissuade use of `skip_binder`)
 - #144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6674fe2 into rust-lang:master Aug 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 9, 2025
rust-timer added a commit that referenced this pull request Aug 9, 2025
Rollup merge of #139451 - madsmtm:apple-target-env-abi, r=wesleywiser

Add `target_env = "macabi"` and `target_env = "sim"`

[RFC 2992](rust-lang/rfcs#2992) ([tracking issue](#80970)) introduced `cfg(target_abi = ...)` with the original motivation being Mac Catalyst and Apple Simulator targets. These do not actually have a changed calling convention in the same sense that e.g. `cfg(target_abi = "eabihf")` or pointer authentication (`arm64e`) does, see #133331.

Specifically, for Apple Simulator targets, the binary runs under the following conditions:
- Runs with the host macOS kernel (but in a mode configured for iOS/tvOS/...).
- Uses frameworks for the specific simulator version being targetted.
- System file accesses need to be made relative to the `IPHONE_SIMULATOR_ROOT` environment variable.
- Uses host GPUs directly.

And for Mac Catalyst:
- Runs with the host macOS kernel (but in a mode configured for iOS).
- Uses mostly host macOS frameworks (though with a few things changed, e.g. the [`NSImageResizingModeStretch`](https://developer.apple.com/documentation/appkit/nsimage/resizingmode-swift.enum/stretch?language=objc) enum has a different value).
- Uses host GPUs, camera and other peripherals directly.

As can be seen, these seem better suited as `target_env`s, since it really is the environment that the binary is running under that's changed (regardless of the Mac Catalyst "macabi" having "abi" in the name). So this PR adds `target_env = "sim"` and `target_env = "macabi"`, with the idea of possibly deprecating `target_abi = "sim"` and `target_abi = "macabi"` in the far future.

This affects iOS Tier 2 targets (`aarch64-apple-ios-sim`, `x86_64-apple-ios`, `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi`), and probably needs a compiler FCP.

Fixes #133331.
Reference PR: rust-lang/reference#1781.
Cargo doc PR: rust-lang/cargo#15404.

r? compiler
CC `@workingjubilee`
CC target maintainers `@deg4uss3r` `@thomcc` `@badboy` `@BlackHoleFox` `@madsmtm` `@agg23`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 9, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - rust-lang/rust#144039 (Use `tcx.short_string()` in more diagnostics)
 - rust-lang/rust#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - rust-lang/rust#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - rust-lang/rust#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - rust-lang/rust#144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - rust-lang/rust#144775 (more strongly dissuade use of `skip_binder`)
 - rust-lang/rust#144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
@madsmtm madsmtm deleted the apple-target-env-abi branch August 9, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. 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
Development

Successfully merging this pull request may close these issues.

"macabi" is not an "ABI" in the same sense as e.g. "gnueabihf"