Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/cargo/core/compiler/compile_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,27 @@ impl CompileKind {
fallback: CompileKindFallback,
) -> CargoResult<Vec<CompileKind>> {
let dedup = |targets: &[String]| {
Ok(targets
let deduplicated_targets = targets
.iter()
.map(|value| Ok(CompileKind::Target(CompileTarget::new(value)?)))
.map(|value| {
// This neatly substitutes the manually-specified `host` target directive
// with the compiling machine's target triple.

if value.as_str() == "host" {
let host_triple = env!("RUST_HOST_TARGET");
Ok(CompileKind::Target(CompileTarget::new(host_triple)?))
} else {
Ok(CompileKind::Target(CompileTarget::new(value.as_str())?))
}
})
// First collect into a set to deduplicate any `--target` passed
// more than once...
.collect::<CargoResult<BTreeSet<_>>>()?
// ... then generate a flat list for everything else to use.
.into_iter()
.collect())
.collect();

Ok(deduplicated_targets)
};

if !targets.is_empty() {
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,11 @@ fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
}
}

// Allow tab-completion for `host` as the desired target.
candidates.push(clap_complete::CompletionCandidate::new("host").help(Some(
concat!("alias for: ", env!("RUST_HOST_TARGET")).into(),
)));

candidates
}

Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,24 @@ OPTIONS

Compilation Options
--target triple
Benchmark for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Benchmark for the specified target architecture. Flag may be
specified multiple times. The default is the host architecture. The
general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,24 @@ OPTIONS

Compilation Options
--target triple
Build for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Build for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,24 @@ OPTIONS

Compilation Options
--target triple
Check for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Check for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ OPTIONS
target in the root of the workspace.

--target triple
Clean for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Clean for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@ OPTIONS

Compilation Options
--target triple
Document for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Document for the specified target architecture. Flag may be
specified multiple times. The default is the host architecture. The
general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,24 @@ DESCRIPTION
OPTIONS
Fetch options
--target triple
Fetch for the given architecture. The default is all architectures.
The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Fetch for the specified target architecture. Flag may be specified
multiple times. The default is all architectures. The general format
of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,24 @@ OPTIONS

Compilation Options
--target triple
Fix for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Fix for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
22 changes: 18 additions & 4 deletions src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,24 @@ OPTIONS

Compilation Options
--target triple
Install for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets.
Install for the specified target architecture. The default is the
host architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,24 @@ OPTIONS

Compilation Options
--target triple
Package for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Package for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-publish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,24 @@ OPTIONS

Compilation Options
--target triple
Publish for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Publish for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
20 changes: 17 additions & 3 deletions src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,24 @@ OPTIONS

Compilation Options
--target triple
Run for the given architecture. The default is the host
Run for the specified target architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets.
<arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
23 changes: 18 additions & 5 deletions src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,24 @@ OPTIONS

Compilation Options
--target triple
Build for the given architecture. The default is the host
architecture. The general format of the triple is
<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
a list of supported targets. This flag may be specified multiple
times.
Build for the specified target architecture. Flag may be specified
multiple times. The default is the host architecture. The general
format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.

Possible values:

o Any supported target in rustc --print target-list.

o "host", which will internally be substituted by the host’s
target. This can be particularly useful if you’re
cross-compiling some crates, and don’t want to specify your
host’s machine as a target (for instance, an xtask in a shared
project that may be worked on by many hosts).

o A path to a custom target specification. See Custom Target Lookup
Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
for more information.

This may also be specified with the build.target config value
<https://doc.rust-lang.org/cargo/reference/config.html>.
Expand Down
Loading
Loading