diff --git a/src/cargo/core/compiler/compile_kind.rs b/src/cargo/core/compiler/compile_kind.rs
index b9cca3794c5..e9fe5464888 100644
--- a/src/cargo/core/compiler/compile_kind.rs
+++ b/src/cargo/core/compiler/compile_kind.rs
@@ -84,15 +84,27 @@ impl CompileKind {
fallback: CompileKindFallback,
) -> CargoResult> {
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::>>()?
// ... then generate a flat list for everything else to use.
.into_iter()
- .collect())
+ .collect();
+
+ Ok(deduplicated_targets)
};
if !targets.is_empty() {
diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs
index c60316452ae..e1d2f9a8894 100644
--- a/src/cargo/util/command_prelude.rs
+++ b/src/cargo/util/command_prelude.rs
@@ -1257,6 +1257,11 @@ fn get_target_triples() -> Vec {
}
}
+ // 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
}
diff --git a/src/doc/man/generated_txt/cargo-bench.txt b/src/doc/man/generated_txt/cargo-bench.txt
index 4c35f28c8fd..09f742fd86b 100644
--- a/src/doc/man/generated_txt/cargo-bench.txt
+++ b/src/doc/man/generated_txt/cargo-bench.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt
index cb13663834c..2f8247937ed 100644
--- a/src/doc/man/generated_txt/cargo-build.txt
+++ b/src/doc/man/generated_txt/cargo-build.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt
index 7df6e62935e..42be19298c8 100644
--- a/src/doc/man/generated_txt/cargo-check.txt
+++ b/src/doc/man/generated_txt/cargo-check.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-clean.txt b/src/doc/man/generated_txt/cargo-clean.txt
index 2325c090c14..09feaf50b34 100644
--- a/src/doc/man/generated_txt/cargo-clean.txt
+++ b/src/doc/man/generated_txt/cargo-clean.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-doc.txt b/src/doc/man/generated_txt/cargo-doc.txt
index 071663129c5..bac56fd6c50 100644
--- a/src/doc/man/generated_txt/cargo-doc.txt
+++ b/src/doc/man/generated_txt/cargo-doc.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-fetch.txt b/src/doc/man/generated_txt/cargo-fetch.txt
index 939821dcbeb..91e308f650f 100644
--- a/src/doc/man/generated_txt/cargo-fetch.txt
+++ b/src/doc/man/generated_txt/cargo-fetch.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt
index f15544bfa29..56e131b45fe 100644
--- a/src/doc/man/generated_txt/cargo-fix.txt
+++ b/src/doc/man/generated_txt/cargo-fix.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-install.txt b/src/doc/man/generated_txt/cargo-install.txt
index 7575948a38a..2001a2cd0f9 100644
--- a/src/doc/man/generated_txt/cargo-install.txt
+++ b/src/doc/man/generated_txt/cargo-install.txt
@@ -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
- ---. 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
+ ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-package.txt b/src/doc/man/generated_txt/cargo-package.txt
index 086b68d050d..54c22628015 100644
--- a/src/doc/man/generated_txt/cargo-package.txt
+++ b/src/doc/man/generated_txt/cargo-package.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-publish.txt b/src/doc/man/generated_txt/cargo-publish.txt
index 770d913759c..c303754b2eb 100644
--- a/src/doc/man/generated_txt/cargo-publish.txt
+++ b/src/doc/man/generated_txt/cargo-publish.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-run.txt b/src/doc/man/generated_txt/cargo-run.txt
index dd9e8123c0d..9f5f3a610b1 100644
--- a/src/doc/man/generated_txt/cargo-run.txt
+++ b/src/doc/man/generated_txt/cargo-run.txt
@@ -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
- ---. Run rustc --print target-list for
- a list of supported targets.
+ ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-rustc.txt b/src/doc/man/generated_txt/cargo-rustc.txt
index 3095cf9189e..763b9b3bbec 100644
--- a/src/doc/man/generated_txt/cargo-rustc.txt
+++ b/src/doc/man/generated_txt/cargo-rustc.txt
@@ -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
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-rustdoc.txt b/src/doc/man/generated_txt/cargo-rustdoc.txt
index ffe6c8e4d01..da7ee6b6e8b 100644
--- a/src/doc/man/generated_txt/cargo-rustdoc.txt
+++ b/src/doc/man/generated_txt/cargo-rustdoc.txt
@@ -128,11 +128,24 @@ OPTIONS
Compilation Options
--target triple
- Document for the given architecture. The default is the host
- architecture. The general format of the triple is
- ---. 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 ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/generated_txt/cargo-test.txt b/src/doc/man/generated_txt/cargo-test.txt
index cf22817d0b2..272b5fcaab9 100644
--- a/src/doc/man/generated_txt/cargo-test.txt
+++ b/src/doc/man/generated_txt/cargo-test.txt
@@ -242,11 +242,24 @@ OPTIONS
Compilation Options
--target triple
- Test for the given architecture. The default is the host
- architecture. The general format of the triple is
- ---. Run rustc --print target-list for
- a list of supported targets. This flag may be specified multiple
- times.
+ Test for the specified target architecture. Flag may be specified
+ multiple times. The default is the host architecture. The general
+ format of the triple is ---.
+
+ 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
+
+ for more information.
This may also be specified with the build.target config value
.
diff --git a/src/doc/man/includes/options-target-triple.md b/src/doc/man/includes/options-target-triple.md
index 60c52a15868..977b52b9358 100644
--- a/src/doc/man/includes/options-target-triple.md
+++ b/src/doc/man/includes/options-target-triple.md
@@ -1,14 +1,17 @@
{{#option "`--target` _triple_"}}
-{{actionverb}} for the given architecture.
+{{actionverb}} for the specified target architecture. {{~#if multitarget }} Flag may be specified multiple times. {{~/if}}
{{~#if target-default-to-all-arch}} The default is all architectures.
{{~else}} The default is the host architecture.
{{~/if}} The general format of the triple is
-`---`. Run `rustc --print target-list` for a
-list of supported targets.
-{{~#if multitarget }} This flag may be specified multiple times. {{~/if}}
+`---`.
-This may also be specified with the `build.target`
-[config value](../reference/config.html).
+Possible values:
+- Any supported target in `rustc --print target-list`.
+- `"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).
+- A path to a custom target specification. See [Custom Target Lookup Path](../../rustc/targets/custom.html#custom-target-lookup-path) for more information.
+
+
+This may also be specified with the `build.target` [config value](../reference/config.html).
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md
index 18d95a53dd2..98a7bc9d32f 100644
--- a/src/doc/src/commands/cargo-bench.md
+++ b/src/doc/src/commands/cargo-bench.md
@@ -256,11 +256,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md
index 3bf0944798f..64387551538 100644
--- a/src/doc/src/commands/cargo-build.md
+++ b/src/doc/src/commands/cargo-build.md
@@ -171,11 +171,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md
index 5592895ac5c..a80c704532b 100644
--- a/src/doc/src/commands/cargo-check.md
+++ b/src/doc/src/commands/cargo-check.md
@@ -167,11 +167,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md
index e18a35a5d9a..1eb9881e770 100644
--- a/src/doc/src/commands/cargo-clean.md
+++ b/src/doc/src/commands/cargo-clean.md
@@ -59,11 +59,15 @@ Defaults to 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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md
index 3b97a336692..6b5db3a6dc5 100644
--- a/src/doc/src/commands/cargo-doc.md
+++ b/src/doc/src/commands/cargo-doc.md
@@ -146,11 +146,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md
index 8cdf5cc1311..443762465ce 100644
--- a/src/doc/src/commands/cargo-fetch.md
+++ b/src/doc/src/commands/cargo-fetch.md
@@ -29,11 +29,15 @@ you plan to use Cargo without a network with the `--offline` flag.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md
index 1a05599b488..5a0dfccc96d 100644
--- a/src/doc/src/commands/cargo-fix.md
+++ b/src/doc/src/commands/cargo-fix.md
@@ -247,11 +247,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-install.md b/src/doc/src/commands/cargo-install.md
index daa90fb25e6..8e272a80e80 100644
--- a/src/doc/src/commands/cargo-install.md
+++ b/src/doc/src/commands/cargo-install.md
@@ -212,11 +212,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md
index ea9ee490bee..5c75c0048f4 100644
--- a/src/doc/src/commands/cargo-package.md
+++ b/src/doc/src/commands/cargo-package.md
@@ -202,11 +202,15 @@ single quotes or double quotes around each pattern.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md
index 4e2484afaf1..6b6081d8276 100644
--- a/src/doc/src/commands/cargo-publish.md
+++ b/src/doc/src/commands/cargo-publish.md
@@ -122,11 +122,15 @@ single quotes or double quotes around each pattern.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-run.md b/src/doc/src/commands/cargo-run.md
index 29d4264f4ef..968dbda0010 100644
--- a/src/doc/src/commands/cargo-run.md
+++ b/src/doc/src/commands/cargo-run.md
@@ -88,11 +88,15 @@ be specified multiple times, which enables all specified features.
--target
triple
-- Run 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 may also be specified with the build.target
-config value.
+- Run 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md
index 7f6f0a49344..73a168102bd 100644
--- a/src/doc/src/commands/cargo-rustc.md
+++ b/src/doc/src/commands/cargo-rustc.md
@@ -160,11 +160,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md
index 162462594c7..8ae1559e7da 100644
--- a/src/doc/src/commands/cargo-rustdoc.md
+++ b/src/doc/src/commands/cargo-rustdoc.md
@@ -166,11 +166,15 @@ be specified multiple times, which enables all specified features.
--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.
-This may also be specified with the build.target
-config value.
+- 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md
index bd7d5f5650e..b76010bf518 100644
--- a/src/doc/src/commands/cargo-test.md
+++ b/src/doc/src/commands/cargo-test.md
@@ -278,11 +278,15 @@ be specified multiple times, which enables all specified features.
--target
triple
-- Test 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.
-This may also be specified with the build.target
-config value.
+- Test 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:
+
+- Any supported target in
rustc --print target-list
.
+"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).
+- A path to a custom target specification. See Custom Target Lookup Path for more information.
+
+This may also be specified with the build.target
config value.
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
build cache documentation for more details.
diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md
index 420ff25248e..52e1c23c124 100644
--- a/src/doc/src/reference/config.md
+++ b/src/doc/src/reference/config.md
@@ -459,11 +459,10 @@ Sets the executable to use for `rustdoc`.
The default [target platform triples][target triple] to compile to.
-This allows passing either a string or an array of strings. Each string value
-is a target platform triple. The selected build targets will be built for each
-of the selected architectures.
-
-The string value may also be a relative path to a `.json` target spec file.
+Possible values:
+- Any supported target in `rustc --print target-list`.
+- `"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).
+- A path to a custom target specification. See [Custom Target Lookup Path](../../rustc/targets/custom.html#custom-target-lookup-path) for more information.
Can be overridden with the `--target` CLI option.
diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1
index f28ddb30742..73e7c64d714 100644
--- a/src/etc/man/cargo-bench.1
+++ b/src/etc/man/cargo-bench.1
@@ -267,12 +267,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Benchmark for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1
index cf8ab4e5014..dd478a54114 100644
--- a/src/etc/man/cargo-build.1
+++ b/src/etc/man/cargo-build.1
@@ -166,12 +166,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Build for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1
index 2805c2b5939..0fd8d9b3dab 100644
--- a/src/etc/man/cargo-check.1
+++ b/src/etc/man/cargo-check.1
@@ -162,12 +162,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Check for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-clean.1 b/src/etc/man/cargo-clean.1
index c3cb9f2bc54..4ca8ed98b40 100644
--- a/src/etc/man/cargo-clean.1
+++ b/src/etc/man/cargo-clean.1
@@ -57,12 +57,24 @@ Defaults to \fBtarget\fR in the root of the workspace.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Clean for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1
index b236f12a84d..96d237cbd09 100644
--- a/src/etc/man/cargo-doc.1
+++ b/src/etc/man/cargo-doc.1
@@ -135,12 +135,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Document for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-fetch.1 b/src/etc/man/cargo-fetch.1
index cb2f7652ac1..726087901f7 100644
--- a/src/etc/man/cargo-fetch.1
+++ b/src/etc/man/cargo-fetch.1
@@ -25,12 +25,24 @@ you plan to use Cargo without a network with the \fB\-\-offline\fR flag.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Fetch for the given architecture. The default is all architectures. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1
index f44b28fcca1..0e79e99b89f 100644
--- a/src/etc/man/cargo-fix.1
+++ b/src/etc/man/cargo-fix.1
@@ -257,12 +257,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Fix for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1
index 4b6bc450647..04c90640eaf 100644
--- a/src/etc/man/cargo-install.1
+++ b/src/etc/man/cargo-install.1
@@ -242,12 +242,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Install for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1
index 0dca951f851..168f3152fcc 100644
--- a/src/etc/man/cargo-package.1
+++ b/src/etc/man/cargo-package.1
@@ -239,12 +239,24 @@ single quotes or double quotes around each pattern.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Package for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1
index 462c94bb699..6d9d3a4a8d1 100644
--- a/src/etc/man/cargo-publish.1
+++ b/src/etc/man/cargo-publish.1
@@ -132,12 +132,24 @@ single quotes or double quotes around each pattern.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Publish for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-run.1 b/src/etc/man/cargo-run.1
index 0e69842149e..f1640ee60cd 100644
--- a/src/etc/man/cargo-run.1
+++ b/src/etc/man/cargo-run.1
@@ -72,12 +72,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Run for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR for a
-list of supported targets.
+Run for the specified target architecture. The default is the host architecture. The general format of the triple is
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1
index e33b4faba8a..865e8db4c1c 100644
--- a/src/etc/man/cargo-rustc.1
+++ b/src/etc/man/cargo-rustc.1
@@ -152,12 +152,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Build for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1
index 5b85f54572f..77f9bc4bf88 100644
--- a/src/etc/man/cargo-rustdoc.1
+++ b/src/etc/man/cargo-rustdoc.1
@@ -154,12 +154,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Document for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR 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
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1
index da783c1a370..2957f891bd9 100644
--- a/src/etc/man/cargo-test.1
+++ b/src/etc/man/cargo-test.1
@@ -287,12 +287,24 @@ Do not activate the \fBdefault\fR feature of the selected packages.
.sp
\fB\-\-target\fR \fItriple\fR
.RS 4
-Test for the given architecture. The default is the host architecture. The general format of the triple is
-\fB\-\-\-\fR\&. Run \fBrustc \-\-print target\-list\fR for a
-list of supported targets. This flag may be specified multiple times.
+Test for the specified target architecture. Flag may be specified multiple times. The default is the host architecture. The general format of the triple is
+\fB\-\-\-\fR\&.
.sp
-This may also be specified with the \fBbuild.target\fR
-\fIconfig value\fR \&.
+Possible values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR\&.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fB"host"\fR, which will internally be substituted by the host\[cq]s target. This can be particularly useful if you\[cq]re cross\-compiling some crates, and don\[cq]t want to specify your host\[cq]s machine as a target (for instance, an \fBxtask\fR in a shared project that may be worked on by many hosts).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'A path to a custom target specification. See \fICustom Target Lookup Path\fR for more information.
+.RE
+.sp
+This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&.
.sp
Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs
index c4ad4093067..e2f9009f0df 100644
--- a/tests/testsuite/cross_compile.rs
+++ b/tests/testsuite/cross_compile.rs
@@ -125,6 +125,89 @@ fn simple_cross_config() {
}
}
+#[cargo_test]
+fn target_host_arg() {
+ if cross_compile_disabled() {
+ return;
+ }
+
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ edition = "2015"
+ authors = []
+ build = "build.rs"
+ "#,
+ )
+ .file(
+ "build.rs",
+ &format!(
+ r#"
+ fn main() {{
+ assert_eq!(std::env::var("TARGET").unwrap(), "{}");
+ }}
+ "#,
+ rustc_host()
+ ),
+ )
+ .file("src/lib.rs", r#""#)
+ .build();
+
+ p.cargo("build -v --target host")
+ .with_stderr_contains("[RUNNING] `rustc [..] --target [HOST_TARGET] [..]`")
+ .run();
+}
+
+#[cargo_test]
+fn target_host_config() {
+ if cross_compile_disabled() {
+ return;
+ }
+
+ let p = project()
+ .file(
+ ".cargo/config.toml",
+ &format!(
+ r#"
+ [build]
+ target = "host"
+ "#,
+ ),
+ )
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ edition = "2015"
+ authors = []
+ build = "build.rs"
+ "#,
+ )
+ .file(
+ "build.rs",
+ &format!(
+ r#"
+ fn main() {{
+ assert_eq!(std::env::var("TARGET").unwrap(), "{}");
+ }}
+ "#,
+ rustc_host()
+ ),
+ )
+ .file("src/lib.rs", r#""#)
+ .build();
+
+ p.cargo("build -v")
+ .with_stderr_contains("[RUNNING] `rustc [..] --target [HOST_TARGET] [..]`")
+ .run();
+}
+
#[cargo_test]
fn simple_deps() {
if cross_compile_disabled() {