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

Fix IPHONEOS_DEPLOYMENT_TARGET on Mac Catalyst #121296

Merged
merged 5 commits into from
Feb 20, 2024

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Feb 19, 2024

Some of the target code invalidly assumed that the deployment target variable on Mac Catalyst is MACOSX_DEPLOYMENT_TARGET, which is wrong, Mac Catalyst uses the same environment variable as iOS.

Additionally, the deployment target was hardcoded to 14.0, I've lowered this to 13.1 (same default as Clang), and made it properly load from the environment.

This shouldn't require any changes to the cc crate, as that uses rustc --print=deployment-target to get this information automatically.

CC @BlackHoleFox
r? @rust-lang/macos

@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

Failed to set assignee to nvzqz: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added 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 Feb 19, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

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

@madsmtm
Copy link
Contributor Author

madsmtm commented Feb 19, 2024

r? shepmaster

(Since you're in @rust-lang/macos as stated here)

@madsmtm
Copy link
Contributor Author

madsmtm commented Feb 19, 2024

See #106925 and #111384 for previous implementation efforts here, including discussion on the choice of defaulting to 14.0; and indeed as said there, 13.0 fails with "invalid version number", but 13.1 works!

pub fn ios_llvm_target(arch: Arch) -> String {
// Modern iOS tooling extracts information about deployment target
// from LC_BUILD_VERSION. This load command will only be emitted when
// we build with a version specific `llvm_target`, with the version
// set high enough. Luckily one LC_BUILD_VERSION is enough, for Xcode
// to pick it up (since std and core are still built with the fallback
// of version 7.0 and hence emit the old LC_IPHONE_MIN_VERSION).
let (major, minor) = ios_deployment_target(arch);
let (major, minor) = ios_deployment_target(arch, "");
Copy link
Member

Choose a reason for hiding this comment

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

Feels a bit odd to use an empty string when we have Option available to us. Is this string defined at a higher level and changing it would be as pain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mostly just tried to follow the existing conventions for the abi value, but agree that this should change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have opened #124762 to fix part of this now

add_link_args_iter(
&mut args,
LinkerFlavor::Darwin(Cc::Yes, Lld::No),
["-target".into(), mac_catalyst_llvm_target(arch).into()].into_iter(),
Copy link
Member

Choose a reason for hiding this comment

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

I know it's not your code, but I wish this function took impl IntoIterator. Maybe a future cleanup.

@shepmaster
Copy link
Member

Thank you for the well-prepared commit sequence!

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Feb 19, 2024

📌 Commit a3cf493 has been approved by shepmaster

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 Feb 19, 2024
@BlackHoleFox
Copy link
Contributor

This shouldn't require any changes to the cc crate, as that uses rustc --print=deployment-target to get this information automatically.

This got reverted fwiw because it turns out rust's default versions don't align well with Apple's SDKs and other third-party C libraries. It shouldn't matter through because cc doesnt pass a deployment target for Catalyst targets and is just using the SDK default for the target (which is 17.0 as of XCode 14). As this is much lower there should be no conflicts. 13.1 is actually the lowest catalyst version the Xcode 14 SDK supports too.

That should be corrected eventually but at least this doesn't make that harder.

@bors
Copy link
Contributor

bors commented Feb 20, 2024

⌛ Testing commit a3cf493 with merge 7d61394...

@bors
Copy link
Contributor

bors commented Feb 20, 2024

☀️ Test successful - checks-actions
Approved by: shepmaster
Pushing 7d61394 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 20, 2024
@bors bors merged commit 7d61394 into rust-lang:master Feb 20, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7d61394): 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

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.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 2.8% [2.8%, 2.8%] 1

Cycles

Results

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)
- - 0
Regressions ❌
(secondary)
4.3% [3.2%, 5.6%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 639.836s -> 638.5s (-0.21%)
Artifact size: 308.66 MiB -> 308.65 MiB (-0.01%)

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

None yet

6 participants