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

rustup component (add|remove) should not rely on hardcoded target triples #3783

Open
2 tasks done
rami3l opened this issue Apr 23, 2024 · 3 comments
Open
2 tasks done
Labels
Milestone

Comments

@rami3l
Copy link
Member

rami3l commented Apr 23, 2024

Verification

Problem

The direct cause of #3166 is that wasm32-unknown-unknown hasn't been hardcoded into our codebase:

static LIST_ARCHS: &[&str] = &[
"i386",
"i586",
"i686",
"x86_64",
"arm",
"armv7",
"armv7s",
"aarch64",
"mips",
"mipsel",
"mips64",
"mips64el",
"powerpc",
"powerpc64",
"powerpc64le",
"riscv64gc",
"s390x",
"loongarch64",
];
static LIST_OSES: &[&str] = &[
"pc-windows",
"unknown-linux",
"apple-darwin",
"unknown-netbsd",
"apple-ios",
"linux",
"rumprun-netbsd",
"unknown-freebsd",
"unknown-illumos",
];

[...] we really should not hardcode target triples in our artifact, as the complete list changes quite regularly.

#3601 (comment)

Rustup version

rustup 1.27.0+74 (a6c9fae91 2024-04-21) dirty 1 modification
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.77.2 (25ef9e3d8 2024-04-09)`
@rami3l rami3l added the bug label Apr 23, 2024
@rami3l rami3l added this to the 1.28.0 milestone Apr 23, 2024
@djc
Copy link
Contributor

djc commented Apr 23, 2024

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).

@rami3l
Copy link
Member Author

rami3l commented Apr 30, 2024

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 rustc --print target-list (I assume we cannot add/remove a component without even having rustc installed, right?), or by reading the manifest (either at comptime or at runtime) and deduplicating.

@djc
Copy link
Contributor

djc commented May 9, 2024

Yeah, splitting is definitely not completely straightforward, but having an automated test that checks our internal code matches any targets in curent manifests still sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants