From 7794d62ced1051f1f1600a21d675ef4addcf2c28 Mon Sep 17 00:00:00 2001
From: zdivelbiss <8019570+zdivelbiss@users.noreply.github.com>
Date: Thu, 14 Aug 2025 11:00:20 -0500
Subject: [PATCH 1/5] implement "host" target substitution
---
src/cargo/core/compiler/compile_kind.rs | 18 +++++++++++++++---
src/cargo/util/command_prelude.rs | 3 +++
2 files changed, 18 insertions(+), 3 deletions(-)
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..506ed08d7a5 100644
--- a/src/cargo/util/command_prelude.rs
+++ b/src/cargo/util/command_prelude.rs
@@ -1257,6 +1257,9 @@ fn get_target_triples() -> Vec {
}
}
+ // Allow tab-completion for `host` as the desired target.
+ candidates.push(clap_complete::CompletionCandidate::new("host"));
+
candidates
}
From b3f5e052f6a5aa9806c55887b7257ddb1647f8b0 Mon Sep 17 00:00:00 2001
From: zdivelbiss <8019570+zdivelbiss@users.noreply.github.com>
Date: Thu, 14 Aug 2025 18:57:12 -0500
Subject: [PATCH 2/5] tests for `host` target specifier
---
tests/testsuite/cross_compile.rs | 113 +++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs
index c4ad4093067..fd0c46b2ba0 100644
--- a/tests/testsuite/cross_compile.rs
+++ b/tests/testsuite/cross_compile.rs
@@ -125,6 +125,119 @@ 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/main.rs",
+ &format!(
+ r#"
+ use std::env;
+ fn main() {{
+ assert_eq!(env::consts::ARCH, "{}");
+ }}
+ "#,
+ cross_compile::native_arch()
+ ),
+ )
+ .build();
+
+ let target = rustc_host();
+ p.cargo("build -v --target host").run();
+ assert!(p.target_bin(target, "foo").is_file());
+
+ if cross_compile_can_run_on_host() {
+ p.process(&p.target_bin(target, "foo")).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/main.rs",
+ &format!(
+ r#"
+ use std::env;
+ fn main() {{
+ assert_eq!(env::consts::ARCH, "{}");
+ }}
+ "#,
+ cross_compile::native_arch()
+ ),
+ )
+ .build();
+
+ let target = rustc_host();
+ p.cargo("build -v").run();
+ assert!(p.target_bin(target, "foo").is_file());
+
+ if cross_compile_can_run_on_host() {
+ p.process(&p.target_bin(target, "foo")).run();
+ }
+}
+
#[cargo_test]
fn simple_deps() {
if cross_compile_disabled() {
From b23e0a99b25c0a36f0b41be8bc39c906f3d1323e Mon Sep 17 00:00:00 2001
From: zdivelbiss <8019570+zdivelbiss@users.noreply.github.com>
Date: Thu, 14 Aug 2025 20:59:32 -0500
Subject: [PATCH 3/5] documentation for `host` target specifier
---
src/cargo/util/command_prelude.rs | 6 ++--
src/doc/man/generated_txt/cargo-bench.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-build.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-check.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-clean.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-doc.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-fetch.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-fix.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-install.txt | 25 +++++++++++++----
src/doc/man/generated_txt/cargo-package.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-publish.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-run.txt | 27 +++++++++++++-----
src/doc/man/generated_txt/cargo-rustc.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-rustdoc.txt | 28 +++++++++++++------
src/doc/man/generated_txt/cargo-test.txt | 28 +++++++++++++------
src/doc/man/includes/options-target-triple.md | 20 +++++++------
src/doc/src/commands/cargo-bench.md | 18 ++++++------
src/doc/src/commands/cargo-build.md | 18 ++++++------
src/doc/src/commands/cargo-check.md | 18 ++++++------
src/doc/src/commands/cargo-clean.md | 18 ++++++------
src/doc/src/commands/cargo-doc.md | 18 ++++++------
src/doc/src/commands/cargo-fetch.md | 18 ++++++------
src/doc/src/commands/cargo-fix.md | 18 ++++++------
src/doc/src/commands/cargo-install.md | 18 ++++++------
src/doc/src/commands/cargo-package.md | 18 ++++++------
src/doc/src/commands/cargo-publish.md | 18 ++++++------
src/doc/src/commands/cargo-run.md | 18 ++++++------
src/doc/src/commands/cargo-rustc.md | 18 ++++++------
src/doc/src/commands/cargo-rustdoc.md | 18 ++++++------
src/doc/src/commands/cargo-test.md | 18 ++++++------
src/doc/src/reference/config.md | 11 ++++----
src/etc/man/cargo-bench.1 | 26 +++++++++++------
src/etc/man/cargo-build.1 | 26 +++++++++++------
src/etc/man/cargo-check.1 | 26 +++++++++++------
src/etc/man/cargo-clean.1 | 26 +++++++++++------
src/etc/man/cargo-doc.1 | 26 +++++++++++------
src/etc/man/cargo-fetch.1 | 26 +++++++++++------
src/etc/man/cargo-fix.1 | 26 +++++++++++------
src/etc/man/cargo-install.1 | 26 +++++++++++------
src/etc/man/cargo-package.1 | 26 +++++++++++------
src/etc/man/cargo-publish.1 | 26 +++++++++++------
src/etc/man/cargo-run.1 | 26 +++++++++++------
src/etc/man/cargo-rustc.1 | 26 +++++++++++------
src/etc/man/cargo-rustdoc.1 | 26 +++++++++++------
src/etc/man/cargo-test.1 | 26 +++++++++++------
tests/testsuite/cross_compile.rs | 2 +-
tests/testsuite/list_availables.rs | 24 ++++++++--------
47 files changed, 704 insertions(+), 363 deletions(-)
diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs
index 506ed08d7a5..52c95545995 100644
--- a/src/cargo/util/command_prelude.rs
+++ b/src/cargo/util/command_prelude.rs
@@ -670,7 +670,7 @@ pub trait ArgMatchesExt {
bail!(
"\"--target\" takes a target architecture as an argument.
-Run `{cmd}` to see possible targets."
+Run `{cmd}` to see possible targets, or specify `host` for the host architecture."
);
}
Ok(self._values_of("target"))
@@ -1258,7 +1258,9 @@ fn get_target_triples() -> Vec {
}
// Allow tab-completion for `host` as the desired target.
- candidates.push(clap_complete::CompletionCandidate::new("host"));
+ 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..44748e3cd5a 100644
--- a/src/doc/man/generated_txt/cargo-bench.txt
+++ b/src/doc/man/generated_txt/cargo-bench.txt
@@ -220,18 +220,30 @@ 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 (may be specified multiple times)
+ The default is the host architecture. The general format of the
+ triple is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt
index cb13663834c..dc632cffdf3 100644
--- a/src/doc/man/generated_txt/cargo-build.txt
+++ b/src/doc/man/generated_txt/cargo-build.txt
@@ -137,18 +137,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt
index 7df6e62935e..845052a8c24 100644
--- a/src/doc/man/generated_txt/cargo-check.txt
+++ b/src/doc/man/generated_txt/cargo-check.txt
@@ -134,18 +134,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-clean.txt b/src/doc/man/generated_txt/cargo-clean.txt
index 2325c090c14..8cdd693adf5 100644
--- a/src/doc/man/generated_txt/cargo-clean.txt
+++ b/src/doc/man/generated_txt/cargo-clean.txt
@@ -45,18 +45,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-doc.txt b/src/doc/man/generated_txt/cargo-doc.txt
index 071663129c5..865411bc695 100644
--- a/src/doc/man/generated_txt/cargo-doc.txt
+++ b/src/doc/man/generated_txt/cargo-doc.txt
@@ -112,18 +112,30 @@ 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 (may be specified multiple times)
+ The default is the host architecture. The general format of the
+ triple is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-fetch.txt b/src/doc/man/generated_txt/cargo-fetch.txt
index 939821dcbeb..a02e3caddd6 100644
--- a/src/doc/man/generated_txt/cargo-fetch.txt
+++ b/src/doc/man/generated_txt/cargo-fetch.txt
@@ -25,18 +25,30 @@ 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 (may be specified multiple times) The
+ default is all architectures. The general format of the triple is
+ ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt
index f15544bfa29..b822349527b 100644
--- a/src/doc/man/generated_txt/cargo-fix.txt
+++ b/src/doc/man/generated_txt/cargo-fix.txt
@@ -208,18 +208,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-install.txt b/src/doc/man/generated_txt/cargo-install.txt
index 7575948a38a..2baebd96a14 100644
--- a/src/doc/man/generated_txt/cargo-install.txt
+++ b/src/doc/man/generated_txt/cargo-install.txt
@@ -186,17 +186,30 @@ OPTIONS
Compilation Options
--target triple
- Install for the given architecture. The default is the host
+ Install for the specified target The default is the host
architecture. The general format of the triple is
- ---. Run rustc --print target-list for
- a list of supported targets.
+ ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-package.txt b/src/doc/man/generated_txt/cargo-package.txt
index 086b68d050d..032cee263c2 100644
--- a/src/doc/man/generated_txt/cargo-package.txt
+++ b/src/doc/man/generated_txt/cargo-package.txt
@@ -188,18 +188,30 @@ 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 (may be specified multiple times)
+ The default is the host architecture. The general format of the
+ triple is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-publish.txt b/src/doc/man/generated_txt/cargo-publish.txt
index 770d913759c..2ca84a8f09b 100644
--- a/src/doc/man/generated_txt/cargo-publish.txt
+++ b/src/doc/man/generated_txt/cargo-publish.txt
@@ -109,18 +109,30 @@ 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 (may be specified multiple times)
+ The default is the host architecture. The general format of the
+ triple is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-run.txt b/src/doc/man/generated_txt/cargo-run.txt
index dd9e8123c0d..e6363d9d583 100644
--- a/src/doc/man/generated_txt/cargo-run.txt
+++ b/src/doc/man/generated_txt/cargo-run.txt
@@ -61,17 +61,30 @@ OPTIONS
Compilation Options
--target triple
- Run 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.
+ Run for the specified target The default is the host architecture.
+ The general format of the triple is
+ ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-rustc.txt b/src/doc/man/generated_txt/cargo-rustc.txt
index 3095cf9189e..700fd3f9855 100644
--- a/src/doc/man/generated_txt/cargo-rustc.txt
+++ b/src/doc/man/generated_txt/cargo-rustc.txt
@@ -128,18 +128,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-rustdoc.txt b/src/doc/man/generated_txt/cargo-rustdoc.txt
index ffe6c8e4d01..b40b05a4e62 100644
--- a/src/doc/man/generated_txt/cargo-rustdoc.txt
+++ b/src/doc/man/generated_txt/cargo-rustdoc.txt
@@ -128,18 +128,30 @@ 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 (may be specified multiple times)
+ The default is the host architecture. The general format of the
+ triple is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/generated_txt/cargo-test.txt b/src/doc/man/generated_txt/cargo-test.txt
index cf22817d0b2..a44a6a0d202 100644
--- a/src/doc/man/generated_txt/cargo-test.txt
+++ b/src/doc/man/generated_txt/cargo-test.txt
@@ -242,18 +242,30 @@ 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 (may be specified multiple times) The
+ default is the host architecture. The general format of the triple
+ is ---.
+
+ You may specify the following kinds of targets:
+
+ o Any supported target in rustc --print target-list (note: you have
+ to install/add the target to use it).
+
+ 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 (further reading here
+ ).
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
+ Note: 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/man/includes/options-target-triple.md b/src/doc/man/includes/options-target-triple.md
index 60c52a15868..336eb21a160 100644
--- a/src/doc/man/includes/options-target-triple.md
+++ b/src/doc/man/includes/options-target-triple.md
@@ -1,16 +1,18 @@
{{#option "`--target` _triple_"}}
-{{actionverb}} for the given architecture.
+{{actionverb}} for the specified target {{~#if multitarget }} (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}}
+`---`.
+
+You may specify the following kinds of targets:
+- Any supported target in `rustc --print target-list` (note: you have to install/add the target to use it).
+- `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 (further reading [here](https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path)).
+
-This may also be specified with the `build.target`
-[config value](../reference/config.html).
+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
-[build cache](../reference/build-cache.html) documentation for more details.
+**Note**: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the [build cache](../reference/build-cache.html) documentation for more details.
{{/option}}
diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md
index 18d95a53dd2..d88e9296324 100644
--- a/src/doc/src/commands/cargo-bench.md
+++ b/src/doc/src/commands/cargo-bench.md
@@ -256,14 +256,16 @@ 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.
-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.
+
Benchmark for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
--profile
name
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md
index 3bf0944798f..0a3752b2a18 100644
--- a/src/doc/src/commands/cargo-build.md
+++ b/src/doc/src/commands/cargo-build.md
@@ -171,14 +171,16 @@ 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.
-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.
+- Build for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md
index 5592895ac5c..f0a280703d4 100644
--- a/src/doc/src/commands/cargo-check.md
+++ b/src/doc/src/commands/cargo-check.md
@@ -167,14 +167,16 @@ 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.
-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.
+- Check for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md
index e18a35a5d9a..6694d7d557e 100644
--- a/src/doc/src/commands/cargo-clean.md
+++ b/src/doc/src/commands/cargo-clean.md
@@ -59,14 +59,16 @@ 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.
-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.
+- Clean for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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..de562a1bf8b 100644
--- a/src/doc/src/commands/cargo-doc.md
+++ b/src/doc/src/commands/cargo-doc.md
@@ -146,14 +146,16 @@ 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.
-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.
+- Document for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md
index 8cdf5cc1311..d76391409b3 100644
--- a/src/doc/src/commands/cargo-fetch.md
+++ b/src/doc/src/commands/cargo-fetch.md
@@ -29,14 +29,16 @@ 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.
-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.
+- Fetch for the specified target (may be specified multiple times) The default is all architectures. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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..0bf919a3301 100644
--- a/src/doc/src/commands/cargo-fix.md
+++ b/src/doc/src/commands/cargo-fix.md
@@ -247,14 +247,16 @@ 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.
-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.
+- Fix for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-install.md b/src/doc/src/commands/cargo-install.md
index daa90fb25e6..27b11e0835b 100644
--- a/src/doc/src/commands/cargo-install.md
+++ b/src/doc/src/commands/cargo-install.md
@@ -212,14 +212,16 @@ 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.
-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.
+- Install for the specified target The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
--target-dir
directory
diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md
index ea9ee490bee..01d26e1e49b 100644
--- a/src/doc/src/commands/cargo-package.md
+++ b/src/doc/src/commands/cargo-package.md
@@ -202,14 +202,16 @@ 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.
-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.
+- Package for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
--target-dir
directory
diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md
index 4e2484afaf1..86b37f1150c 100644
--- a/src/doc/src/commands/cargo-publish.md
+++ b/src/doc/src/commands/cargo-publish.md
@@ -122,14 +122,16 @@ 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.
-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.
+- Publish for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
--target-dir
directory
diff --git a/src/doc/src/commands/cargo-run.md b/src/doc/src/commands/cargo-run.md
index 29d4264f4ef..a9d841618fb 100644
--- a/src/doc/src/commands/cargo-run.md
+++ b/src/doc/src/commands/cargo-run.md
@@ -88,14 +88,16 @@ 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.
-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.
+- Run for the specified target The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md
index 7f6f0a49344..5bdf5c42da5 100644
--- a/src/doc/src/commands/cargo-rustc.md
+++ b/src/doc/src/commands/cargo-rustc.md
@@ -160,14 +160,16 @@ 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.
-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.
+- Build for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md
index 162462594c7..ec1fa06292d 100644
--- a/src/doc/src/commands/cargo-rustdoc.md
+++ b/src/doc/src/commands/cargo-rustdoc.md
@@ -166,14 +166,16 @@ 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.
-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.
+- Document for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md
index bd7d5f5650e..8a7fe3648e7 100644
--- a/src/doc/src/commands/cargo-test.md
+++ b/src/doc/src/commands/cargo-test.md
@@ -278,14 +278,16 @@ 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.
-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.
+- Test for the specified target (may be specified multiple times) The default is the host architecture. The general format of the triple is
+
<arch><sub>-<vendor>-<sys>-<abi>
.
+You may specify the following kinds of targets:
+
+- Any supported target in
rustc --print target-list
(note: you have to install/add the target to use it).
+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 (further reading here).
+
+This may also be specified with the build.target
config value.
+Note: 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.
-r
diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md
index 420ff25248e..7db7ba174bb 100644
--- a/src/doc/src/reference/config.md
+++ b/src/doc/src/reference/config.md
@@ -459,17 +459,16 @@ 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.
+You may specify the following kinds of targets:
+- Any supported target in `rustc --print target-list` (note: you have to install/add the target to use it).
+- `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 (further reading [here](https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path)).
Can be overridden with the `--target` CLI option.
```toml
[build]
-target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
+target = ["host", "x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
```
#### `build.target-dir`
diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1
index f28ddb30742..6cc833890fa 100644
--- a/src/etc/man/cargo-bench.1
+++ b/src/etc/man/cargo-bench.1
@@ -267,16 +267,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-\-profile\fR \fIname\fR
diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1
index cf8ab4e5014..4f235a21e35 100644
--- a/src/etc/man/cargo-build.1
+++ b/src/etc/man/cargo-build.1
@@ -166,16 +166,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1
index 2805c2b5939..cf32e394b78 100644
--- a/src/etc/man/cargo-check.1
+++ b/src/etc/man/cargo-check.1
@@ -162,16 +162,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-clean.1 b/src/etc/man/cargo-clean.1
index c3cb9f2bc54..6c2f8f73db4 100644
--- a/src/etc/man/cargo-clean.1
+++ b/src/etc/man/cargo-clean.1
@@ -57,16 +57,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.SS "Display Options"
.sp
diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1
index b236f12a84d..81fb0953447 100644
--- a/src/etc/man/cargo-doc.1
+++ b/src/etc/man/cargo-doc.1
@@ -135,16 +135,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-fetch.1 b/src/etc/man/cargo-fetch.1
index cb2f7652ac1..14c911665fb 100644
--- a/src/etc/man/cargo-fetch.1
+++ b/src/etc/man/cargo-fetch.1
@@ -25,16 +25,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.SS "Display Options"
.sp
diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1
index f44b28fcca1..bfb1043950e 100644
--- a/src/etc/man/cargo-fix.1
+++ b/src/etc/man/cargo-fix.1
@@ -257,16 +257,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1
index 4b6bc450647..e82ae0b78c2 100644
--- a/src/etc/man/cargo-install.1
+++ b/src/etc/man/cargo-install.1
@@ -242,16 +242,26 @@ 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 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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR
diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1
index 0dca951f851..cac7f2a379f 100644
--- a/src/etc/man/cargo-package.1
+++ b/src/etc/man/cargo-package.1
@@ -239,16 +239,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR
diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1
index 462c94bb699..34dd6364431 100644
--- a/src/etc/man/cargo-publish.1
+++ b/src/etc/man/cargo-publish.1
@@ -132,16 +132,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR
diff --git a/src/etc/man/cargo-run.1 b/src/etc/man/cargo-run.1
index 0e69842149e..cf63052b36b 100644
--- a/src/etc/man/cargo-run.1
+++ b/src/etc/man/cargo-run.1
@@ -72,16 +72,26 @@ 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 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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1
index e33b4faba8a..09fcc70b70e 100644
--- a/src/etc/man/cargo-rustc.1
+++ b/src/etc/man/cargo-rustc.1
@@ -152,16 +152,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1
index 5b85f54572f..ac5e4e7b4df 100644
--- a/src/etc/man/cargo-rustdoc.1
+++ b/src/etc/man/cargo-rustdoc.1
@@ -154,16 +154,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1
index da783c1a370..2926b557f16 100644
--- a/src/etc/man/cargo-test.1
+++ b/src/etc/man/cargo-test.1
@@ -287,16 +287,26 @@ 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 (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 \&.
+You may specify the following kinds of targets:
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'Any supported target in \fBrustc \-\-print target\-list\fR (note: you have to install/add the target to use it).
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+03'\fBhost\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 (further reading \fIhere\fR ).
+.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
-\fIbuild cache\fR documentation for more details.
+\fBNote\fR: Specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the \fIbuild cache\fR documentation for more details.
.RE
.sp
\fB\-r\fR,
diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs
index fd0c46b2ba0..89fe628ca53 100644
--- a/tests/testsuite/cross_compile.rs
+++ b/tests/testsuite/cross_compile.rs
@@ -169,7 +169,7 @@ fn target_host_arg() {
.build();
let target = rustc_host();
- p.cargo("build -v --target host").run();
+ p.cargo(&format!("build -v --target {target}")).run();
assert!(p.target_bin(target, "foo").is_file());
if cross_compile_can_run_on_host() {
diff --git a/tests/testsuite/list_availables.rs b/tests/testsuite/list_availables.rs
index 162eadc52c5..dc9ff9653ce 100644
--- a/tests/testsuite/list_availables.rs
+++ b/tests/testsuite/list_availables.rs
@@ -233,7 +233,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -308,7 +308,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -344,7 +344,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -419,7 +419,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -468,7 +468,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -543,7 +543,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -618,7 +618,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -664,7 +664,7 @@ No binaries available.
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -739,7 +739,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -814,7 +814,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -856,7 +856,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
@@ -880,7 +880,7 @@ Possible packages/workspace members:
.with_target(str![[r#"
[ERROR] "--target" takes a target architecture as an argument.
-Run `[..]` to see possible targets.
+Run `[..]` to see possible targets, or specify `host` for the host architecture.
"#]])
.build(),
From 8f66af71945147c3fbcaf156fe9cc617d16e519b Mon Sep 17 00:00:00 2001
From: zdivelbiss <8019570+zdivelbiss@users.noreply.github.com>
Date: Sat, 16 Aug 2025 17:32:49 -0500
Subject: [PATCH 4/5] simplify tests for `host` target specifier
---
tests/testsuite/cross_compile.rs | 46 ++++++--------------------------
1 file changed, 8 insertions(+), 38 deletions(-)
diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs
index 89fe628ca53..e2f9009f0df 100644
--- a/tests/testsuite/cross_compile.rs
+++ b/tests/testsuite/cross_compile.rs
@@ -154,27 +154,12 @@ fn target_host_arg() {
rustc_host()
),
)
- .file(
- "src/main.rs",
- &format!(
- r#"
- use std::env;
- fn main() {{
- assert_eq!(env::consts::ARCH, "{}");
- }}
- "#,
- cross_compile::native_arch()
- ),
- )
+ .file("src/lib.rs", r#""#)
.build();
- let target = rustc_host();
- p.cargo(&format!("build -v --target {target}")).run();
- assert!(p.target_bin(target, "foo").is_file());
-
- if cross_compile_can_run_on_host() {
- p.process(&p.target_bin(target, "foo")).run();
- }
+ p.cargo("build -v --target host")
+ .with_stderr_contains("[RUNNING] `rustc [..] --target [HOST_TARGET] [..]`")
+ .run();
}
#[cargo_test]
@@ -215,27 +200,12 @@ fn target_host_config() {
rustc_host()
),
)
- .file(
- "src/main.rs",
- &format!(
- r#"
- use std::env;
- fn main() {{
- assert_eq!(env::consts::ARCH, "{}");
- }}
- "#,
- cross_compile::native_arch()
- ),
- )
+ .file("src/lib.rs", r#""#)
.build();
- let target = rustc_host();
- p.cargo("build -v").run();
- assert!(p.target_bin(target, "foo").is_file());
-
- if cross_compile_can_run_on_host() {
- p.process(&p.target_bin(target, "foo")).run();
- }
+ p.cargo("build -v")
+ .with_stderr_contains("[RUNNING] `rustc [..] --target [HOST_TARGET] [..]`")
+ .run();
}
#[cargo_test]
From d5509ebacc1bd4426926cfa7c930c8b271455500 Mon Sep 17 00:00:00 2001
From: zdivelbiss <8019570+zdivelbiss@users.noreply.github.com>
Date: Sun, 17 Aug 2025 14:38:39 -0500
Subject: [PATCH 5/5] amend documentation style for `host` target specifier
We also rebuilt the manual pages, to ensure they're up-to-date with the changes made in the `host` target specifier PR.
---
src/cargo/util/command_prelude.rs | 2 +-
src/doc/man/generated_txt/cargo-bench.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-build.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-check.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-clean.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-doc.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-fetch.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-fix.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-install.txt | 23 +++++++++--------
src/doc/man/generated_txt/cargo-package.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-publish.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-run.txt | 23 +++++++++--------
src/doc/man/generated_txt/cargo-rustc.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-rustdoc.txt | 25 ++++++++++---------
src/doc/man/generated_txt/cargo-test.txt | 25 ++++++++++---------
src/doc/man/includes/options-target-triple.md | 15 +++++------
src/doc/src/commands/cargo-bench.md | 14 ++++++-----
src/doc/src/commands/cargo-build.md | 14 ++++++-----
src/doc/src/commands/cargo-check.md | 14 ++++++-----
src/doc/src/commands/cargo-clean.md | 14 ++++++-----
src/doc/src/commands/cargo-doc.md | 14 ++++++-----
src/doc/src/commands/cargo-fetch.md | 14 ++++++-----
src/doc/src/commands/cargo-fix.md | 14 ++++++-----
src/doc/src/commands/cargo-install.md | 14 ++++++-----
src/doc/src/commands/cargo-package.md | 14 ++++++-----
src/doc/src/commands/cargo-publish.md | 14 ++++++-----
src/doc/src/commands/cargo-run.md | 14 ++++++-----
src/doc/src/commands/cargo-rustc.md | 14 ++++++-----
src/doc/src/commands/cargo-rustdoc.md | 14 ++++++-----
src/doc/src/commands/cargo-test.md | 14 ++++++-----
src/doc/src/reference/config.md | 10 ++++----
src/etc/man/cargo-bench.1 | 14 ++++++-----
src/etc/man/cargo-build.1 | 14 ++++++-----
src/etc/man/cargo-check.1 | 14 ++++++-----
src/etc/man/cargo-clean.1 | 14 ++++++-----
src/etc/man/cargo-doc.1 | 14 ++++++-----
src/etc/man/cargo-fetch.1 | 14 ++++++-----
src/etc/man/cargo-fix.1 | 14 ++++++-----
src/etc/man/cargo-install.1 | 14 ++++++-----
src/etc/man/cargo-package.1 | 14 ++++++-----
src/etc/man/cargo-publish.1 | 14 ++++++-----
src/etc/man/cargo-run.1 | 14 ++++++-----
src/etc/man/cargo-rustc.1 | 14 ++++++-----
src/etc/man/cargo-rustdoc.1 | 14 ++++++-----
src/etc/man/cargo-test.1 | 14 ++++++-----
tests/testsuite/list_availables.rs | 24 +++++++++---------
46 files changed, 430 insertions(+), 359 deletions(-)
diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs
index 52c95545995..e1d2f9a8894 100644
--- a/src/cargo/util/command_prelude.rs
+++ b/src/cargo/util/command_prelude.rs
@@ -670,7 +670,7 @@ pub trait ArgMatchesExt {
bail!(
"\"--target\" takes a target architecture as an argument.
-Run `{cmd}` to see possible targets, or specify `host` for the host architecture."
+Run `{cmd}` to see possible targets."
);
}
Ok(self._values_of("target"))
diff --git a/src/doc/man/generated_txt/cargo-bench.txt b/src/doc/man/generated_txt/cargo-bench.txt
index 44748e3cd5a..09f742fd86b 100644
--- a/src/doc/man/generated_txt/cargo-bench.txt
+++ b/src/doc/man/generated_txt/cargo-bench.txt
@@ -220,30 +220,31 @@ OPTIONS
Compilation Options
--target triple
- Benchmark for the specified target (may be specified multiple times)
- The default is the host architecture. The general format of the
- triple is ---.
+ 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 ---.
- You may specify the following kinds of targets:
+ Possible values:
- o Any supported target in rustc --print target-list (note: you have
- to install/add the target to use it).
+ o Any supported target in rustc --print target-list.
- o host, which will internally be substituted by the host’s
+ 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 (further reading here
- ).
+ 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
.
- Note: Specifying this flag makes Cargo run in a different mode where
- the target artifacts are placed in a separate directory. See the
- build cache
+ 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/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt
index dc632cffdf3..2f8247937ed 100644
--- a/src/doc/man/generated_txt/cargo-build.txt
+++ b/src/doc/man/generated_txt/cargo-build.txt
@@ -137,30 +137,31 @@ OPTIONS
Compilation Options
--target triple
- Build for the specified target (may be specified multiple times) The
- default is the host architecture. The general format of the triple
- is ---.
+ 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 ---.
- You may specify the following kinds of targets:
+ Possible values:
- o Any supported target in rustc --print target-list (note: you have
- to install/add the target to use it).
+ o Any supported target in rustc --print target-list.
- o host, which will internally be substituted by the host’s
+ 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 (further reading here
- ).
+ 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
.
- Note: Specifying this flag makes Cargo run in a different mode where
- the target artifacts are placed in a separate directory. See the
- build cache
+ 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/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt
index 845052a8c24..42be19298c8 100644
--- a/src/doc/man/generated_txt/cargo-check.txt
+++ b/src/doc/man/generated_txt/cargo-check.txt
@@ -134,30 +134,31 @@ OPTIONS
Compilation Options
--target triple
- Check for the specified target (may be specified multiple times) The
- default is the host architecture. The general format of the triple
- is ---.
+ 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