diff --git a/src/cargo/core/compiler/compile_kind.rs b/src/cargo/core/compiler/compile_kind.rs index 9f6271ce0a9..7ab19ae1ccf 100644 --- a/src/cargo/core/compiler/compile_kind.rs +++ b/src/cargo/core/compiler/compile_kind.rs @@ -2,7 +2,7 @@ use crate::core::Target; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util::{Config, StableHasher}; -use anyhow::{bail, Context as _}; +use anyhow::Context as _; use serde::Serialize; use std::collections::BTreeSet; use std::fs; @@ -65,9 +65,6 @@ impl CompileKind { }; if !targets.is_empty() { - if targets.len() > 1 && !config.cli_unstable().multitarget { - bail!("specifying multiple `--target` flags requires `-Zmultitarget`") - } return dedup(targets); } diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 90cb1191a47..da5d36eb512 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -722,6 +722,8 @@ const STABILISED_NAMESPACED_FEATURES: &str = "Namespaced features are now always const STABILIZED_TIMINGS: &str = "The -Ztimings option has been stabilized as --timings."; +const STABILISED_MULTITARGET: &str = "Multiple `--target` options are now always available."; + fn deserialize_build_std<'de, D>(deserializer: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, @@ -922,7 +924,7 @@ impl CliUnstable { self.features = Some(feats); } "separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?, - "multitarget" => self.multitarget = parse_empty(k, v)?, + "multitarget" => stabilized_warn(k, "1.64", STABILISED_MULTITARGET), "rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?, "terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?), "sparse-registry" => self.sparse_registry = parse_empty(k, v)?, diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs index d96477a16ed..8e8d400ad2c 100644 --- a/src/cargo/util/config/mod.rs +++ b/src/cargo/util/config/mod.rs @@ -2248,13 +2248,7 @@ impl BuildTargetConfig { }; let values = match &self.inner.val { BuildTargetConfigInner::One(s) => vec![map(s)], - BuildTargetConfigInner::Many(v) => { - if !config.cli_unstable().multitarget { - bail!("specifying an array in `build.target` config value requires `-Zmultitarget`") - } else { - v.iter().map(map).collect() - } - } + BuildTargetConfigInner::Many(v) => v.iter().map(map).collect(), }; Ok(values) } diff --git a/src/doc/man/cargo-bench.md b/src/doc/man/cargo-bench.md index f43e5b24f86..1155ac50b92 100644 --- a/src/doc/man/cargo-bench.md +++ b/src/doc/man/cargo-bench.md @@ -1,6 +1,7 @@ # cargo-bench(1) {{*set actionverb="Benchmark"}} {{*set nouns="benchmarks"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-build.md b/src/doc/man/cargo-build.md index e4dc63f5b28..3b71ae6a317 100644 --- a/src/doc/man/cargo-build.md +++ b/src/doc/man/cargo-build.md @@ -1,5 +1,6 @@ # cargo-build(1) {{*set actionverb="Build"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-check.md b/src/doc/man/cargo-check.md index 208cd273406..44a3d0fdc4d 100644 --- a/src/doc/man/cargo-check.md +++ b/src/doc/man/cargo-check.md @@ -1,5 +1,6 @@ # cargo-check(1) {{*set actionverb="Check"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-clean.md b/src/doc/man/cargo-clean.md index aa631563248..be1fa1fce45 100644 --- a/src/doc/man/cargo-clean.md +++ b/src/doc/man/cargo-clean.md @@ -1,5 +1,6 @@ # cargo-clean(1) {{*set actionverb="Clean"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-doc.md b/src/doc/man/cargo-doc.md index 5e33541395f..f8f517d9ae7 100644 --- a/src/doc/man/cargo-doc.md +++ b/src/doc/man/cargo-doc.md @@ -1,5 +1,6 @@ # cargo-doc(1) {{*set actionverb="Document"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-fetch.md b/src/doc/man/cargo-fetch.md index 601ddb248cd..69ce103cae3 100644 --- a/src/doc/man/cargo-fetch.md +++ b/src/doc/man/cargo-fetch.md @@ -1,6 +1,7 @@ # cargo-fetch(1) {{*set actionverb="Fetch"}} {{*set target-default-to-all-arch=true}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-fix.md b/src/doc/man/cargo-fix.md index 53dfb4cc622..e78ae34fd2e 100644 --- a/src/doc/man/cargo-fix.md +++ b/src/doc/man/cargo-fix.md @@ -1,5 +1,6 @@ # cargo-fix(1) {{*set actionverb="Fix"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-package.md b/src/doc/man/cargo-package.md index 1180df718ef..d7f35c6234c 100644 --- a/src/doc/man/cargo-package.md +++ b/src/doc/man/cargo-package.md @@ -1,6 +1,7 @@ # cargo-package(1) {{*set actionverb="Package"}} {{*set noall=true}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-publish.md b/src/doc/man/cargo-publish.md index 6033b238d4a..560e3c10472 100644 --- a/src/doc/man/cargo-publish.md +++ b/src/doc/man/cargo-publish.md @@ -1,5 +1,6 @@ # cargo-publish(1) {{*set actionverb="Publish"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-rustc.md b/src/doc/man/cargo-rustc.md index 32d3b0e5be7..588c080a9e0 100644 --- a/src/doc/man/cargo-rustc.md +++ b/src/doc/man/cargo-rustc.md @@ -1,5 +1,6 @@ # cargo-rustc(1) {{*set actionverb="Build"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-rustdoc.md b/src/doc/man/cargo-rustdoc.md index 2e4b6e21626..6c38780f324 100644 --- a/src/doc/man/cargo-rustdoc.md +++ b/src/doc/man/cargo-rustdoc.md @@ -1,5 +1,6 @@ # cargo-rustdoc(1) {{*set actionverb="Document"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/cargo-test.md b/src/doc/man/cargo-test.md index b948d91c24c..7419b532397 100644 --- a/src/doc/man/cargo-test.md +++ b/src/doc/man/cargo-test.md @@ -1,6 +1,7 @@ # cargo-test(1) {{*set actionverb="Test"}} {{*set nouns="tests"}} +{{*set multitarget=true}} ## NAME diff --git a/src/doc/man/generated_txt/cargo-bench.txt b/src/doc/man/generated_txt/cargo-bench.txt index 01afc593cac..876442b09d8 100644 --- a/src/doc/man/generated_txt/cargo-bench.txt +++ b/src/doc/man/generated_txt/cargo-bench.txt @@ -208,7 +208,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-build.txt b/src/doc/man/generated_txt/cargo-build.txt index 17802b7fe6d..2fbf8982dc1 100644 --- a/src/doc/man/generated_txt/cargo-build.txt +++ b/src/doc/man/generated_txt/cargo-build.txt @@ -140,7 +140,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-check.txt b/src/doc/man/generated_txt/cargo-check.txt index 2efb2edc87e..4287350809e 100644 --- a/src/doc/man/generated_txt/cargo-check.txt +++ b/src/doc/man/generated_txt/cargo-check.txt @@ -137,7 +137,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-clean.txt b/src/doc/man/generated_txt/cargo-clean.txt index a4888cfdfc4..76bdf3fef06 100644 --- a/src/doc/man/generated_txt/cargo-clean.txt +++ b/src/doc/man/generated_txt/cargo-clean.txt @@ -43,7 +43,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-doc.txt b/src/doc/man/generated_txt/cargo-doc.txt index b57035384c1..8e2c7faae81 100644 --- a/src/doc/man/generated_txt/cargo-doc.txt +++ b/src/doc/man/generated_txt/cargo-doc.txt @@ -115,7 +115,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-fetch.txt b/src/doc/man/generated_txt/cargo-fetch.txt index afd3fc37791..43aa77eae70 100644 --- a/src/doc/man/generated_txt/cargo-fetch.txt +++ b/src/doc/man/generated_txt/cargo-fetch.txt @@ -28,7 +28,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-fix.txt b/src/doc/man/generated_txt/cargo-fix.txt index c5520bb6e34..df48eba7e39 100644 --- a/src/doc/man/generated_txt/cargo-fix.txt +++ b/src/doc/man/generated_txt/cargo-fix.txt @@ -210,7 +210,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-package.txt b/src/doc/man/generated_txt/cargo-package.txt index 89a6b652d93..66c03c2be73 100644 --- a/src/doc/man/generated_txt/cargo-package.txt +++ b/src/doc/man/generated_txt/cargo-package.txt @@ -112,7 +112,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-publish.txt b/src/doc/man/generated_txt/cargo-publish.txt index fc63a9c0a2d..4e53da191f2 100644 --- a/src/doc/man/generated_txt/cargo-publish.txt +++ b/src/doc/man/generated_txt/cargo-publish.txt @@ -79,7 +79,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-rustc.txt b/src/doc/man/generated_txt/cargo-rustc.txt index b0f2ff3f622..e971052d14c 100644 --- a/src/doc/man/generated_txt/cargo-rustc.txt +++ b/src/doc/man/generated_txt/cargo-rustc.txt @@ -131,7 +131,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-rustdoc.txt b/src/doc/man/generated_txt/cargo-rustdoc.txt index b45e229a8a9..6d7e4ebeb89 100644 --- a/src/doc/man/generated_txt/cargo-rustdoc.txt +++ b/src/doc/man/generated_txt/cargo-rustdoc.txt @@ -131,7 +131,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/generated_txt/cargo-test.txt b/src/doc/man/generated_txt/cargo-test.txt index d0fe9df36a0..b63eaa67bbf 100644 --- a/src/doc/man/generated_txt/cargo-test.txt +++ b/src/doc/man/generated_txt/cargo-test.txt @@ -222,7 +222,8 @@ OPTIONS 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. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . diff --git a/src/doc/man/includes/options-target-triple.md b/src/doc/man/includes/options-target-triple.md index 9d91de66cea..bb180f53d7a 100644 --- a/src/doc/man/includes/options-target-triple.md +++ b/src/doc/man/includes/options-target-triple.md @@ -5,6 +5,7 @@ {{~/if}} The general format of the triple is `---`. Run `rustc --print target-list` for a list of supported targets. +{{~#if multitarget }} This flag may be specified multiple times. {{~/if}} This may also be specified with the `build.target` [config value](../reference/config.html). diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md index 69bee8ddb92..edf5f5e2749 100644 --- a/src/doc/src/commands/cargo-bench.md +++ b/src/doc/src/commands/cargo-bench.md @@ -2,6 +2,7 @@ + ## NAME cargo-bench - Execute benchmarks of a package @@ -255,7 +256,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md index 3f473de7a7d..b69012142b9 100644 --- a/src/doc/src/commands/cargo-build.md +++ b/src/doc/src/commands/cargo-build.md @@ -1,6 +1,7 @@ # cargo-build(1) + ## NAME cargo-build - Compile the current package @@ -182,7 +183,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md index 7ea0651901a..16935a756a6 100644 --- a/src/doc/src/commands/cargo-check.md +++ b/src/doc/src/commands/cargo-check.md @@ -1,6 +1,7 @@ # cargo-check(1) + ## NAME cargo-check - Check the current package @@ -177,7 +178,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md index d2e46620471..eee69854dc6 100644 --- a/src/doc/src/commands/cargo-clean.md +++ b/src/doc/src/commands/cargo-clean.md @@ -1,6 +1,7 @@ # cargo-clean(1) + ## NAME cargo-clean - Remove generated artifacts @@ -59,7 +60,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md index b28020c9d74..5bcd73689e7 100644 --- a/src/doc/src/commands/cargo-doc.md +++ b/src/doc/src/commands/cargo-doc.md @@ -1,6 +1,7 @@ # cargo-doc(1) + ## NAME cargo-doc - Build a package's documentation @@ -155,7 +156,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md index 7cdd4543e13..9248fb98aeb 100644 --- a/src/doc/src/commands/cargo-fetch.md +++ b/src/doc/src/commands/cargo-fetch.md @@ -2,6 +2,7 @@ + ## NAME cargo-fetch - Fetch dependencies of a package from the network @@ -34,7 +35,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md index d75d81a44bf..85ca570f8ea 100644 --- a/src/doc/src/commands/cargo-fix.md +++ b/src/doc/src/commands/cargo-fix.md @@ -1,6 +1,7 @@ # cargo-fix(1) + ## NAME cargo-fix - Automatically fix lint warnings reported by rustc @@ -257,7 +258,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md index 568880a0d48..1a9dac0b799 100644 --- a/src/doc/src/commands/cargo-package.md +++ b/src/doc/src/commands/cargo-package.md @@ -2,6 +2,7 @@ + ## NAME cargo-package - Assemble the local package into a distributable tarball @@ -133,7 +134,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-publish.md b/src/doc/src/commands/cargo-publish.md index e4489416e06..af5c12776f9 100644 --- a/src/doc/src/commands/cargo-publish.md +++ b/src/doc/src/commands/cargo-publish.md @@ -1,6 +1,7 @@ # cargo-publish(1) + ## NAME cargo-publish - Upload a package to the registry @@ -99,7 +100,7 @@ format.

--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.

+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 diff --git a/src/doc/src/commands/cargo-rustc.md b/src/doc/src/commands/cargo-rustc.md index 7396d679e2e..f0d85718e1d 100644 --- a/src/doc/src/commands/cargo-rustc.md +++ b/src/doc/src/commands/cargo-rustc.md @@ -1,6 +1,7 @@ # cargo-rustc(1) + ## NAME cargo-rustc - Compile the current package, and pass extra options to the compiler @@ -169,7 +170,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-rustdoc.md b/src/doc/src/commands/cargo-rustdoc.md index 1fe506d108e..8f795050519 100644 --- a/src/doc/src/commands/cargo-rustdoc.md +++ b/src/doc/src/commands/cargo-rustdoc.md @@ -1,6 +1,7 @@ # cargo-rustdoc(1) + ## NAME cargo-rustdoc - Build a package's documentation, using specified custom flags @@ -174,7 +175,7 @@ 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.

+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 diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md index 9ff65a10723..8e7a812e995 100644 --- a/src/doc/src/commands/cargo-test.md +++ b/src/doc/src/commands/cargo-test.md @@ -2,6 +2,7 @@ + ## NAME cargo-test - Execute unit and integration tests of a package @@ -269,7 +270,7 @@ 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.

+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 diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index f4749457e7a..ee4430fb360 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -380,16 +380,25 @@ It affects the filename hash so that artifacts produced by the wrapper are cache Sets the executable to use for `rustdoc`. ##### `build.target` -* Type: string +* Type: string or array of strings * Default: host platform * Environment: `CARGO_BUILD_TARGET` -The default target platform triple to compile to. +The default target platform triples to compile to. -This may also be a relative path to a `.json` target spec file. +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. Can be overridden with the `--target` CLI option. +```toml +[build] +target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] +``` + ##### `build.target-dir` * Type: string (path) * Default: "target" diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 945db70afb6..28e66f7fa67 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -48,7 +48,7 @@ how the feature works: ```toml [unstable] mtime-on-use = true - multitarget = true + build-std = ["core", "alloc"] ``` Each new feature described below should explain how to use it. @@ -76,7 +76,6 @@ Each new feature described below should explain how to use it. * Compile behavior * [mtime-on-use](#mtime-on-use) — Updates the last-modified timestamp on every dependency every time it is used, to provide a mechanism to delete unused artifacts. * [doctest-xcompile](#doctest-xcompile) — Supports running doctests with the `--target` flag. - * [multitarget](#multitarget) — Supports building for multiple targets at the same time. * [build-std](#build-std) — Builds the standard library instead of using pre-built binaries. * [build-std-features](#build-std-features) — Sets features to use with the standard library. * [binary-dep-depinfo](#binary-dep-depinfo) — Causes the dep-info file to track binary dependencies. @@ -218,32 +217,6 @@ information from `.cargo/config.toml`. See the rustc issue for more information. cargo test --target foo -Zdoctest-xcompile ``` -### multitarget -* Tracking Issue: [#8176](https://github.com/rust-lang/cargo/issues/8176) - -This flag allows passing multiple `--target` flags to the `cargo` subcommand -selected. When multiple `--target` flags are passed the selected build targets -will be built for each of the selected architectures. - -For example to compile a library for both 32 and 64-bit: - -``` -cargo build --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu -``` - -or running tests for both targets: - -``` -cargo test --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu -``` - -This can also be specified in `.cargo/config.toml` files. - -```toml -[build] -target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] -``` - #### New `dir-name` attribute Some of the paths generated under `target/` have resulted in a de-facto "build @@ -1569,3 +1542,9 @@ unstable and require `-Zunstable-options`.) The `--config` CLI option has been stabilized in the 1.63 release. See the [config documentation](config.html#command-line-overrides) for more information. + +### multitarget + +The `-Z multitarget` option has been stabilized in the 1.64 release. +See [`build.target`](config.md#buildtarget) for more information about +setting the default target platform triples. diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1 index 002f7562a21..21e07fbbcd6 100644 --- a/src/etc/man/cargo-bench.1 +++ b/src/etc/man/cargo-bench.1 @@ -257,7 +257,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1 index edbc8f90b61..8ddfd548254 100644 --- a/src/etc/man/cargo-build.1 +++ b/src/etc/man/cargo-build.1 @@ -168,7 +168,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1 index a8ecef5f7b1..4e39a23e40d 100644 --- a/src/etc/man/cargo-check.1 +++ b/src/etc/man/cargo-check.1 @@ -164,7 +164,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-clean.1 b/src/etc/man/cargo-clean.1 index b326a7f1ca7..f0181fb5554 100644 --- a/src/etc/man/cargo-clean.1 +++ b/src/etc/man/cargo-clean.1 @@ -53,7 +53,7 @@ Defaults to \fBtarget\fR in the root of the workspace. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1 index 5d3ffc2dd2a..aa06c1033da 100644 --- a/src/etc/man/cargo-doc.1 +++ b/src/etc/man/cargo-doc.1 @@ -137,7 +137,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-fetch.1 b/src/etc/man/cargo-fetch.1 index f69fff8e809..b87bbf9694c 100644 --- a/src/etc/man/cargo-fetch.1 +++ b/src/etc/man/cargo-fetch.1 @@ -27,7 +27,7 @@ you plan to use Cargo without a network with the \fB\-\-offline\fR flag. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1 index 3aaa1f89bce..95a75d6a59a 100644 --- a/src/etc/man/cargo-fix.1 +++ b/src/etc/man/cargo-fix.1 @@ -259,7 +259,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1 index 6e451ada63b..6504d243d1a 100644 --- a/src/etc/man/cargo-package.1 +++ b/src/etc/man/cargo-package.1 @@ -148,7 +148,7 @@ single quotes or double quotes around each pattern. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1 index aa2490ed0eb..6417023d3f6 100644 --- a/src/etc/man/cargo-publish.1 +++ b/src/etc/man/cargo-publish.1 @@ -98,7 +98,7 @@ format. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1 index 07076e24463..e1571c41b85 100644 --- a/src/etc/man/cargo-rustc.1 +++ b/src/etc/man/cargo-rustc.1 @@ -154,7 +154,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1 index 34a37d52f61..ce8fc408af8 100644 --- a/src/etc/man/cargo-rustdoc.1 +++ b/src/etc/man/cargo-rustdoc.1 @@ -156,7 +156,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1 index 00fe416d5a2..662cb1bdb63 100644 --- a/src/etc/man/cargo-test.1 +++ b/src/etc/man/cargo-test.1 @@ -269,7 +269,7 @@ Do not activate the \fBdefault\fR feature of the selected packages. .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. +list of supported targets. This flag may be specified multiple times. .sp This may also be specified with the \fBbuild.target\fR \fIconfig value\fR \&. diff --git a/tests/testsuite/multitarget.rs b/tests/testsuite/multitarget.rs index 496f6c048bd..5f3543f0159 100644 --- a/tests/testsuite/multitarget.rs +++ b/tests/testsuite/multitarget.rs @@ -2,56 +2,6 @@ use cargo_test_support::{basic_manifest, cross_compile, project, rustc_host}; -#[cargo_test] -fn double_target_rejected() { - let p = project() - .file("Cargo.toml", &basic_manifest("foo", "1.0.0")) - .file("src/main.rs", "fn main() {}") - .build(); - - p.cargo("build --target a --target b") - .with_stderr("[ERROR] specifying multiple `--target` flags requires `-Zmultitarget`") - .with_status(101) - .run(); -} - -#[cargo_test] -fn array_of_target_rejected_with_config() { - let p = project() - .file("Cargo.toml", &basic_manifest("foo", "1.0.0")) - .file("src/main.rs", "fn main() {}") - .file( - ".cargo/config.toml", - r#" - [build] - target = ["a", "b"] - "#, - ) - .build(); - - p.cargo("build") - .with_stderr( - "[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`", - ) - .with_status(101) - .run(); - - p.change_file( - ".cargo/config.toml", - r#" - [build] - target = ["a"] - "#, - ); - - p.cargo("build") - .with_stderr( - "[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`", - ) - .with_status(101) - .run(); -} - #[cargo_test] fn simple_build() { if cross_compile::disabled() { @@ -64,12 +14,11 @@ fn simple_build() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("build -Z multitarget") + p.cargo("build") .arg("--target") .arg(&t1) .arg("--target") .arg(&t2) - .masquerade_as_nightly_cargo(&["multitarget"]) .run(); assert!(p.target_bin(t1, "foo").is_file()); @@ -90,8 +39,6 @@ fn simple_build_with_config() { ".cargo/config.toml", &format!( r#" - [unstable] - multitarget = true [build] target = ["{t1}", "{t2}"] "# @@ -99,9 +46,7 @@ fn simple_build_with_config() { ) .build(); - p.cargo("build") - .masquerade_as_nightly_cargo(&["multitarget"]) - .run(); + p.cargo("build").run(); assert!(p.target_bin(t1, "foo").is_file()); assert!(p.target_bin(t2, "foo").is_file()); @@ -119,12 +64,11 @@ fn simple_test() { .file("src/lib.rs", "fn main() {}") .build(); - p.cargo("test -Z multitarget") + p.cargo("test") .arg("--target") .arg(&t1) .arg("--target") .arg(&t2) - .masquerade_as_nightly_cargo(&["multitarget"]) .with_stderr_contains(&format!("[RUNNING] [..]{}[..]", t1)) .with_stderr_contains(&format!("[RUNNING] [..]{}[..]", t2)) .run(); @@ -137,10 +81,9 @@ fn simple_run() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("run -Z multitarget --target a --target b") + p.cargo("run --target a --target b") .with_stderr("[ERROR] only one `--target` argument is supported") .with_status(101) - .masquerade_as_nightly_cargo(&["multitarget"]) .run(); } @@ -156,12 +99,11 @@ fn simple_doc() { .file("src/lib.rs", "//! empty lib") .build(); - p.cargo("doc -Z multitarget") + p.cargo("doc") .arg("--target") .arg(&t1) .arg("--target") .arg(&t2) - .masquerade_as_nightly_cargo(&["multitarget"]) .run(); assert!(p.build_dir().join(&t1).join("doc/foo/index.html").is_file()); @@ -180,12 +122,11 @@ fn simple_check() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("check -Z multitarget") + p.cargo("check") .arg("--target") .arg(&t1) .arg("--target") .arg(&t2) - .masquerade_as_nightly_cargo(&["multitarget"]) .run(); } @@ -200,12 +141,11 @@ fn same_value_twice() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("build -Z multitarget") + p.cargo("build") .arg("--target") .arg(&t) .arg("--target") .arg(&t) - .masquerade_as_nightly_cargo(&["multitarget"]) .run(); assert!(p.target_bin(t, "foo").is_file()); @@ -224,8 +164,6 @@ fn same_value_twice_with_config() { ".cargo/config.toml", &format!( r#" - [unstable] - multitarget = true [build] target = ["{t}", "{t}"] "# @@ -233,9 +171,7 @@ fn same_value_twice_with_config() { ) .build(); - p.cargo("build") - .masquerade_as_nightly_cargo(&["multitarget"]) - .run(); + p.cargo("build").run(); assert!(p.target_bin(t, "foo").is_file()); } @@ -253,8 +189,6 @@ fn works_with_config_in_both_string_or_list() { ".cargo/config.toml", &format!( r#" - [unstable] - multitarget = true [build] target = "{t}" "# @@ -262,9 +196,7 @@ fn works_with_config_in_both_string_or_list() { ) .build(); - p.cargo("build") - .masquerade_as_nightly_cargo(&["multitarget"]) - .run(); + p.cargo("build").run(); assert!(p.target_bin(t, "foo").is_file()); @@ -274,17 +206,13 @@ fn works_with_config_in_both_string_or_list() { ".cargo/config.toml", &format!( r#" - [unstable] - multitarget = true [build] target = ["{t}"] "# ), ); - p.cargo("build") - .masquerade_as_nightly_cargo(&["multitarget"]) - .run(); + p.cargo("build").run(); assert!(p.target_bin(t, "foo").is_file()); } diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index d6d196db47d..31be7fda086 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -743,8 +743,8 @@ fn rustc_with_print_cfg_multiple_targets() { .file("src/main.rs", r#"fn main() {} "#) .build(); - p.cargo("rustc -Z unstable-options -Z multitarget --target x86_64-pc-windows-msvc --target i686-unknown-linux-gnu --print cfg") - .masquerade_as_nightly_cargo(&["print", "multitarget"]) + p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --target i686-unknown-linux-gnu --print cfg") + .masquerade_as_nightly_cargo(&["print"]) .with_stdout_contains("debug_assertions") .with_stdout_contains("target_arch=\"x86_64\"") .with_stdout_contains("target_endian=\"little\"")