Skip to content

Commit fe95630

Browse files
committed
Extract logic to TargetInfo::supports_debuginfo_split
1 parent 856ed94 commit fe95630

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::core::compiler::{
1212
};
1313
use crate::core::{Dependency, Package, Target, TargetKind, Workspace};
1414
use crate::util::config::{Config, StringList, TargetConfig};
15+
use crate::util::interning::InternedString;
1516
use crate::util::{CargoResult, Rustc};
1617
use anyhow::Context as _;
1718
use cargo_platform::{Cfg, CfgExpr};
@@ -43,6 +44,8 @@ pub struct TargetInfo {
4344
crate_types: RefCell<HashMap<CrateType, Option<(String, String)>>>,
4445
/// `cfg` information extracted from `rustc --print=cfg`.
4546
cfg: Vec<Cfg>,
47+
/// Supported values for `-Csplit-debuginfo=` flag, queried from rustc
48+
support_split_debuginfo: Vec<String>,
4649
/// Path to the sysroot.
4750
pub sysroot: PathBuf,
4851
/// Path to the "lib" or "bin" directory that rustc uses for its dynamic
@@ -55,8 +58,6 @@ pub struct TargetInfo {
5558
pub rustflags: Vec<String>,
5659
/// Extra flags to pass to `rustdoc`, see [`extra_args`].
5760
pub rustdocflags: Vec<String>,
58-
/// Supported values for `-Csplit-debuginfo=` flag, queried from rustc
59-
pub support_split_debuginfo: Vec<String>,
6061
}
6162

6263
/// Kind of each file generated by a Unit, part of `FileType`.
@@ -547,6 +548,13 @@ impl TargetInfo {
547548
}
548549
Ok((result, unsupported))
549550
}
551+
552+
/// Checks if the debuginfo-split value is supported by this target
553+
pub fn supports_debuginfo_split(&self, split: InternedString) -> bool {
554+
self.support_split_debuginfo
555+
.iter()
556+
.any(|sup| sup.as_str() == split.as_str())
557+
}
550558
}
551559

552560
/// Takes rustc output (using specialized command line args), and calculates the file prefix and

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,7 @@ fn build_base_args(
903903
.bcx
904904
.target_data
905905
.info(unit.kind)
906-
.support_split_debuginfo
907-
.iter()
908-
.find(|sup| sup.as_str() == split.as_str())
909-
.is_some()
906+
.supports_debuginfo_split(split)
910907
{
911908
cmd.arg("-C").arg(format!("split-debuginfo={}", split));
912909
}

0 commit comments

Comments
 (0)