-
Notifications
You must be signed in to change notification settings - Fork 954
rustup component (add|remove)
should not rely on hardcoded target triples
#3783
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
Comments
I think a good approach here would be to add an integration test that can download a recent manifest, parse it, and regenerate a source file that contains current definitions of these (and fails the test if they're outdated). |
@djc The current model of target triples in Rustup requires some non-code knowledge to correctly generate the list: { arch: aarch64, os: linux, env: android }
{ arch: aarch64, os: unknown-freebsd} Looking at the original file, I think a reasonable (but possibly breaking) solution would be parsing the triples as follows: // for `x-y`
{ arch: x, os: y }
// special case for `x-y-w` where `y` is `none` or `linux`
// e.g. `thumbv4t-none-eabi`, `i686-linux-android`
// (should've been called `x-unknown-y-w`, but alas)
{ arch: x, os: y, env: w }
// for `x-y-z`
{ arch: x, os: y-z }
// for `x-y-z-w`
{ arch: x, os: y-z, env: w } Then we can get a list of triples by using things like |
Yeah, splitting is definitely not completely straightforward, but having an automated test that checks our internal code matches any targets in current manifests still sounds good. |
@djc After some investigation I think https://docs.rs/platforms could potentially be a better alternative, also I like its glob patterns which might greatly simplify our Implementation. I'm not sure how this might interact with our triple shorthands though... Lines 107 to 119 in 2a5a69e
Also we need to ensure the existence of an escape hatch for new/custom triples. |
Ah yes, that looks great! |
So here's my plan for the experiment: I'll try to generate a source file by CS 101-level string templating according to the rules in #3783 (comment), and The only concern I have is the following snippet in Lines 3 to 27 in 2a5a69e
However I don't know too much about this undocumented environment variable and how it's supposed to be used. Maybe @kinnison can provide more context on this one? I mean, by using Update: Grepping the whole repo showed that Line 261 in 2a5a69e
Lines 266 to 268 in 2a5a69e
|
Instead of using |
@djc I see your point of keeping those lists clearly visible in the codebase, but will this cause PR authors to chase a moving target, similar to what we have now WRT clippy lints? My original point is that outsourcing the changes to an external dependency means updating the list is always a version bump away. |
Potentially -- but (a) fixing it should be very straightforward and (b) don't know how much the target moves. If you think using platforms is easier, I'd go with that first, we can see which downsides we run into over time. |
Verification
Problem
#3601 (comment)
Rustup version
The text was updated successfully, but these errors were encountered: