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

Print name of env var in --print=deployment-target #133041

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Nov 14, 2024

The deployment target environment variable is OS-specific, and if you're in a place where you're asking rustc for the deployment target, you're likely to also wanna know the name of the environment variable. I myself wanted this for some code I'm working on in bootstrap, for example.

Behaviour before this PR:

$ rustc --print=deployment-target --target=aarch64-apple-darwin
deployment_target=11.0
$ rustc --print=deployment-target --target=aarch64-apple-visionos
deployment_target=1.0

Behaviour after this PR:

$ rustc --print=deployment-target --target=aarch64-apple-darwin
MACOSX_DEPLOYMENT_TARGET=11.0
$ rustc --print=deployment-target --target=aarch64-apple-visionos
XROS_DEPLOYMENT_TARGET=1.0

My belief is that this option is extremely rarely used in general, and a GitHub search for "rustc print deployment-target" seems to confirm this, it revealed only the following actual pieces of code using this:

maturin does .split('=').last(), so it will continue to work after this change, but cc v1.0.84 did .strip_prefix("deployment_target=") since this PR, so it would break. That's probably fine though, it was broken in a lot of scenarios anyway, and got reverted in v1.0.85.

So while this is technically a breaking change, I really doubt that anyone is going to observe it, so it's probably fine.

@BlackHoleFox wdyt?

@rustbot label O-apple
r? compiler

The deployment target environment variable is OS-specific, and if you're
in a place where you're asking `rustc` for the deployment target, you're
likely to also wanna know the environment variable.
@madsmtm madsmtm changed the title Print env var in --print=deployment-target Print name of env var in --print=deployment-target Nov 14, 2024
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs 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 Nov 14, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 14, 2024

This PR modifies tests/run-make/. If this PR is trying to port a Makefile
run-make test to use rmake.rs, please update the
run-make port tracking issue
so we can track our progress. You can either modify the tracking issue
directly, or you can comment on the tracking issue and link this PR.

cc @jieyouxu

@madsmtm
Copy link
Contributor Author

madsmtm commented Nov 14, 2024

This also makes it easier to use in shell scripts, you can now do for example:

export $(rustc --print=deployment-target --target=$MY_APPLE_TARGET)
# Or
env $(rustc --print=deployment-target --target=$MY_APPLE_TARGET) clang --target $MY_APPLE_TARGET foo.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs 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.

3 participants