-
Notifications
You must be signed in to change notification settings - Fork 952
Fix conversion from PartialTargetTriple to TargetTriple #3467
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 conversion from PartialTargetTriple to TargetTriple #3467
Conversation
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.
This looks good, thanks!
"i586", | ||
"i686", | ||
"x86_64", | ||
"aarch64", |
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.
Just to check, where did you source these lists of current arches, OSes and envs?
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 copied all the targets from the Platform Support section of the rustc book and created the lists manually. I'm not sure if these lists already exist somewhere, so I created them manually.
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.
Sure, maybe add a docstring linking to a section in the book for each of these constants?
src/dist/dist.rs
Outdated
} | ||
let arch = value.arch.ok_or("Incomplete / bad target triple")?; | ||
let os = value.os.ok_or("Incomplete / bad target triple")?; | ||
let triple = match value.env { |
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.
Tiny style nit: I would spell this Ok(Self(match value.env { .. }))
directly, which avoids a low-value single use binding.
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.
Sure, willing to do so.
Maybe it would be good to add some tests for the new behavior? Especially the high-level CLI behavior as discussed in #3166. |
Thanks for the patch. I have two questions.
One possibility is to hook in a call to resolve() with the context of the toolchain. Another possibility is to look at what would happen if instead we defined The problem I am worried about is that So a missing env gets filled in - and I'm still used to the older machine-vendor-os triples from gcc - https://wiki.osdev.org/Target_Triplet / https://github.com/gcc-mirror/gcc/blob/master/config.sub#L1877C6-L1877C37 - where apple is a vendor and darwin is the os. |
Trying to clarify this issue as best I can.
The rustup will try to extract target triple from the substring from the user input. If the substring of user input does not match the combination of archs, oses and envs in For the case in #3166:
Because of rustup cannot parse
The actual component and target should be The valid component list could be obtained from unique values from Most error messages should remain, except the input component is totally gibberish and does not match any valid component and target, then display a different message to address this error. |
Most of valid target triple have this structure:
For instance, a windows system with gnu environment would be:
But a triple without
env
could be a valid triple:This PR makes convertion of
PartialTargetTriple
without anenv
field a validTargetTriple
and updates the list of possible targets ofPartialTargetTriple
.This also makes
Component::new_with_target
able to create a valid target from a triple withoutenv
.Fix: #3166