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

Provide Command to Show Host Tuple #1663

Closed
naftulikay opened this issue Feb 14, 2019 · 8 comments
Closed

Provide Command to Show Host Tuple #1663

naftulikay opened this issue Feb 14, 2019 · 8 comments

Comments

@naftulikay
Copy link

naftulikay commented Feb 14, 2019

Describe the problem you are trying to solve

Similar to #1659, I'm writing automation around rustup. I need a way to get the x86_64-unknown-linux-gnu tuple from rustup to find out what the host platform is in a way that I can then use around rustup.

Describe the solution you'd like

I may PR this in, but a command like rustup host which displayed this architecture would be ideal.

@ehuss
Copy link
Contributor

ehuss commented Feb 15, 2019

The host triple can be determined from rustc -Vv.

@naftulikay
Copy link
Author

Will rustc always show the host's triple as opposed to whatever toolchain that rustc is compiling for?

@ehuss
Copy link
Contributor

ehuss commented Feb 15, 2019

The host: field is the architecture of the compiler itself. The architecture it is compiling for is called the target triple and is specified with --target (defaulting to host if --target is not used).

The host triple may have different values on the same machine. For example, it is possible to run an i686 rustc binary on an x86 machine, or various different abi's on linux or windows (musl, gnu, msvc, etc.). So you can't really say there is one "host", the user can pick different ones. rustup has a "default" toolchain, but without knowing more about what you need it for, it's hard to say which information is relevant.

@naftulikay
Copy link
Author

naftulikay commented Feb 15, 2019

@ehuss my use case is that when a user specifies that they'd like rust-src to be installed, when I subsequently list which components are installed (via #1659), I need to append the triple to match against it.

e.g. a user passes rustup_components: [rust-src], I run rustup component list --installed and get fully-qualified component names with the triples appended, so in order to check whether rust-src is installed, I need to try matching against the list by appending the host triple. Something like this:

fn is_component_installed(component: &str, installed_components: &[&str]) -> bool {
    let triple = get_rust_host_triple();
    for installed_component in installed_components {
        if component == installed_component || format!("{}-{}", component, triple) == installed_component {
            return true;
        }
    }

    return false
}

This means that I won't have to force my users to specify fully qualified component names.

@ehuss
Copy link
Contributor

ehuss commented Feb 15, 2019

rustup show will tell you the current host triple, too:

Default host: x86_64-unknown-linux-gnu

rust-src doesn't have a triple. If you don't want to do a starts_with match, I would probably just grab the host from rustup show.

@naftulikay
Copy link
Author

Yeah, I considered this. My only concern is that rustup show could change at any point in time, breaking my automation.

rust-src wasn't a good example, maybe rustfmt or another platform-specific one.

@ehuss
Copy link
Contributor

ehuss commented Feb 16, 2019

Yea, it seems like #450 would be helpful. It's hard to say how stable the output is.

@rbtcollins
Copy link
Contributor

So this has been sitting around for over a year. I think that the maintainers aren't going to get to it. #450 is something we are likely to get to, but we can't promise even with that that we wouldn't ever accidentally change some output - though we would of course do our best ;).

For now, I'm closing this, but if someone were to put up a PR, we'd be happy to have a subcommand that does it I think, its just that there is no point having a ticket saying 'please add this' - its not on the roadmap.

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

No branches or pull requests

3 participants