diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index 8813dd8bfad..0ba01509c79 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -12,6 +12,7 @@ use crate::core::compiler::{ }; use crate::core::{Dependency, Package, Target, TargetKind, Workspace}; use crate::util::config::{Config, StringList, TargetConfig}; +use crate::util::interning::InternedString; use crate::util::{CargoResult, Rustc}; use anyhow::Context as _; use cargo_platform::{Cfg, CfgExpr}; @@ -43,6 +44,8 @@ pub struct TargetInfo { crate_types: RefCell>>, /// `cfg` information extracted from `rustc --print=cfg`. cfg: Vec, + /// Supported values for `-Csplit-debuginfo=` flag, queried from rustc + support_split_debuginfo: Vec, /// Path to the sysroot. pub sysroot: PathBuf, /// Path to the "lib" or "bin" directory that rustc uses for its dynamic @@ -55,8 +58,6 @@ pub struct TargetInfo { pub rustflags: Vec, /// Extra flags to pass to `rustdoc`, see [`extra_args`]. pub rustdocflags: Vec, - /// Supported values for `-Csplit-debuginfo=` flag, queried from rustc - pub support_split_debuginfo: Vec, } /// Kind of each file generated by a Unit, part of `FileType`. @@ -547,6 +548,13 @@ impl TargetInfo { } Ok((result, unsupported)) } + + /// Checks if the debuginfo-split value is supported by this target + pub fn supports_debuginfo_split(&self, split: InternedString) -> bool { + self.support_split_debuginfo + .iter() + .any(|sup| sup.as_str() == split.as_str()) + } } /// Takes rustc output (using specialized command line args), and calculates the file prefix and diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index dad221edb75..2999c358467 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -903,10 +903,7 @@ fn build_base_args( .bcx .target_data .info(unit.kind) - .support_split_debuginfo - .iter() - .find(|sup| sup.as_str() == split.as_str()) - .is_some() + .supports_debuginfo_split(split) { cmd.arg("-C").arg(format!("split-debuginfo={}", split)); }