2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for checking exactly how profiles correspond with each unit. For
|
|
|
|
//! example, the `test` profile applying to test targets, but not other
|
|
|
|
//! targets, etc.
|
2018-04-21 20:57:54 +00:00
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
use cargo_test_support::{basic_manifest, project, Project};
|
2018-04-21 20:57:54 +00:00
|
|
|
|
|
|
|
fn all_target_project() -> Project {
|
|
|
|
// This abuses the `codegen-units` setting so that we can verify exactly
|
|
|
|
// which profile is used for each compiler invocation.
|
2018-07-20 11:47:47 +00:00
|
|
|
project()
|
2018-04-21 20:57:54 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
2021-09-24 04:55:42 +00:00
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2018-04-21 20:57:54 +00:00
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
2018-04-21 20:57:54 +00:00
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
[build-dependencies]
|
|
|
|
bdep = { path = "bdep" }
|
2018-04-21 20:57:54 +00:00
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
[profile.dev]
|
|
|
|
codegen-units = 1
|
|
|
|
panic = "abort"
|
|
|
|
[profile.release]
|
|
|
|
codegen-units = 2
|
|
|
|
panic = "abort"
|
|
|
|
[profile.test]
|
|
|
|
codegen-units = 3
|
|
|
|
[profile.bench]
|
|
|
|
codegen-units = 4
|
|
|
|
[profile.dev.build-override]
|
|
|
|
codegen-units = 5
|
|
|
|
[profile.release.build-override]
|
|
|
|
codegen-units = 6
|
|
|
|
"#,
|
2018-04-21 20:57:54 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate bar;")
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/main.rs", "extern crate foo; fn main() {}")
|
|
|
|
.file("examples/ex1.rs", "extern crate foo; fn main() {}")
|
2018-04-21 20:57:54 +00:00
|
|
|
.file("tests/test1.rs", "extern crate foo;")
|
|
|
|
.file("benches/bench1.rs", "extern crate foo;")
|
2018-12-08 11:19:47 +00:00
|
|
|
.file(
|
|
|
|
"build.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate bdep;
|
|
|
|
fn main() {
|
|
|
|
eprintln!("foo custom build PROFILE={} DEBUG={} OPT_LEVEL={}",
|
|
|
|
std::env::var("PROFILE").unwrap(),
|
|
|
|
std::env::var("DEBUG").unwrap(),
|
|
|
|
std::env::var("OPT_LEVEL").unwrap(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
2019-02-03 04:01:23 +00:00
|
|
|
// `bar` package.
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-04-21 20:57:54 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
2019-02-03 04:01:23 +00:00
|
|
|
// `bdep` package.
|
2018-12-08 11:19:47 +00:00
|
|
|
.file(
|
|
|
|
"bdep/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bdep"
|
|
|
|
version = "0.0.1"
|
2018-04-21 20:57:54 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "../bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
2018-04-21 20:57:54 +00:00
|
|
|
.file("bdep/src/lib.rs", "extern crate bar;")
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_build() {
|
|
|
|
let p = all_target_project();
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
// `build`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
|
|
|
// - build_script_build is built without panic because it thinks `build.rs` is a plugin.
|
2022-11-21 20:06:02 +00:00
|
|
|
// - We make sure that the build dependencies bar, bdep, and build.rs
|
2023-05-21 21:25:33 +00:00
|
|
|
// are built with debuginfo=0.
|
2022-11-21 20:06:02 +00:00
|
|
|
p.cargo("build -vv")
|
|
|
|
.with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
2022-11-21 20:06:02 +00:00
|
|
|
"
|
|
|
|
)
|
2023-05-31 19:44:56 +00:00
|
|
|
.with_stderr_does_not_contain("[..] -C debuginfo=0[..]")
|
2022-11-21 20:06:02 +00:00
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_build_release() {
|
|
|
|
let p = all_target_project();
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
// `build --release`
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --release -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] release [optimized] [..]
|
2018-08-28 09:20:03 +00:00
|
|
|
").run();
|
|
|
|
p.cargo("build --release -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] release [optimized] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_build_all_targets() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `build`
|
|
|
|
// NOTES:
|
2018-04-21 20:57:54 +00:00
|
|
|
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
|
|
|
// - build_script_build is built without panic because it thinks
|
|
|
|
// `build.rs` is a plugin.
|
|
|
|
// - Benchmark dependencies are compiled in `dev` mode, which may be
|
2019-02-03 04:01:23 +00:00
|
|
|
// surprising. See issue rust-lang/cargo#4929.
|
2023-05-30 21:47:16 +00:00
|
|
|
// - We make sure that the build dependencies bar, bdep, and build.rs are built with
|
|
|
|
// debuginfo=0; but since we don't pass `-C debuginfo` when it's set to 0, we have to test
|
|
|
|
// explicitly that there's no `-C debuginfo` flag.
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Reason
|
|
|
|
// --- ------ ------- ------
|
2018-10-12 19:55:31 +00:00
|
|
|
// bar lib dev For foo-bin
|
|
|
|
// bar lib dev-panic For tests/benches and bdep
|
|
|
|
// bdep lib dev-panic For foo build.rs
|
|
|
|
// foo custom dev-panic
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2019-02-03 04:01:23 +00:00
|
|
|
// - `foo` target list is:
|
2018-04-21 20:57:54 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
|
|
|
// lib dev+panic build (a normal lib target)
|
|
|
|
// lib dev-panic build (used by tests/benches)
|
2019-06-01 13:07:15 +00:00
|
|
|
// lib dev dev
|
2019-09-27 19:28:44 +00:00
|
|
|
// test dev dev
|
2019-06-01 13:07:15 +00:00
|
|
|
// bench dev dev
|
|
|
|
// bin dev dev
|
2018-04-21 20:57:54 +00:00
|
|
|
// bin dev build
|
|
|
|
// example dev build
|
2022-11-21 20:06:02 +00:00
|
|
|
p.cargo("build --all-targets -vv")
|
|
|
|
.with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]`
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
2022-11-21 20:06:02 +00:00
|
|
|
"
|
|
|
|
)
|
2023-05-31 19:44:56 +00:00
|
|
|
.with_stderr_does_not_contain("[..] -C debuginfo=0[..]")
|
2022-11-21 20:06:02 +00:00
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_build_all_targets_release() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `build --all-targets --release`
|
|
|
|
// NOTES:
|
2018-04-21 20:57:54 +00:00
|
|
|
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
2019-02-03 04:01:23 +00:00
|
|
|
// - bar compiled twice. It tries with and without panic, but the "is a
|
2018-04-21 20:57:54 +00:00
|
|
|
// plugin" logic is forcing it to be cleared.
|
|
|
|
// - build_script_build is built without panic because it thinks
|
|
|
|
// `build.rs` is a plugin.
|
2019-02-03 04:01:23 +00:00
|
|
|
// - build_script_build is being run two times. Once for the `dev` and
|
2018-04-21 20:57:54 +00:00
|
|
|
// `test` targets, once for the `bench` targets.
|
|
|
|
// TODO: "PROFILE" says debug both times, though!
|
|
|
|
//
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Reason
|
|
|
|
// --- ------ ------- ------
|
2018-10-12 19:55:31 +00:00
|
|
|
// bar lib release For foo-bin
|
|
|
|
// bar lib release-panic For tests/benches and bdep
|
|
|
|
// bdep lib release-panic For foo build.rs
|
|
|
|
// foo custom release-panic
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2019-02-03 04:01:23 +00:00
|
|
|
// - `foo` target list is:
|
2018-04-21 20:57:54 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
|
|
|
// lib release+panic build (a normal lib target)
|
|
|
|
// lib release-panic build (used by tests/benches)
|
2019-06-01 13:07:15 +00:00
|
|
|
// lib release test (bench/test de-duped)
|
|
|
|
// test release test
|
|
|
|
// bench release test
|
|
|
|
// bin release test (bench/test de-duped)
|
2018-04-21 20:57:54 +00:00
|
|
|
// bin release build
|
|
|
|
// example release build
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --all-targets --release -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]`
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
|
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] release [optimized] [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build --all-targets --release -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] release [optimized] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_test() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `test`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Reason
|
|
|
|
// --- ------ ------- ------
|
2019-06-01 13:07:15 +00:00
|
|
|
// bar lib test For foo-bin
|
|
|
|
// bar lib test-panic For tests/benches and bdep
|
|
|
|
// bdep lib test-panic For foo build.rs
|
|
|
|
// foo custom test-panic
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2019-02-03 04:01:23 +00:00
|
|
|
// - `foo` target list is:
|
2018-04-21 20:57:54 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
2019-06-01 13:07:15 +00:00
|
|
|
// lib test-panic build (for tests)
|
|
|
|
// lib test build (for bins)
|
2018-04-21 20:57:54 +00:00
|
|
|
// lib test test
|
|
|
|
// test test test
|
2019-06-01 13:07:15 +00:00
|
|
|
// example test-panic build
|
2018-04-21 20:57:54 +00:00
|
|
|
// bin test test
|
2019-06-01 13:07:15 +00:00
|
|
|
// bin test build
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("test -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2019-06-01 13:07:15 +00:00
|
|
|
[FINISHED] test [unoptimized + debuginfo] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/test1-[..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[DOCTEST] foo
|
2023-08-15 11:44:08 +00:00
|
|
|
[RUNNING] `[..] rustdoc [..]--test [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("test -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
2019-06-07 18:09:47 +00:00
|
|
|
[FINISHED] test [unoptimized + debuginfo] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/test1-[..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[DOCTEST] foo
|
2023-08-15 11:44:08 +00:00
|
|
|
[RUNNING] `[..] rustdoc [..]--test [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_test_release() {
|
|
|
|
let p = all_target_project();
|
2019-09-27 19:28:44 +00:00
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
// `test --release`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Reason
|
|
|
|
// --- ------ ------- ------
|
2018-10-12 19:55:31 +00:00
|
|
|
// bar lib release For foo-bin
|
|
|
|
// bar lib release-panic For tests/benches and bdep
|
|
|
|
// bdep lib release-panic For foo build.rs
|
|
|
|
// foo custom release-panic
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2019-02-03 04:01:23 +00:00
|
|
|
// - `foo` target list is:
|
2018-04-21 20:57:54 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
2018-05-10 21:25:17 +00:00
|
|
|
// lib release-panic build (for tests)
|
|
|
|
// lib release build (for bins)
|
2019-06-01 13:07:15 +00:00
|
|
|
// lib release test
|
|
|
|
// test release test
|
2018-04-21 20:57:54 +00:00
|
|
|
// example release-panic build
|
2019-06-01 13:07:15 +00:00
|
|
|
// bin release test
|
2018-05-10 21:25:17 +00:00
|
|
|
// bin release build
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("test --release -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C opt-level=3[..]-C codegen-units=2[..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] release [optimized] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/test1-[..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[DOCTEST] foo
|
2023-08-15 11:44:08 +00:00
|
|
|
[RUNNING] `[..] rustdoc [..]--test [..]`
|
2021-09-24 04:55:42 +00:00
|
|
|
").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("test --release -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] release [optimized] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..]`
|
|
|
|
[RUNNING] `[..]/deps/test1-[..]`
|
2018-04-21 20:57:54 +00:00
|
|
|
[DOCTEST] foo
|
2023-08-15 11:44:08 +00:00
|
|
|
[RUNNING] `[..] rustdoc [..]--test [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_bench() {
|
|
|
|
let p = all_target_project();
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
// `bench`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Reason
|
|
|
|
// --- ------ ------- ------
|
2019-06-01 13:07:15 +00:00
|
|
|
// bar lib bench For foo-bin
|
|
|
|
// bar lib bench-panic For tests/benches and bdep
|
|
|
|
// bdep lib bench-panic For foo build.rs
|
|
|
|
// foo custom bench-panic
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2019-02-03 04:01:23 +00:00
|
|
|
// - `foo` target list is:
|
2018-04-21 20:57:54 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
2019-06-01 13:07:15 +00:00
|
|
|
// lib bench-panic build (for benches)
|
|
|
|
// lib bench build (for bins)
|
2018-04-22 20:57:38 +00:00
|
|
|
// lib bench test(bench)
|
|
|
|
// bench bench test(bench)
|
|
|
|
// bin bench test(bench)
|
2019-06-01 13:07:15 +00:00
|
|
|
// bin bench build
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("bench -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
|
2019-06-01 13:07:15 +00:00
|
|
|
[FINISHED] bench [optimized] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..] --bench`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..] --bench`
|
|
|
|
[RUNNING] `[..]/deps/bench1-[..] --bench`
|
2021-09-24 04:55:42 +00:00
|
|
|
").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("bench -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
|
|
|
[FRESH] foo [..]
|
2019-06-07 18:09:47 +00:00
|
|
|
[FINISHED] bench [optimized] [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]/deps/foo-[..] --bench`
|
|
|
|
[RUNNING] `[..]/deps/foo-[..] --bench`
|
|
|
|
[RUNNING] `[..]/deps/bench1-[..] --bench`
|
2018-04-21 20:57:54 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_check_all_targets() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `check`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Action Reason
|
|
|
|
// --- ------ ------- ------ ------
|
|
|
|
// bar lib dev* link For bdep
|
|
|
|
// bar lib dev-panic metadata For tests/benches
|
|
|
|
// bar lib dev metadata For lib/bins
|
|
|
|
// bdep lib dev* link For foo build.rs
|
|
|
|
// foo custom dev* link For build.rs
|
|
|
|
//
|
|
|
|
// `*` = wants panic, but it is cleared when args are built.
|
|
|
|
//
|
|
|
|
// - foo target list is:
|
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
|
|
|
// lib dev check
|
|
|
|
// lib dev-panic check (for tests/benches)
|
|
|
|
// lib dev-panic check-test (checking lib as a unittest)
|
|
|
|
// example dev check
|
|
|
|
// test dev-panic check-test
|
|
|
|
// bench dev-panic check-test
|
|
|
|
// bin dev check
|
|
|
|
// bin dev-panic check-test (checking bin as a unittest)
|
|
|
|
//
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("check --all-targets -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep[..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
2018-08-28 09:20:03 +00:00
|
|
|
").run();
|
2018-04-22 16:05:18 +00:00
|
|
|
// Starting with Rust 1.27, rustc emits `rmeta` files for bins, so
|
2019-02-03 04:01:23 +00:00
|
|
|
// everything should be completely fresh. Previously, bins were being
|
2018-04-22 16:05:18 +00:00
|
|
|
// rechecked.
|
2019-02-03 04:01:23 +00:00
|
|
|
// See PR rust-lang/rust#49289 and issue rust-lang/cargo#3624.
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("check --all-targets -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
2018-04-22 16:05:18 +00:00
|
|
|
[FRESH] foo [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_check_all_targets_release() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `check --release`
|
|
|
|
// See issue rust-lang/cargo#5218.
|
2018-04-21 20:57:54 +00:00
|
|
|
// This is a pretty straightforward variant of
|
|
|
|
// `profile_selection_check_all_targets` that uses `release` instead of
|
|
|
|
// `dev` for all targets.
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("check --all-targets --release -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep[..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link [..]-C codegen-units=6 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.
Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.
The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:
* In some cases build scripts and procedural macros can take quite a
long time to run!
* Cargo may not build dependencies more than once if they're shared with
the main build. This only applies to builds without `--target` where
the same crate is used in the final binary as in a build script.
In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:
[profile.release.build-override]
opt-level = 3
or you can configure this via the environment:
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.
At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 19:39:41 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 --test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] release [optimized] [..]
|
2018-08-28 09:20:03 +00:00
|
|
|
").run();
|
2018-04-22 16:05:18 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("check --all-targets --release -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
2018-04-22 16:05:18 +00:00
|
|
|
[FRESH] foo [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] release [optimized] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_check_all_targets_test() {
|
|
|
|
let p = all_target_project();
|
2019-09-27 19:28:44 +00:00
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
// `check --profile=test`
|
2018-04-21 20:57:54 +00:00
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Action Reason
|
|
|
|
// --- ------ ------- ------ ------
|
2019-06-01 13:07:15 +00:00
|
|
|
// bar lib test* link For bdep
|
2022-05-10 21:47:28 +00:00
|
|
|
// bar lib test-panic metadata For tests/benches
|
2019-06-01 13:07:15 +00:00
|
|
|
// bdep lib test* link For foo build.rs
|
|
|
|
// foo custom test* link For build.rs
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
|
|
|
// `*` = wants panic, but it is cleared when args are built.
|
|
|
|
//
|
|
|
|
// - foo target list is:
|
2019-06-01 13:07:15 +00:00
|
|
|
// Target Profile Mode
|
|
|
|
// ------ ------- ----
|
|
|
|
// lib test-panic check-test (for tests/benches)
|
|
|
|
// lib test-panic check-test (checking lib as a unittest)
|
|
|
|
// example test-panic check-test
|
|
|
|
// test test-panic check-test
|
|
|
|
// bench test-panic check-test
|
|
|
|
// bin test-panic check-test
|
2018-04-21 20:57:54 +00:00
|
|
|
//
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("check --all-targets --profile=test -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep[..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2021-09-24 04:55:42 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]
|
2023-05-31 10:09:35 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
|
|
|
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
|
2019-06-01 13:07:15 +00:00
|
|
|
[FINISHED] test [unoptimized + debuginfo] [..]
|
2021-09-24 04:55:42 +00:00
|
|
|
").run();
|
2018-04-22 16:05:18 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("check --all-targets --profile=test -vv")
|
|
|
|
.with_stderr_unordered(
|
2018-04-21 20:57:54 +00:00
|
|
|
"\
|
|
|
|
[FRESH] bar [..]
|
|
|
|
[FRESH] bdep [..]
|
2018-04-22 16:05:18 +00:00
|
|
|
[FRESH] foo [..]
|
2019-06-07 18:09:47 +00:00
|
|
|
[FINISHED] test [unoptimized + debuginfo] [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 20:57:54 +00:00
|
|
|
fn profile_selection_doc() {
|
|
|
|
let p = all_target_project();
|
2019-02-03 04:01:23 +00:00
|
|
|
// `doc`
|
2018-04-21 20:57:54 +00:00
|
|
|
// NOTES:
|
|
|
|
// - Dependency profiles:
|
|
|
|
// Pkg Target Profile Action Reason
|
|
|
|
// --- ------ ------- ------ ------
|
|
|
|
// bar lib dev* link For bdep
|
|
|
|
// bar lib dev metadata For rustdoc
|
|
|
|
// bdep lib dev* link For foo build.rs
|
|
|
|
// foo custom dev* link For build.rs
|
|
|
|
//
|
|
|
|
// `*` = wants panic, but it is cleared when args are built.
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("doc -vv").with_stderr_unordered("\
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bar [..]
|
|
|
|
[DOCUMENTING] bar [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2019-09-12 17:38:10 +00:00
|
|
|
[RUNNING] `rustdoc [..]--crate-name bar bar/src/lib.rs [..]
|
2020-04-01 18:41:27 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] bdep [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[COMPILING] foo [..]
|
2022-10-15 15:02:14 +00:00
|
|
|
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
|
2018-08-02 09:18:48 +00:00
|
|
|
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
|
2018-10-09 20:30:13 +00:00
|
|
|
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
2018-04-21 20:57:54 +00:00
|
|
|
[DOCUMENTING] foo [..]
|
2019-09-12 17:38:10 +00:00
|
|
|
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]
|
2018-04-21 20:57:54 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] [..]
|
2023-10-19 15:40:49 +00:00
|
|
|
[GENERATED] [CWD]/target/doc/foo/index.html
|
2018-08-28 09:20:03 +00:00
|
|
|
").run();
|
2018-04-21 20:57:54 +00:00
|
|
|
}
|