Skip to content

[RFC] cargo install should ignore the default build target #5850

@japaric

Description

@japaric

This is a papercut embedded users often encounter as our templates ship with a .cargo/config file
that sets a default build target:

$ cargo new --lib foo && cd $_

$ mkdir .cargo
$ cat >.cargo/config <<'EOF'
[build]
target = "thumbv7em-none-eabi"
EOF

$ cargo install cargo-binutils
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-binutils v0.1.1
   Compiling unicode-xid v0.1.0
   Compiling failure_derive v0.1.2
   Compiling serde v1.0.70
   Compiling libc v0.2.42
   Compiling void v1.0.2
   Compiling semver-parser v0.7.0
   Compiling rustc-demangle v0.1.9
   Compiling ucd-util v0.1.1
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabi` target may not be installed

The issue is that cargo-install compiles cargo-binutils for the thumbv7em-none-eabi target
and that fails because there's no pre-compiled std for that target. Even if the compilation
did succeed that would result in an ARM binary being installed and a x86_64 host would not be able
to run it in most cases.

I propose that cargo-install ignores the default build target if one is set in a Cargo
configuration file. In the, IMO, rare case where one does want to install a cross compiled binary
cargo install --target $T would be the way to go.

This is technically a breaking change but I doubt anyone is relying on this.

Thoughts?

cc @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions