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
+list of supported targets. This flag may be specified multiple times.
This may also be specified with the build.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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 5e03c7c3fb1..d7a18baebb6 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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.
--targettriple
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.targetconfig 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 4f859f16c85..6c83cf79d80 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.
@@ -87,7 +86,6 @@ Each new feature described below should explain how to use it.
* [`doctest-in-workspace`](#doctest-in-workspace) — Fixes workspace-relative paths when running doctests.
* [rustdoc-map](#rustdoc-map) — Provides mappings for documentation to link to external sites like [docs.rs](https://docs.rs/).
* `Cargo.toml` extensions
- * [Profile `strip` option](#profile-strip-option) — Forces the removal of debug information and symbols from executables.
* [Profile `rustflags` option](#profile-rustflags-option) — Passed directly to rustc.
* [per-package-target](#per-package-target) — Sets the `--target` to use for each individual package.
* [artifact dependencies](#artifact-dependencies) - Allow build artifacts to be included into other build artifacts and build them for different targets.
@@ -218,32 +216,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
@@ -438,7 +410,7 @@ like to stabilize it somehow!
[rust-lang/rust#64158]: https://github.com/rust-lang/rust/pull/64158
### keep-going
-* Tracking Issue: [#0](https://github.com/rust-lang/cargo/issues/10496)
+* Tracking Issue: [#10496](https://github.com/rust-lang/cargo/issues/10496)
`cargo build --keep-going` (and similarly for `check`, `test` etc) will build as
many crates in the dependency graph as possible, rather than aborting the build
@@ -1553,6 +1525,12 @@ 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.
+
### crate-type
The `--crate-type` flag for `cargo rustc` has been stabilized in the 1.64
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 b4492dc4c6d..02dba7b26ec 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 6fe4008d23e..d00818c8515 100644
--- a/tests/testsuite/rustc.rs
+++ b/tests/testsuite/rustc.rs
@@ -720,8 +720,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\"")
diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs
index 06feb5056b1..6b5c22fd95c 100644
--- a/tests/testsuite/vendor.rs
+++ b/tests/testsuite/vendor.rs
@@ -69,6 +69,53 @@ directory = "vendor"
.run();
}
+#[cargo_test]
+fn vendor_path_specified() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [dependencies]
+ log = "0.3.5"
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ Package::new("log", "0.3.5").publish();
+
+ let path = if cfg!(windows) {
+ r#"deps\.vendor"#
+ } else {
+ "deps/.vendor"
+ };
+
+ let output = p
+ .cargo("vendor --respect-source-config")
+ .arg(path)
+ .exec_with_output()
+ .unwrap();
+ // Assert against original output to ensure that
+ // path is normalized by `ops::vendor` on Windows.
+ assert_eq!(
+ &String::from_utf8(output.stdout).unwrap(),
+ r#"
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "deps/.vendor"
+"#
+ );
+
+ let lock = p.read_file("deps/.vendor/log/Cargo.toml");
+ assert!(lock.contains("version = \"0.3.5\""));
+}
+
fn add_vendor_config(p: &Project) {
p.change_file(
".cargo/config",
@@ -117,7 +164,7 @@ fn package_exclude() {
.publish();
p.cargo("vendor --respect-source-config").run();
- let csum = dbg!(p.read_file("vendor/bar/.cargo-checksum.json"));
+ let csum = p.read_file("vendor/bar/.cargo-checksum.json");
assert!(csum.contains(".include"));
assert!(!csum.contains(".exclude"));
assert!(!csum.contains(".dotdir/exclude"));