diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 5359ac751e8..cbb479e44f8 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -427,7 +427,6 @@ fn compute_metadata<'a, 'cfg>( // panic=abort and panic=unwind artifacts, additionally with various // settings like debuginfo and whatnot. unit.profile.hash(&mut hasher); - cx.used_in_plugin.contains(unit).hash(&mut hasher); unit.mode.hash(&mut hasher); if let Some(ref args) = bcx.extra_args_for(unit) { args.hash(&mut hasher); diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index a5b6231e86a..df5671403ae 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -94,7 +94,6 @@ pub struct Context<'a, 'cfg: 'a> { pub compiled: HashSet>, pub build_scripts: HashMap, Arc>, pub links: Links<'a>, - pub used_in_plugin: HashSet>, pub jobserver: Client, primary_packages: HashSet<&'a PackageId>, unit_dependencies: HashMap, Vec>>, @@ -127,7 +126,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { build_scripts: HashMap::new(), build_explicit_deps: HashMap::new(), links: Links::new(), - used_in_plugin: HashSet::new(), jobserver, build_script_overridden: HashSet::new(), @@ -334,7 +332,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { &mut self.unit_dependencies, &mut self.package_cache, )?; - self.build_used_in_plugin_map(units)?; let files = CompilationFiles::new( units, host_layout, @@ -371,37 +368,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Ok(()) } - /// Builds up the `used_in_plugin` internal to this context from the list of - /// top-level units. - /// - /// This will recursively walk `units` and all of their dependencies to - /// determine which crate are going to be used in plugins or not. - fn build_used_in_plugin_map(&mut self, units: &[Unit<'a>]) -> CargoResult<()> { - let mut visited = HashSet::new(); - for unit in units { - self.walk_used_in_plugin_map(unit, unit.target.for_host(), &mut visited)?; - } - Ok(()) - } - - fn walk_used_in_plugin_map( - &mut self, - unit: &Unit<'a>, - is_plugin: bool, - visited: &mut HashSet<(Unit<'a>, bool)>, - ) -> CargoResult<()> { - if !visited.insert((*unit, is_plugin)) { - return Ok(()); - } - if is_plugin { - self.used_in_plugin.insert(*unit); - } - for unit in self.dep_targets(unit) { - self.walk_used_in_plugin_map(&unit, is_plugin || unit.target.for_host(), visited)?; - } - Ok(()) - } - pub fn files(&self) -> &CompilationFiles<'a, 'cfg> { self.files.as_ref().unwrap() } diff --git a/src/cargo/core/compiler/context/unit_dependencies.rs b/src/cargo/core/compiler/context/unit_dependencies.rs index c7050e348ec..afc819df21f 100644 --- a/src/cargo/core/compiler/context/unit_dependencies.rs +++ b/src/cargo/core/compiler/context/unit_dependencies.rs @@ -20,7 +20,7 @@ use std::collections::{HashMap, HashSet}; use CargoResult; use core::dependency::Kind as DepKind; -use core::profiles::ProfileFor; +use core::profiles::UnitFor; use core::{Package, Target, PackageId}; use core::package::Downloads; use super::{BuildContext, CompileMode, Kind, Unit}; @@ -59,12 +59,19 @@ pub fn build_unit_dependencies<'a, 'cfg>( // cleared, and avoid building the lib thrice (once with `panic`, once // without, once for --test). In particular, the lib included for // doctests and examples are `Build` mode here. - let profile_for = if unit.mode.is_any_test() || bcx.build_config.test() { - ProfileFor::TestDependency + let unit_for = if unit.mode.is_any_test() || bcx.build_config.test() { + UnitFor::new_test() + } else if unit.target.is_custom_build() { + // This normally doesn't happen, except `clean` aggressively + // generates all units. + UnitFor::new_build() + } else if unit.target.for_host() { + // proc-macro/plugin should never have panic set. + UnitFor::new_compiler() } else { - ProfileFor::Any + UnitFor::new_normal() }; - deps_of(unit, &mut state, profile_for)?; + deps_of(unit, &mut state, unit_for)?; } if state.waiting_on_download.len() > 0 { @@ -84,20 +91,20 @@ pub fn build_unit_dependencies<'a, 'cfg>( fn deps_of<'a, 'cfg, 'tmp>( unit: &Unit<'a>, state: &mut State<'a, 'cfg, 'tmp>, - profile_for: ProfileFor, + unit_for: UnitFor, ) -> CargoResult<()> { - // Currently the `deps` map does not include `profile_for`. This should + // Currently the `deps` map does not include `unit_for`. This should // be safe for now. `TestDependency` only exists to clear the `panic` // flag, and you'll never ask for a `unit` with `panic` set as a // `TestDependency`. `CustomBuild` should also be fine since if the // requested unit's settings are the same as `Any`, `CustomBuild` can't // affect anything else in the hierarchy. if !state.deps.contains_key(unit) { - let unit_deps = compute_deps(unit, state, profile_for)?; + let unit_deps = compute_deps(unit, state, unit_for)?; let to_insert: Vec<_> = unit_deps.iter().map(|&(unit, _)| unit).collect(); state.deps.insert(*unit, to_insert); - for (unit, profile_for) in unit_deps { - deps_of(&unit, state, profile_for)?; + for (unit, unit_for) in unit_deps { + deps_of(&unit, state, unit_for)?; } } Ok(()) @@ -105,13 +112,13 @@ fn deps_of<'a, 'cfg, 'tmp>( /// For a package, return all targets which are registered as dependencies /// for that package. -/// This returns a vec of `(Unit, ProfileFor)` pairs. The `ProfileFor` +/// This returns a vec of `(Unit, UnitFor)` pairs. The `UnitFor` /// is the profile type that should be used for dependencies of the unit. fn compute_deps<'a, 'cfg, 'tmp>( unit: &Unit<'a>, state: &mut State<'a, 'cfg, 'tmp>, - profile_for: ProfileFor, -) -> CargoResult, ProfileFor)>> { + unit_for: UnitFor, +) -> CargoResult, UnitFor)>> { if unit.mode.is_run_custom_build() { return compute_deps_custom_build(unit, state.bcx); } else if unit.mode.is_doc() && !unit.mode.is_any_test() { @@ -173,15 +180,16 @@ fn compute_deps<'a, 'cfg, 'tmp>( None => continue, }; let mode = check_or_build_mode(unit.mode, lib); + let dep_unit_for = unit_for.with_for_host(lib.for_host()); let unit = new_unit( bcx, pkg, lib, - profile_for, + dep_unit_for, unit.kind.for_target(lib), mode, ); - ret.push((unit, profile_for)); + ret.push((unit, dep_unit_for)); } // If this target is a build script, then what we've collected so far is @@ -199,7 +207,7 @@ fn compute_deps<'a, 'cfg, 'tmp>( if unit.target.is_lib() && unit.mode != CompileMode::Doctest { return Ok(ret); } - ret.extend(maybe_lib(unit, bcx, profile_for)); + ret.extend(maybe_lib(unit, bcx, unit_for)); // If any integration tests/benches are being run, make sure that // binaries are built as well. @@ -225,11 +233,11 @@ fn compute_deps<'a, 'cfg, 'tmp>( bcx, unit.pkg, t, - ProfileFor::Any, + UnitFor::new_normal(), unit.kind.for_target(t), CompileMode::Build, ), - ProfileFor::Any, + UnitFor::new_normal(), ) }), ); @@ -245,7 +253,7 @@ fn compute_deps<'a, 'cfg, 'tmp>( fn compute_deps_custom_build<'a, 'cfg>( unit: &Unit<'a>, bcx: &BuildContext<'a, 'cfg>, -) -> CargoResult, ProfileFor)>> { +) -> CargoResult, UnitFor)>> { // When not overridden, then the dependencies to run a build script are: // // 1. Compiling the build script itself @@ -259,20 +267,20 @@ fn compute_deps_custom_build<'a, 'cfg>( bcx, unit.pkg, unit.target, - ProfileFor::CustomBuild, + UnitFor::new_build(), Kind::Host, // build scripts always compiled for the host CompileMode::Build, ); // All dependencies of this unit should use profiles for custom // builds. - Ok(vec![(unit, ProfileFor::CustomBuild)]) + Ok(vec![(unit, UnitFor::new_build())]) } /// Returns the dependencies necessary to document a package fn compute_deps_doc<'a, 'cfg, 'tmp>( unit: &Unit<'a>, state: &mut State<'a, 'cfg, 'tmp>, -) -> CargoResult, ProfileFor)>> { +) -> CargoResult, UnitFor)>> { let bcx = state.bcx; let deps = bcx.resolve .deps(unit.pkg.package_id()) @@ -299,26 +307,27 @@ fn compute_deps_doc<'a, 'cfg, 'tmp>( // rustdoc only needs rmeta files for regular dependencies. // However, for plugins/proc-macros, deps should be built like normal. let mode = check_or_build_mode(unit.mode, lib); + let dep_unit_for = UnitFor::new_normal().with_for_host(lib.for_host()); let lib_unit = new_unit( bcx, dep, lib, - ProfileFor::Any, + dep_unit_for, unit.kind.for_target(lib), mode, ); - ret.push((lib_unit, ProfileFor::Any)); + ret.push((lib_unit, dep_unit_for)); if let CompileMode::Doc { deps: true } = unit.mode { // Document this lib as well. let doc_unit = new_unit( bcx, dep, lib, - ProfileFor::Any, + dep_unit_for, unit.kind.for_target(lib), unit.mode, ); - ret.push((doc_unit, ProfileFor::Any)); + ret.push((doc_unit, dep_unit_for)); } } @@ -327,7 +336,7 @@ fn compute_deps_doc<'a, 'cfg, 'tmp>( // If we document a binary, we need the library available if unit.target.is_bin() { - ret.extend(maybe_lib(unit, bcx, ProfileFor::Any)); + ret.extend(maybe_lib(unit, bcx, UnitFor::new_normal())); } Ok(ret) } @@ -335,19 +344,19 @@ fn compute_deps_doc<'a, 'cfg, 'tmp>( fn maybe_lib<'a>( unit: &Unit<'a>, bcx: &BuildContext, - profile_for: ProfileFor, -) -> Option<(Unit<'a>, ProfileFor)> { + unit_for: UnitFor, +) -> Option<(Unit<'a>, UnitFor)> { unit.pkg.targets().iter().find(|t| t.linkable()).map(|t| { let mode = check_or_build_mode(unit.mode, t); let unit = new_unit( bcx, unit.pkg, t, - profile_for, + unit_for, unit.kind.for_target(t), mode, ); - (unit, profile_for) + (unit, unit_for) }) } @@ -358,7 +367,7 @@ fn maybe_lib<'a>( /// script itself doesn't have any dependencies, so even in that case a unit /// of work is still returned. `None` is only returned if the package has no /// build script. -fn dep_build_script<'a>(unit: &Unit<'a>, bcx: &BuildContext) -> Option<(Unit<'a>, ProfileFor)> { +fn dep_build_script<'a>(unit: &Unit<'a>, bcx: &BuildContext) -> Option<(Unit<'a>, UnitFor)> { unit.pkg .targets() .iter() @@ -374,7 +383,7 @@ fn dep_build_script<'a>(unit: &Unit<'a>, bcx: &BuildContext) -> Option<(Unit<'a> kind: unit.kind, mode: CompileMode::RunCustomBuild, }, - ProfileFor::CustomBuild, + UnitFor::new_build(), ) }) } @@ -401,14 +410,14 @@ fn new_unit<'a>( bcx: &BuildContext, pkg: &'a Package, target: &'a Target, - profile_for: ProfileFor, + unit_for: UnitFor, kind: Kind, mode: CompileMode, ) -> Unit<'a> { let profile = bcx.profiles.get_profile( &pkg.package_id(), bcx.ws.is_member(pkg), - profile_for, + unit_for, mode, bcx.build_config.release, ); diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index eace5217c91..6acb85a79bf 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -466,7 +466,6 @@ fn calculate<'a, 'cfg>( unit.mode, bcx.extra_args_for(unit), cx.incremental_args(unit)?, - cx.used_in_plugin.contains(unit), // used when passing panic=abort )); let fingerprint = Arc::new(Fingerprint { rustc: util::hash_u64(&bcx.rustc.verbose_version), diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 1b31e736433..474094468dd 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -765,20 +765,8 @@ fn build_base_args<'a, 'cfg>( cmd.arg("-C").arg(&format!("opt-level={}", opt_level)); } - // If a panic mode was configured *and* we're not ever going to be used in a - // plugin, then we can compile with that panic mode. - // - // If we're used in a plugin then we'll eventually be linked to libsyntax - // most likely which isn't compiled with a custom panic mode, so we'll just - // get an error if we actually compile with that. This fixes `panic=abort` - // crates which have plugin dependencies, but unfortunately means that - // dependencies shared between the main application and plugins must be - // compiled without `panic=abort`. This isn't so bad, though, as the main - // application will still be compiled with `panic=abort`. if let Some(panic) = panic.as_ref() { - if !cx.used_in_plugin.contains(unit) { - cmd.arg("-C").arg(format!("panic={}", panic)); - } + cmd.arg("-C").arg(format!("panic={}", panic)); } // Disable LTO for host builds as prefer_dynamic and it are mutually diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index 2a822022af4..6120007c560 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -69,7 +69,7 @@ impl Profiles { &self, pkg_id: &PackageId, is_member: bool, - profile_for: ProfileFor, + unit_for: UnitFor, mode: CompileMode, release: bool, ) -> Profile { @@ -98,10 +98,10 @@ impl Profiles { CompileMode::Bench => &self.bench, CompileMode::Doc { .. } => &self.doc, }; - let mut profile = maker.get_profile(Some(pkg_id), is_member, profile_for); + let mut profile = maker.get_profile(Some(pkg_id), is_member, unit_for); // `panic` should not be set for tests/benches, or any of their // dependencies. - if profile_for == ProfileFor::TestDependency || mode.is_any_test() { + if !unit_for.is_panic_ok() || mode.is_any_test() { profile.panic = None; } profile @@ -124,9 +124,9 @@ impl Profiles { /// select for the package that was actually built. pub fn base_profile(&self, release: bool) -> Profile { if release { - self.release.get_profile(None, true, ProfileFor::Any) + self.release.get_profile(None, true, UnitFor::new_normal()) } else { - self.dev.get_profile(None, true, ProfileFor::Any) + self.dev.get_profile(None, true, UnitFor::new_normal()) } } @@ -166,14 +166,14 @@ impl ProfileMaker { &self, pkg_id: Option<&PackageId>, is_member: bool, - profile_for: ProfileFor, + unit_for: UnitFor, ) -> Profile { let mut profile = self.default; if let Some(ref toml) = self.toml { - merge_toml(pkg_id, is_member, profile_for, &mut profile, toml); + merge_toml(pkg_id, is_member, unit_for, &mut profile, toml); } if let Some(ref toml) = self.config { - merge_toml(pkg_id, is_member, profile_for, &mut profile, toml); + merge_toml(pkg_id, is_member, unit_for, &mut profile, toml); } profile } @@ -293,12 +293,12 @@ impl ProfileMaker { fn merge_toml( pkg_id: Option<&PackageId>, is_member: bool, - profile_for: ProfileFor, + unit_for: UnitFor, profile: &mut Profile, toml: &TomlProfile, ) { merge_profile(profile, toml); - if profile_for == ProfileFor::CustomBuild { + if unit_for.is_custom_build() { if let Some(ref build_override) = toml.build_override { merge_profile(profile, build_override); } @@ -532,25 +532,82 @@ pub enum Lto { Named(InternedString), } -/// A flag used in `Unit` to indicate the purpose for the target. +/// Flags used in creating `Unit`s to indicate the purpose for the target, and +/// to ensure the target's dependencies have the correct settings. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] -pub enum ProfileFor { - /// A general-purpose target. - Any, +pub struct UnitFor { /// A target for `build.rs` or any of its dependencies. This enables /// `build-override` profiles for these targets. - CustomBuild, - /// A target that is a dependency of a test or benchmark. Currently this - /// enforces that the `panic` setting is not set. - TestDependency, + custom_build: bool, + /// This is true if it is *allowed* to set the `panic` flag. Currently + /// this is false for test/bench targets and all their dependencies, and + /// "for_host" units such as proc-macro and custom build scripts and their + /// dependencies. + panic_ok: bool, } -impl ProfileFor { - pub fn all_values() -> &'static [ProfileFor] { - static ALL: [ProfileFor; 3] = [ - ProfileFor::Any, - ProfileFor::CustomBuild, - ProfileFor::TestDependency, +impl UnitFor { + /// A unit for a normal target/dependency (i.e. not custom build, + /// proc-macro/plugin, or test/bench). + pub fn new_normal() -> UnitFor { + UnitFor { + custom_build: false, + panic_ok: true, + } + } + + /// A unit for a custom build script or its dependencies. + pub fn new_build() -> UnitFor { + UnitFor { + custom_build: true, + panic_ok: false, + } + } + + /// A unit for a proc-macro or compiler plugin or their dependencies. + pub fn new_compiler() -> UnitFor { + UnitFor { + custom_build: false, + panic_ok: false, + } + } + + /// A unit for a test/bench target or their dependencies. + pub fn new_test() -> UnitFor { + UnitFor { + custom_build: false, + panic_ok: false, + } + } + + /// Create a variant based on `for_host` setting. + /// + /// When `for_host` is true, this clears `panic_ok` in a sticky fashion so + /// that all its dependencies also have `panic_ok=false`. + pub fn with_for_host(self, for_host: bool) -> UnitFor { + UnitFor { + custom_build: self.custom_build, + panic_ok: self.panic_ok && !for_host + } + } + + /// Returns true if this unit is for a custom build script or one of its + /// dependencies. + pub fn is_custom_build(&self) -> bool { + self.custom_build + } + + /// Returns true if this unit is allowed to set the `panic` compiler flag. + pub fn is_panic_ok(&self) -> bool { + self.panic_ok + } + + /// All possible values, used by `clean`. + pub fn all_values() -> &'static [UnitFor] { + static ALL: [UnitFor; 3] = [ + UnitFor { custom_build: false, panic_ok: true }, + UnitFor { custom_build: true, panic_ok: false }, + UnitFor { custom_build: false, panic_ok: false }, ]; &ALL } diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 1fe35aa84db..10308cd8920 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -3,7 +3,7 @@ use std::fs; use std::path::Path; use core::compiler::{BuildConfig, BuildContext, CompileMode, Context, Kind, Unit}; -use core::profiles::ProfileFor; +use core::profiles::UnitFor; use core::Workspace; use ops; use util::errors::{CargoResult, CargoResultExt}; @@ -58,12 +58,12 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { for target in pkg.targets() { for kind in [Kind::Host, Kind::Target].iter() { for mode in CompileMode::all_modes() { - for profile_for in ProfileFor::all_values() { + for unit_for in UnitFor::all_values() { let profile = if mode.is_run_custom_build() { profiles.get_profile_run_custom_build(&profiles.get_profile( pkg.package_id(), ws.is_member(pkg), - *profile_for, + *unit_for, CompileMode::Build, opts.release, )) @@ -71,7 +71,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { profiles.get_profile( pkg.package_id(), ws.is_member(pkg), - *profile_for, + *unit_for, *mode, opts.release, ) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 0f9264e990e..56293249f57 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use core::compiler::{BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor}; use core::compiler::{CompileMode, Kind, Unit}; -use core::profiles::{ProfileFor, Profiles}; +use core::profiles::{UnitFor, Profiles}; use core::resolver::{Method, Resolve}; use core::{Package, Source, Target}; use core::{PackageId, PackageIdSpec, TargetKind, Workspace}; @@ -478,11 +478,11 @@ fn generate_targets<'a>( ) -> CargoResult>> { // Helper for creating a Unit struct. let new_unit = |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| { - let profile_for = if build_config.mode.is_any_test() { - // NOTE: The ProfileFor here is subtle. If you have a profile + let unit_for = if build_config.mode.is_any_test() { + // NOTE: The UnitFor here is subtle. If you have a profile // with `panic` set, the `panic` flag is cleared for - // tests/benchmarks and their dependencies. If we left this - // as an "Any" profile, then the lib would get compiled three + // tests/benchmarks and their dependencies. If this + // was `normal`, then the lib would get compiled three // times (once with panic, once without, and once with // --test). // @@ -497,10 +497,15 @@ fn generate_targets<'a>( // // Forcing the lib to be compiled three times during `cargo // test` is probably also not desirable. - ProfileFor::TestDependency + UnitFor::new_test() + } else if target.for_host() { + // proc-macro/plugin should not have `panic` set. + UnitFor::new_compiler() } else { - ProfileFor::Any + UnitFor::new_normal() }; + // Custom build units are added in `build_unit_dependencies`. + assert!(!target.is_custom_build()); let target_mode = match target_mode { CompileMode::Test => { if target.is_example() && !filter.is_specific() && !target.tested() { @@ -527,7 +532,7 @@ fn generate_targets<'a>( let profile = profiles.get_profile( pkg.package_id(), ws.is_member(pkg), - profile_for, + unit_for, target_mode, build_config.release, ); diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index fcac16a0ba2..00c50e69053 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1029,3 +1029,151 @@ fn reuse_workspace_lib() { ", ).run(); } + +#[test] +fn reuse_shared_build_dep() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + shared = {path = "shared"} + + [workspace] + members = ["shared", "bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("shared/Cargo.toml", &basic_manifest("shared", "0.0.1")) + .file("shared/src/lib.rs", "") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.0.1" + + [build-dependencies] + shared = { path = "../shared" } + "#, + ) + .file("bar/src/lib.rs", "") + .file("bar/build.rs", "fn main() {}") + .build(); + + p.cargo("build --all").run(); + // This should not recompile! + p.cargo("build -p foo -v") + .with_stderr( + "\ +[FRESH] shared [..] +[FRESH] foo [..] +[FINISHED] [..] +", + ) + .run(); +} + +#[test] +fn reuse_panic_build_dep_test() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [build-dependencies] + bar = { path = "bar" } + + [dev-dependencies] + bar = { path = "bar" } + + [profile.dev] + panic = "abort" + "#, + ) + .file("src/lib.rs", "") + .file("build.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + .file("bar/src/lib.rs", "") + .build(); + + // Check that `bar` is not built twice. It is only needed once (without `panic`). + p.cargo("test --lib --no-run -v") + .with_stderr( + "\ +[COMPILING] bar [..] +[RUNNING] `rustc --crate-name bar [..] +[COMPILING] foo [..] +[RUNNING] `rustc --crate-name build_script_build [..] +[RUNNING] [..]build-script-build` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--test[..] +[FINISHED] [..] +", + ) + .run(); +} + +#[test] +fn reuse_panic_pm() { + // foo(panic) -> bar(panic) + // somepm(nopanic) -> bar(nopanic) + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + bar = { path = "bar" } + somepm = { path = "somepm" } + + [profile.dev] + panic = "abort" + "#, + ) + .file("src/lib.rs", "extern crate bar;") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + .file("bar/src/lib.rs", "") + .file( + "somepm/Cargo.toml", + r#" + [package] + name = "somepm" + version = "0.0.1" + + [lib] + proc-macro = true + + [dependencies] + bar = { path = "../bar" } + "#, + ) + .file("somepm/src/lib.rs", "extern crate bar;") + .build(); + + // bar is built once without panic (for proc-macro) and once with (for the + // normal dependency). + p.cargo("build -v") + .with_stderr_unordered( + "\ +[COMPILING] bar [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 [..] +[COMPILING] somepm [..] +[RUNNING] `rustc --crate-name somepm [..] +[COMPILING] foo [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C panic=abort[..] +[FINISHED] [..] +", + ) + .run(); +} diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 8fd5a194612..a62a2da8786 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -73,19 +73,19 @@ fn profile_selection_build() { // Build default targets. // NOTES: // - bdep `panic` is not set because it thinks `build.rs` is a plugin. - // - bar `panic` is not set because it is shared with `bdep`. // - build_script_build is built without panic because it thinks `build.rs` is a plugin. p.cargo("build -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [FINISHED] dev [unoptimized + debuginfo] [..] ").run(); p.cargo("build -vv") @@ -106,15 +106,16 @@ fn profile_selection_build_release() { // Build default targets, release. p.cargo("build --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [FINISHED] release [optimized] [..] ").run(); p.cargo("build --release -vv") @@ -134,8 +135,6 @@ fn profile_selection_build_all_targets() { // Build all explicit targets. // NOTES // - bdep `panic` is not set because it thinks `build.rs` is a plugin. - // - bar compiled twice. It tries with and without panic, but the "is a - // plugin" logic is forcing it to be cleared. // - build_script_build is built without panic because it thinks // `build.rs` is a plugin. // - build_script_build is being run two times. Once for the `dev` and @@ -147,12 +146,10 @@ fn profile_selection_build_all_targets() { // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib dev* For bdep and foo - // bar lib dev-panic For tests/benches - // bdep lib dev* For foo build.rs - // foo custom dev* - // - // `*` = wants panic, but it is cleared when args are built. + // 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 // // - foo target list is: // Target Profile Mode @@ -169,26 +166,26 @@ fn profile_selection_build_all_targets() { // example dev build p.cargo("build --all-targets -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=false OPT_LEVEL=3 foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]` -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]` +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]` [FINISHED] dev [unoptimized + debuginfo] [..] ").run(); p.cargo("build -vv") @@ -219,13 +216,10 @@ fn profile_selection_build_all_targets_release() { // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib release* For bdep and foo - // bar lib release-panic For tests/benches - // bdep lib release* For foo build.rs - // foo custom release* - // - // `*` = wants panic, but it is cleared when args are built. - // + // 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 // // - foo target list is: // Target Profile Mode @@ -240,22 +234,22 @@ fn profile_selection_build_all_targets_release() { // example release build p.cargo("build --all-targets --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]` -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]` +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]` +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]` [FINISHED] release [optimized] [..] ").run(); p.cargo("build --all-targets --release -vv") @@ -277,12 +271,10 @@ fn profile_selection_test() { // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib dev* For bdep and foo - // bar lib dev-panic For tests/benches - // bdep lib dev* For foo build.rs - // foo custom dev* - // - // `*` = wants panic, but it is cleared when args are built. + // 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 // // - foo target list is: // Target Profile Mode @@ -297,21 +289,21 @@ fn profile_selection_test() { // p.cargo("test -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [FINISHED] dev [unoptimized + debuginfo] [..] [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/foo-[..]` @@ -343,12 +335,10 @@ fn profile_selection_test_release() { // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib release* For bdep and foo - // bar lib release-panic For tests/benches - // bdep lib release* For foo build.rs - // foo custom release* - // - // `*` = wants panic, but it is cleared when args are built. + // 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 // // - foo target list is: // Target Profile Mode @@ -363,21 +353,21 @@ fn profile_selection_test_release() { // p.cargo("test --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [FINISHED] release [optimized] [..] [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/foo-[..]` @@ -410,12 +400,10 @@ fn profile_selection_bench() { // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib release* For bdep and foo - // bar lib release-panic For tests/benches - // bdep lib release* For foo build.rs - // foo custom release* - // - // `*` = wants panic, but it is cleared when args are built. + // 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 // // - foo target list is: // Target Profile Mode @@ -429,20 +417,20 @@ fn profile_selection_bench() { // p.cargo("bench -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [RUNNING] `[..]target/release/build/foo-[..]/build-script-build` foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [FINISHED] release [optimized] [..] [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/foo-[..] --bench` @@ -497,23 +485,23 @@ fn profile_selection_check_all_targets() { // p.cargo("check --all-targets -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep[..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [FINISHED] dev [unoptimized + debuginfo] [..] ").run(); // Starting with Rust 1.27, rustc emits `rmeta` files for bins, so @@ -547,23 +535,23 @@ fn profile_selection_check_all_targets_release() { // `dev` for all targets. p.cargo("check --all-targets --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [COMPILING] bdep[..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..] [RUNNING] `[..]target/release/build/foo-[..]/build-script-build` foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --crate-type bin --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..] [FINISHED] release [optimized] [..] ").run(); @@ -612,20 +600,20 @@ fn profile_selection_check_all_targets_test() { // p.cargo("check --all-targets --profile=test -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep[..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name test1 tests/test1.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name bench1 benches/bench1.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `rustc --crate-name ex1 examples/ex1.rs --color never --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name bench1 benches/bench1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..] [FINISHED] dev [unoptimized + debuginfo] [..] ").run(); @@ -657,13 +645,13 @@ fn profile_selection_doc() { p.cargo("doc -vv").with_stderr_unordered("\ [COMPILING] bar [..] [DOCUMENTING] bar [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `rustdoc --crate-name bar bar/src/lib.rs [..] -[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] bdep [..] -[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] +[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [DOCUMENTING] foo [..]