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

Move versioned Apple LLVM targets from rustc_target to rustc_codegen_ssa #131037

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Sep 29, 2024

Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like MACOSX_DEPLOYMENT_TARGET, IPHONEOS_DEPLOYMENT_TARGET etc.

We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from #130883 to do #118204. See also #129342 (comment) for some discussion.

The first commit does the actual refactor, it should be a non-functional change, the second commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session.

Tested with the same commands as in #130435.

r? @petrochenkov

The OS version depends on the deployment target environment variables,
the access of which we want to move to later in the compilation pipeline
that has access to more information, for example `env_depinfo`.
@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 Sep 29, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2024

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

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@@ -259,7 +260,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
}

fn target_triple(sess: &Session) -> target_lexicon::Triple {
match sess.target.llvm_target.parse() {
match versioned_llvm_target(sess).parse() {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably remain unchanged. Cranelift currently doesn't consume the deployment target and cranelift-object may well expect it to be passed in separately in the future. In general Cranelift barely takes any information from the target triple. Only the cpu architecture and default calling convention for the OS currently. Even the object file format dependent way to lower TLS is passed in using a separate flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we talked about this elsewhere, I did it like this for now so that the commit was completely free of functional changes.

In particular, I think passing an unversioned target triple to target-lexicon would result in an error here, as their current parsing code for macosx assumes that the version is always present.

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'll try to whip up a PR to fix this in target-lexicon, but that shouldn't block this PR IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants