rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.1k stars 877 forks source link

request: a flag to limit target list results by support tier level #3308

Open mcandre opened 1 year ago

mcandre commented 1 year ago

Problem you are trying to solve

Hi,

I want to loop over the tier 1 and tier 2 targets and cross-compile my Rust apps for these platforms. I do this for my Rust projects in order to make it easier for non-Rust users to enjoy my command line tools!

I have a working script to do just that, called crit, based on the excellent cross tool.

https://github.com/mcandre/crit

This works (yay!) for about 80% of the available triples from rustup target list. Unfortunately, it requires hardcoding target triples to skip over, namely the tier 3 triples, for which the cross community has yet to publish stable Docker images.

Over time, this triple exclusion hardcoding represents some extra maintenance and fragility. I would prefer that rustup be able to filter by support tier as a built-in capability.

There is an HTML source of truth to get this data:

https://doc.rust-lang.org/rustc/platform-support.html

But of course HTML is not the most friendly or robust way to query the information in an automated fashion.

Solution you'd like

I would love for rustup target list to accept an optional flag, like --max-support-tier <n>.

When present, the flag elides target triples from the console output whose support tier is known to be larger than n.

Alternatively, add a new column to the target triple output lines, indicating the support tier number. Then, we still have an automated source of truth, which downstream CLI tools could reasonably handle parsing with simple regular expressions / awk / etc.

Notes

No response

rbtcollins commented 1 year ago

So rustup is in the same situation your code is with respect to this: there is no intrinsic knowledge in rustup about whether a given triple is a particular tier.

Rustup consumes the channel data - https://forge.rust-lang.org/infra/channel-layout.html - to decide what is available and make downloads possible.

Secondly, rustup doesn't know what cross has image available for - there is an obvious race condition where something can move from one tier to another but not yet have a cross image.

So I don't think rustup is a good place to solve this.

Working with infra to get the metadata you want into the channel information would be the obvious way forward: once that data is present, you could then consume it as an automated source of truth (modulo the race with cross image production etc).

I'll leave this open for now, since a reasonable request would be 'show this data once its in the channel data', though I'm not entirely sure of the usefulness of that, since rustup itself doesn't have an API today, and depending on a CLI also isn't a stable interface.

mcandre commented 1 year ago

That's fair.

Rust Forge could assist, by either:

Rustin170506 commented 1 year ago
  • Offering a URL to a TOML file providing target triple support tier information; Or
  • Peppering a stable element in the channel-layout.html DOM tree with xpath-friendly attributes.

https://github.com/rust-lang/rustup-components-history Does this website help?

mcandre commented 1 year ago

That's similarly fragile, in terms of extracting the information by automated means.

We would need to establish a permanent DOM tree structure there. Better yet, store the data in a JSON file with a stable schema, and have the web page generate the DOM from the JSON data.