Skip to content

Apple: Refactor deployment target version parsing#129341

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

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

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.

Loading
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 / Darwin (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