-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(cli): Help users know possible --target
values
#12607
Conversation
r? @weihanglo (rustbot has picked a reviewer for you, use r? to override) |
@@ -42,7 +42,7 @@ Compilation Options: | |||
--profile <PROFILE-NAME> Build artifacts with the specified profile | |||
-j, --jobs <N> Number of parallel jobs, defaults to # of CPUs. | |||
--keep-going Do not abort the build as soon as there is an error | |||
--target <TRIPLE> Build for the target triple | |||
--target [<TRIPLE>] Build for the target triple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we could have a way to avoid this showing as optional 🥲.
(Never mind we already have this issue everywhere.)
src/cargo/util/command_prelude.rs
Outdated
let cmd = if is_rustup() { | ||
"rustup target list" | ||
} else { | ||
"ustc --print target-list" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a real objection. Just this recommendation could often be false when using +channel
command line override.
And typo
"ustc --print target-list" | |
"rustc --print target-list" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo fixed. I can go either way in how we handle the recommendation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo/src/cargo/core/compiler/standard_lib.rs
Lines 245 to 252 in 40f1f67
match target_data.config.get_env("RUSTUP_TOOLCHAIN") { | |
Ok(rustup_toolchain) => { | |
anyhow::bail!("{} --toolchain {}", msg, rustup_toolchain); | |
} | |
Err(_) => { | |
anyhow::bail!(msg); | |
} | |
} |
We've already got something alike, though applying toolchain doesn't seem too useful. The output of rustup target list
shouldn't change too much across versions, and people doing weird stuff usually know the trick.
I'll merge it as is.
@bors r+ |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request. |
Update cargo 21 commits in 96fe1c9e1aecd8f57063e3753969bb6418fd2fd5..d14c85f4e6e7671673b1a1bc87231ff7164761e1 2023-08-29 20:10:34 +0000 to 2023-09-05 22:28:10 +0000 - fix(resolver): Make resolver behavior independent of package order (rust-lang/cargo#12602) - cargo-credential: change serialization of cache expiration (rust-lang/cargo#12622) - Update registry-web-api.md yank/unyank comments (rust-lang/cargo#12619) - test: new options of debuginfo are no longer unstable (rust-lang/cargo#12618) - use split_once for cleaner code (rust-lang/cargo#12615) - stop using lazy_static (rust-lang/cargo#12616) - doc: adjust all doc headings one level up (rust-lang/cargo#12595) - chore(deps): update compatible (rust-lang/cargo#12609) - chore(deps): update rust crate cargo_metadata to 0.17.0 (rust-lang/cargo#12610) - Prepare for partial-version package specs (rust-lang/cargo#12591) - refactor: Use more serde_untagged (rust-lang/cargo#12581) - fix(cli): Help users know possible `--target` values (rust-lang/cargo#12607) - Tab completion for --target uses rustup but fallsback to rustc (rust-lang/cargo#12606) - Fewer temporary needless strings (rust-lang/cargo#12604) - fix(help): Provide better commands heading for styling (rust-lang/cargo#12593) - fix(update): Clarify meaning of --aggressive as --recursive (rust-lang/cargo#12544) - docs(changelog): Clarify language for Cargo.lock policy (rust-lang/cargo#12601) - fix typo: "default branch branch" -> "default branch" (rust-lang/cargo#12598) - fix: add error for unsupported credential provider version (rust-lang/cargo#12590) - fix(help): Explain --explain (rust-lang/cargo#12592) - fix(help): Remove redundant information from new/init (rust-lang/cargo#12594) r? ghost
What does this PR try to resolve?
I was needing to do some more cross-compilation and forgot what the target triple was that I needed to run. I realized i had to re-remember the command yet again. Especially with #12585 in memory, I realized that
--target
isn't working like--package
and other arguments that can report supported values.In working on it, I realized I probably didn't want to report supported values yet out of concern for how big the list is (see also #12585), so I decided to just list the relevant commands for now. We might be able to parse the rustup output to report those targets but I didn't receive a glowing endorsement from the rustup team about parsing the list (more of "yes, hyrums law and at least its interactive rather than CI").
Before:
After:
(quotes were used because the other "list available" use them, we should probably work to be uniform in how we quote)
How should we test and review this PR?
First PR adds a test showing the existing output and then through the rest you can see how the output changed