Skip to content

Commit

Permalink
Extract logic to TargetInfo::supports_debuginfo_split
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Nov 8, 2022
1 parent 856ed94 commit fe95630
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -43,6 +44,8 @@ pub struct TargetInfo {
crate_types: RefCell<HashMap<CrateType, Option<(String, String)>>>,
/// `cfg` information extracted from `rustc --print=cfg`.
cfg: Vec<Cfg>,
/// Supported values for `-Csplit-debuginfo=` flag, queried from rustc
support_split_debuginfo: Vec<String>,
/// Path to the sysroot.
pub sysroot: PathBuf,
/// Path to the "lib" or "bin" directory that rustc uses for its dynamic
Expand All @@ -55,8 +58,6 @@ pub struct TargetInfo {
pub rustflags: Vec<String>,
/// Extra flags to pass to `rustdoc`, see [`extra_args`].
pub rustdocflags: Vec<String>,
/// Supported values for `-Csplit-debuginfo=` flag, queried from rustc
pub support_split_debuginfo: Vec<String>,
}

/// Kind of each file generated by a Unit, part of `FileType`.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit fe95630

Please sign in to comment.