diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 01890e54291..d1746217497 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -31,7 +31,7 @@ //! [`CompileMode::RunCustomBuild`]: super::CompileMode //! [instructions]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script -use super::{fingerprint, Context, Job, LinkType, Unit, Work}; +use super::{fingerprint, Context, Job, Unit, Work}; use crate::core::compiler::artifact; use crate::core::compiler::context::Metadata; use crate::core::compiler::job_queue::JobState; @@ -62,7 +62,7 @@ pub struct BuildOutput { /// Names and link kinds of libraries, suitable for the `-l` flag. pub library_links: Vec, /// Linker arguments suitable to be passed to `-C link-arg=` - pub linker_args: Vec<(LinkType, String)>, + pub linker_args: Vec<(LinkArgTarget, String)>, /// Various `--cfg` flags to pass to the compiler. pub cfgs: Vec, /// Various `--check-cfg` flags to pass to the compiler. @@ -146,6 +146,47 @@ pub struct BuildDeps { pub rerun_if_env_changed: Vec, } +/// Represents one of the instructions from `cargo:rustc-link-arg-*` build +/// script instruction family. +/// +/// In other words, indicates targets that custom linker arguments applies to. +/// +/// See the [build script documentation][1] for more. +/// +/// [1]: https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#cargorustc-link-argflag +#[derive(Clone, Hash, Debug, PartialEq, Eq)] +pub enum LinkArgTarget { + /// Represents `cargo:rustc-link-arg=FLAG`. + All, + /// Represents `cargo:rustc-cdylib-link-arg=FLAG`. + Cdylib, + /// Represents `cargo:rustc-link-arg-bins=FLAG`. + Bin, + /// Represents `cargo:rustc-link-arg-bin=BIN=FLAG`. + SingleBin(String), + /// Represents `cargo:rustc-link-arg-tests=FLAG`. + Test, + /// Represents `cargo:rustc-link-arg-benches=FLAG`. + Bench, + /// Represents `cargo:rustc-link-arg-examples=FLAG`. + Example, +} + +impl LinkArgTarget { + /// Checks if this link type applies to a given [`Target`]. + pub fn applies_to(&self, target: &Target) -> bool { + match self { + LinkArgTarget::All => true, + LinkArgTarget::Cdylib => target.is_cdylib(), + LinkArgTarget::Bin => target.is_bin(), + LinkArgTarget::SingleBin(name) => target.is_bin() && target.name() == name, + LinkArgTarget::Test => target.is_test(), + LinkArgTarget::Bench => target.is_bench(), + LinkArgTarget::Example => target.is_exe_example(), + } + } +} + /// Prepares a `Work` that executes the target as a custom build script. pub fn prepare(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { let _p = profile::start(format!( @@ -711,10 +752,10 @@ impl BuildOutput { key, pkg_descr )); } - linker_args.push((LinkType::Cdylib, value)) + linker_args.push((LinkArgTarget::Cdylib, value)) } "rustc-link-arg-bins" => { - check_and_add_target!("bin", Target::is_bin, LinkType::Bin); + check_and_add_target!("bin", Target::is_bin, LinkArgTarget::Bin); } "rustc-link-arg-bin" => { let mut parts = value.splitn(2, '='); @@ -742,19 +783,19 @@ impl BuildOutput { bin_name ); } - linker_args.push((LinkType::SingleBin(bin_name), arg.to_string())); + linker_args.push((LinkArgTarget::SingleBin(bin_name), arg.to_string())); } "rustc-link-arg-tests" => { - check_and_add_target!("test", Target::is_test, LinkType::Test); + check_and_add_target!("test", Target::is_test, LinkArgTarget::Test); } "rustc-link-arg-benches" => { - check_and_add_target!("benchmark", Target::is_bench, LinkType::Bench); + check_and_add_target!("benchmark", Target::is_bench, LinkArgTarget::Bench); } "rustc-link-arg-examples" => { - check_and_add_target!("example", Target::is_example, LinkType::Example); + check_and_add_target!("example", Target::is_example, LinkArgTarget::Example); } "rustc-link-arg" => { - linker_args.push((LinkType::All, value)); + linker_args.push((LinkArgTarget::All, value)); } "rustc-cfg" => cfgs.push(value.to_string()), "rustc-check-cfg" => { diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 55ec17182d1..31e63c226b7 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -76,6 +76,7 @@ pub use self::compilation::{Compilation, Doctest, UnitOutput}; pub use self::compile_kind::{CompileKind, CompileTarget}; pub use self::context::{Context, Metadata}; pub use self::crate_type::CrateType; +pub use self::custom_build::LinkArgTarget; pub use self::custom_build::{BuildOutput, BuildScriptOutputs, BuildScripts}; pub(crate) use self::fingerprint::DirtyReason; pub use self::job_queue::Freshness; @@ -99,44 +100,6 @@ use rustfix::diagnostics::Applicability; const RUSTDOC_CRATE_VERSION_FLAG: &str = "--crate-version"; -// TODO: Rename this to `ExtraLinkArgFor` or else, and move to compiler/custom_build.rs? -/// Represents one of the instruction from `cargo:rustc-link-arg-*` build script -/// instruction family. -/// -/// In other words, indicates targets that custom linker arguments applies to. -#[derive(Clone, Hash, Debug, PartialEq, Eq)] -pub enum LinkType { - /// Represents `cargo:rustc-link-arg=FLAG`. - All, - /// Represents `cargo:rustc-cdylib-link-arg=FLAG`. - Cdylib, - /// Represents `cargo:rustc-link-arg-bins=FLAG`. - Bin, - /// Represents `cargo:rustc-link-arg-bin=BIN=FLAG`. - SingleBin(String), - /// Represents `cargo:rustc-link-arg-tests=FLAG`. - Test, - /// Represents `cargo:rustc-link-arg-benches=FLAG`. - Bench, - /// Represents `cargo:rustc-link-arg-examples=FLAG`. - Example, -} - -impl LinkType { - /// Checks if this link type applies to a given [`Target`]. - pub fn applies_to(&self, target: &Target) -> bool { - match self { - LinkType::All => true, - LinkType::Cdylib => target.is_cdylib(), - LinkType::Bin => target.is_bin(), - LinkType::SingleBin(name) => target.is_bin() && target.name() == name, - LinkType::Test => target.is_test(), - LinkType::Bench => target.is_bench(), - LinkType::Example => target.is_exe_example(), - } - } -} - /// A glorified callback for executing calls to rustc. Rather than calling rustc /// directly, we'll use an `Executor`, giving clients an opportunity to intercept /// the build calls. @@ -286,14 +249,12 @@ fn make_failed_scrape_diagnostic( /// Creates a unit of work invoking `rustc` for building the `unit`. fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc) -> CargoResult { - let mut rustc = prepare_rustc(cx, &unit.target.rustc_crate_types(), unit)?; + let mut rustc = prepare_rustc(cx, unit)?; let build_plan = cx.bcx.build_config.build_plan; let name = unit.pkg.name().to_string(); let buildkey = unit.buildkey(); - add_cap_lints(cx.bcx, unit, &mut rustc); - let outputs = cx.outputs(unit)?; let root = cx.files().out_dir(unit); @@ -319,10 +280,6 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc) -> Car let rustc_dep_info_loc = root.join(dep_info_name); let dep_info_loc = fingerprint::dep_info_loc(cx, unit); - rustc.args(cx.bcx.rustflags_args(unit)); - if cx.bcx.config.cli_unstable().binary_dep_depinfo { - rustc.arg("-Z").arg("binary-dep-depinfo"); - } let mut output_options = OutputOptions::new(cx, unit); let package_id = unit.pkg.package_id(); let target = Target::clone(&unit.target); @@ -544,7 +501,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc) -> Car // clause should have been kept in the `if` block above. For // now, continue allowing it for cdylib only. // See https://github.com/rust-lang/cargo/issues/9562 - if lt.applies_to(target) && (key.0 == current_id || *lt == LinkType::Cdylib) { + if lt.applies_to(target) && (key.0 == current_id || *lt == LinkArgTarget::Cdylib) { rustc.arg("-C").arg(format!("link-arg={}", arg)); } } @@ -705,13 +662,13 @@ where search_path } -// TODO: do we really need this as a separate function? -// Maybe we should reorganize `rustc` fn to make it more traceable and readable. -fn prepare_rustc( - cx: &mut Context<'_, '_>, - crate_types: &[CrateType], - unit: &Unit, -) -> CargoResult { +/// Prepares flags and environments we can compute for a `rustc` invocation +/// before the job queue starts compiling any unit. +/// +/// This builds a static view of the invocation. Flags depending on the +/// completion of other units will be added later in runtime, such as flags +/// from build scripts. +fn prepare_rustc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult { let is_primary = cx.is_primary_package(unit); let is_workspace = cx.bcx.ws.is_member(&unit.pkg); @@ -729,13 +686,23 @@ fn prepare_rustc( } base.inherit_jobserver(&cx.jobserver); - build_base_args(cx, &mut base, unit, crate_types)?; + build_base_args(cx, &mut base, unit)?; build_deps_args(&mut base, cx, unit)?; + add_cap_lints(cx.bcx, unit, &mut base); + base.args(cx.bcx.rustflags_args(unit)); + if cx.bcx.config.cli_unstable().binary_dep_depinfo { + base.arg("-Z").arg("binary-dep-depinfo"); + } Ok(base) } -/// Creates a unit of work invoking `rustdoc` for documenting the `unit`. -fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { +/// Prepares flags and environments we can compute for a `rustdoc` invocation +/// before the job queue starts compiling any unit. +/// +/// This builds a static view of the invocation. Flags depending on the +/// completion of other units will be added later in runtime, such as flags +/// from build scripts. +fn prepare_rustdoc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult { let bcx = cx.bcx; // script_metadata is not needed here, it is only for tests. let mut rustdoc = cx.compilation.rustdoc_process(unit, None)?; @@ -749,12 +716,6 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { rustdoc.arg("--target").arg(target.rustc_target()); } let doc_dir = cx.files().out_dir(unit); - - // Create the documentation directory ahead of time as rustdoc currently has - // a bug where concurrent invocations will race to create this directory if - // it doesn't already exist. - paths::create_dir_all(&doc_dir)?; - rustdoc.arg("-o").arg(&doc_dir); rustdoc.args(&features_args(unit)); rustdoc.args(&check_cfg_args(cx, unit)); @@ -770,10 +731,6 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { let metadata = cx.metadata_for_doc_units[unit]; rustdoc.arg("-C").arg(format!("metadata={}", metadata)); - let scrape_output_path = |unit: &Unit| -> CargoResult { - cx.outputs(unit).map(|outputs| outputs[0].path.clone()) - }; - if unit.mode.is_doc_scrape() { debug_assert!(cx.bcx.scrape_units.contains(unit)); @@ -785,7 +742,7 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { rustdoc .arg("--scrape-examples-output-path") - .arg(scrape_output_path(unit)?); + .arg(scrape_output_path(cx, unit)?); // Only scrape example for items from crates in the workspace, to reduce generated file size for pkg in cx.bcx.ws.members() { @@ -800,21 +757,9 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { } } - let should_include_scrape_units = unit.mode.is_doc() - && cx.bcx.scrape_units.len() > 0 - && cx.bcx.ws.unit_needs_doc_scrape(unit); - let scrape_outputs = if should_include_scrape_units { + if should_include_scrape_units(cx.bcx, unit) { rustdoc.arg("-Zunstable-options"); - Some( - cx.bcx - .scrape_units - .iter() - .map(|unit| Ok((cx.files().metadata(unit), scrape_output_path(unit)?))) - .collect::>>()?, - ) - } else { - None - }; + } build_deps_args(&mut rustdoc, cx, unit)?; rustdoc::add_root_urls(cx, unit, &mut rustdoc)?; @@ -825,6 +770,20 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { append_crate_version_flag(unit, &mut rustdoc); } + Ok(rustdoc) +} + +/// Creates a unit of work invoking `rustdoc` for documenting the `unit`. +fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { + let mut rustdoc = prepare_rustdoc(cx, unit)?; + + let crate_name = unit.target.crate_name(); + let doc_dir = cx.files().out_dir(unit); + // Create the documentation directory ahead of time as rustdoc currently has + // a bug where concurrent invocations will race to create this directory if + // it doesn't already exist. + paths::create_dir_all(&doc_dir)?; + let target_desc = unit.target.description_named(); let name = unit.pkg.name().to_string(); let build_script_outputs = Arc::clone(&cx.build_script_outputs); @@ -833,6 +792,17 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { let target = Target::clone(&unit.target); let mut output_options = OutputOptions::new(cx, unit); let script_metadata = cx.find_build_script_metadata(unit); + let scrape_outputs = if should_include_scrape_units(cx.bcx, unit) { + Some( + cx.bcx + .scrape_units + .iter() + .map(|unit| Ok((cx.files().metadata(unit), scrape_output_path(cx, unit)?))) + .collect::>>()?, + ) + } else { + None + }; let failed_scrape_units = Arc::clone(&cx.failed_scrape_units); let hide_diagnostics_for_scrape_unit = cx.bcx.unit_can_fail_for_docscraping(unit) @@ -977,12 +947,7 @@ fn add_error_format_and_color(cx: &Context<'_, '_>, cmd: &mut ProcessBuilder) { } /// Adds essential rustc flags and environment variables to the command to execute. -fn build_base_args( - cx: &mut Context<'_, '_>, - cmd: &mut ProcessBuilder, - unit: &Unit, - crate_types: &[CrateType], -) -> CargoResult<()> { +fn build_base_args(cx: &Context<'_, '_>, cmd: &mut ProcessBuilder, unit: &Unit) -> CargoResult<()> { assert!(!unit.mode.is_run_custom_build()); let bcx = cx.bcx; @@ -998,7 +963,7 @@ fn build_base_args( ref panic, incremental, strip, - rustflags, + rustflags: profile_rustflags, .. } = unit.profile.clone(); let test = unit.mode.is_any_test(); @@ -1014,7 +979,7 @@ fn build_base_args( let mut contains_dy_lib = false; if !test { - for crate_type in crate_types { + for crate_type in &unit.target.rustc_crate_types() { cmd.arg("--crate-type").arg(crate_type.as_str()); contains_dy_lib |= crate_type == &CrateType::Dylib; } @@ -1047,22 +1012,6 @@ fn build_base_args( cmd.args(<o_args(cx, unit)); - // This is generally just an optimization on build time so if we don't pass - // it then it's ok. The values for the flag (off, packed, unpacked) may be supported - // or not depending on the platform, so availability is checked per-value. - // For example, at the time of writing this code, on Windows the only stable valid - // value for split-debuginfo is "packed", while on Linux "unpacked" is also stable. - if let Some(split) = split_debuginfo { - if cx - .bcx - .target_data - .info(unit.kind) - .supports_debuginfo_split(split) - { - cmd.arg("-C").arg(format!("split-debuginfo={}", split)); - } - } - if let Some(backend) = codegen_backend { cmd.arg("-Z").arg(&format!("codegen-backend={}", backend)); } @@ -1074,13 +1023,27 @@ fn build_base_args( let debuginfo = debuginfo.into_inner(); // Shorten the number of arguments if possible. if debuginfo != TomlDebugInfo::None { - cmd.arg("-C").arg(format!("debuginfo={}", debuginfo)); + cmd.arg("-C").arg(format!("debuginfo={debuginfo}")); + // This is generally just an optimization on build time so if we don't + // pass it then it's ok. The values for the flag (off, packed, unpacked) + // may be supported or not depending on the platform, so availability is + // checked per-value. For example, at the time of writing this code, on + // Windows the only stable valid value for split-debuginfo is "packed", + // while on Linux "unpacked" is also stable. + if let Some(split) = split_debuginfo { + if cx + .bcx + .target_data + .info(unit.kind) + .supports_debuginfo_split(split) + { + cmd.arg("-C").arg(format!("split-debuginfo={split}")); + } + } } cmd.args(unit.pkg.manifest().lint_rustflags()); - if !rustflags.is_empty() { - cmd.args(&rustflags); - } + cmd.args(&profile_rustflags); if let Some(args) = cx.bcx.extra_args_for(unit) { cmd.args(args); } @@ -1279,11 +1242,7 @@ fn lto_args(cx: &Context<'_, '_>, unit: &Unit) -> Vec { /// /// [`-L`]: https://doc.rust-lang.org/nightly/rustc/command-line-arguments.html#-l-add-a-directory-to-the-library-search-path /// [`--extern`]: https://doc.rust-lang.org/nightly/rustc/command-line-arguments.html#--extern-specify-where-an-external-library-is-located -fn build_deps_args( - cmd: &mut ProcessBuilder, - cx: &mut Context<'_, '_>, - unit: &Unit, -) -> CargoResult<()> { +fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> { let bcx = cx.bcx; cmd.arg("-L").arg(&{ let mut deps = OsString::from("dependency="); @@ -1823,3 +1782,14 @@ fn apply_env_config(config: &crate::Config, cmd: &mut ProcessBuilder) -> CargoRe } Ok(()) } + +/// Checks if there are some scrape units waiting to be processed. +fn should_include_scrape_units(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool { + unit.mode.is_doc() && bcx.scrape_units.len() > 0 && bcx.ws.unit_needs_doc_scrape(unit) +} + +/// Gets the file path of function call information output from `rustdoc`. +fn scrape_output_path(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult { + assert!(unit.mode.is_doc() || unit.mode.is_doc_scrape()); + cx.outputs(unit).map(|outputs| outputs[0].path.clone()) +} diff --git a/src/cargo/util/config/target.rs b/src/cargo/util/config/target.rs index a7f2f3ef269..cdafe73dd67 100644 --- a/src/cargo/util/config/target.rs +++ b/src/cargo/util/config/target.rs @@ -1,5 +1,5 @@ use super::{Config, ConfigKey, ConfigRelativePath, OptValue, PathAndArgs, StringList, CV}; -use crate::core::compiler::{BuildOutput, LinkType}; +use crate::core::compiler::{BuildOutput, LinkArgTarget}; use crate::util::CargoResult; use serde::Deserialize; use std::collections::{BTreeMap, HashMap}; @@ -178,27 +178,27 @@ fn parse_links_overrides( .extend(list.iter().map(|v| PathBuf::from(&v.0))); } "rustc-link-arg-cdylib" | "rustc-cdylib-link-arg" => { - let args = extra_link_args(LinkType::Cdylib, key, value)?; + let args = extra_link_args(LinkArgTarget::Cdylib, key, value)?; output.linker_args.extend(args); } "rustc-link-arg-bins" => { - let args = extra_link_args(LinkType::Bin, key, value)?; + let args = extra_link_args(LinkArgTarget::Bin, key, value)?; output.linker_args.extend(args); } "rustc-link-arg" => { - let args = extra_link_args(LinkType::All, key, value)?; + let args = extra_link_args(LinkArgTarget::All, key, value)?; output.linker_args.extend(args); } "rustc-link-arg-tests" => { - let args = extra_link_args(LinkType::Test, key, value)?; + let args = extra_link_args(LinkArgTarget::Test, key, value)?; output.linker_args.extend(args); } "rustc-link-arg-benches" => { - let args = extra_link_args(LinkType::Bench, key, value)?; + let args = extra_link_args(LinkArgTarget::Bench, key, value)?; output.linker_args.extend(args); } "rustc-link-arg-examples" => { - let args = extra_link_args(LinkType::Example, key, value)?; + let args = extra_link_args(LinkArgTarget::Example, key, value)?; output.linker_args.extend(args); } "rustc-cfg" => { @@ -237,10 +237,10 @@ fn parse_links_overrides( } fn extra_link_args<'a>( - link_type: LinkType, + link_type: LinkArgTarget, key: &str, value: &'a CV, -) -> CargoResult + 'a> { +) -> CargoResult + 'a> { let args = value.list(key)?; Ok(args.iter().map(move |v| (link_type.clone(), v.0.clone()))) } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 44a452fd81f..6dbef022e95 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1334,13 +1334,13 @@ fn cargo_default_env_metadata_env_var() { [COMPILING] bar v0.0.1 ([CWD]/bar) [RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \ --emit=[..]link \ - -C prefer-dynamic[..]-C debuginfo=2 \ + -C prefer-dynamic[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ @@ -1362,13 +1362,13 @@ fn cargo_default_env_metadata_env_var() { [COMPILING] bar v0.0.1 ([CWD]/bar) [RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \ --emit=[..]link \ - -C prefer-dynamic[..]-C debuginfo=2 \ + -C prefer-dynamic[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ @@ -2053,7 +2053,7 @@ fn verbose_build() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` @@ -5432,7 +5432,7 @@ fn targets_selected_all() { // Unit tests. .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 --test [..]", + -C debuginfo=2 [..]--test [..]", ) .run(); } @@ -5449,7 +5449,7 @@ fn all_targets_no_lib() { // Unit tests. .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 --test [..]", + -C debuginfo=2 [..]--test [..]", ) .run(); } @@ -5920,7 +5920,7 @@ fn build_lib_only() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 873c838de2e..330bc64a6f4 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -1755,7 +1755,7 @@ fn build_cmd_with_a_build_cmd() { --extern a=[..]liba[..].rlib` [RUNNING] `[..]/foo-[..]/build-script-build` [RUNNING] `rustc --crate-name foo [..]lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L [..]target/debug/deps` diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index cc964455027..1bc0c277db1 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -398,7 +398,7 @@ fn linker() { "\ [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc --crate-name foo src/foo.rs [..]--crate-type bin \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [CWD]/target/{target}/debug/deps \ --target {target} \ diff --git a/tests/testsuite/profile_config.rs b/tests/testsuite/profile_config.rs index ee087d516f7..26104e7e716 100644 --- a/tests/testsuite/profile_config.rs +++ b/tests/testsuite/profile_config.rs @@ -267,7 +267,7 @@ fn profile_config_all_options() { -C panic=abort \ -C lto[..]\ -C codegen-units=2 \ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C debug-assertions=on \ -C overflow-checks=off [..]\ -C rpath [..]\ diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 0f0e51e7af8..a88ca34fd6d 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -100,7 +100,7 @@ fn profile_selection_build() { [FINISHED] dev [unoptimized + debuginfo] [..] " ) - .with_stdout_does_not_contain("[..] -C debuginfo=0[..]") + .with_stderr_does_not_contain("[..] -C debuginfo=0[..]") .run(); p.cargo("build -vv") .with_stderr_unordered( @@ -191,17 +191,17 @@ fn profile_selection_build_all_targets() { [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [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/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]` +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]` [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]` -[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 [..]` +[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 [..]` [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 [..]` [FINISHED] dev [unoptimized + debuginfo] [..] " ) - .with_stdout_does_not_contain("[..] -C debuginfo=0[..]") + .with_stderr_does_not_contain("[..] -C debuginfo=0[..]") .run(); p.cargo("build -vv") .with_stderr_unordered( @@ -318,10 +318,10 @@ fn profile_selection_test() { [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [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 [..] -[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 [..] +[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 [..] [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..] [FINISHED] test [unoptimized + debuginfo] [..] [RUNNING] `[..]/deps/foo-[..]` @@ -516,10 +516,10 @@ fn profile_selection_check_all_targets() { [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [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 [..] -[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 [..] +[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 [..] [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 [..] [FINISHED] dev [unoptimized + debuginfo] [..] @@ -618,11 +618,11 @@ fn profile_selection_check_all_targets_test() { [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..] -[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 [..] +[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 [..] [FINISHED] test [unoptimized + debuginfo] [..] ").run(); diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index ca72d9d0fea..465ab3b998a 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -66,7 +66,7 @@ fn opt_level_override_0() { [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` @@ -99,7 +99,7 @@ fn debug_override_1() { [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]\ - -C debuginfo=1 \ + -C debuginfo=1 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` @@ -136,7 +136,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link \ -C opt-level={level}[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C debug-assertions=on \ -C metadata=[..] \ --out-dir [..] \ @@ -211,7 +211,7 @@ fn top_level_overrides_deps() { --emit=[..]link \ -C prefer-dynamic \ -C opt-level=1[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [CWD]/target/release/deps \ -L dependency=[CWD]/target/release/deps` @@ -219,7 +219,7 @@ fn top_level_overrides_deps() { [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link \ -C opt-level=1[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/release/deps \ diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index aa210d6aec0..586502288b8 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -777,14 +777,14 @@ fast2", [COMPILING] bar v0.5.0 ([CWD]/bar) [RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \ --emit=[..]link[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [CWD]/target/debug/deps \ -L dependency=[CWD]/target/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \ --emit=[..]link[..]\ - -C debuginfo=2 \ + -C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [CWD]/target/debug/examples \ -L dependency=[CWD]/target/debug/deps \ diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 65e0740f8bd..6e3d69cf7bd 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -18,7 +18,7 @@ fn build_lib_for_foo() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` @@ -40,7 +40,7 @@ fn lib() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C debug-assertions=off \ -C metadata=[..] \ --out-dir [..] \ @@ -63,12 +63,12 @@ fn build_main_and_allow_unstable_options() { "\ [COMPILING] {name} v{version} ([CWD]) [RUNNING] `rustc --crate-name {name} src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C metadata=[..] \ --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` [RUNNING] `rustc --crate-name {name} src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]-C debuginfo=2 \ + --emit=[..]link[..]-C debuginfo=2 [..]\ -C debug-assertions \ -C metadata=[..] \ --out-dir [..] \ @@ -109,10 +109,10 @@ fn build_with_args_to_one_of_multiple_binaries() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]\ - -C debuginfo=2 -C metadata=[..] \ + -C debuginfo=2 [..]-C metadata=[..] \ --out-dir [..]` [RUNNING] `rustc --crate-name bar src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]\ - -C debuginfo=2 -C debug-assertions [..]` + -C debuginfo=2 [..]-C debug-assertions [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -381,9 +381,9 @@ fn build_with_args_to_one_of_multiple_tests() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]\ - -C debuginfo=2 -C metadata=[..] \ + -C debuginfo=2 [..]-C metadata=[..] \ --out-dir [..]` -[RUNNING] `rustc --crate-name bar tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 \ +[RUNNING] `rustc --crate-name bar tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]\ -C debug-assertions [..]--test[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -420,7 +420,7 @@ fn build_foo_with_bar_dependency() { [COMPILING] bar v0.1.0 ([..]) [RUNNING] `[..] -C debuginfo=2 [..]` [COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `[..] -C debuginfo=2 -C debug-assertions [..]` +[RUNNING] `[..] -C debuginfo=2 [..]-C debug-assertions [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ) @@ -478,7 +478,7 @@ fn targets_selected_default() { // unit test .with_stderr_does_not_contain( "[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \ - -C debuginfo=2 --test [..]", + -C debuginfo=2 [..]--test [..]", ) .run(); } @@ -495,7 +495,7 @@ fn targets_selected_all() { // unit test .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 --test [..]", + -C debuginfo=2 [..]--test [..]", ) .run(); }