Skip to content

Commit

Permalink
Gate binary dependency information behind -Zbinary-dep-depinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jul 24, 2019
1 parent eafb42d commit d749b5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
parse_symbol_mangling_version, [TRACKED],
"which mangling version to use for symbol names"),
binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
"include artifacts (sysroot, crate dependencies) used during compilation in dep-info"),
}

pub fn default_lib_output() -> CrateType {
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ impl Session {
pub fn print_llvm_passes(&self) -> bool {
self.opts.debugging_opts.print_llvm_passes
}
pub fn binary_dep_depinfo(&self) -> bool {
self.opts.debugging_opts.binary_dep_depinfo
}

/// Gets the features enabled for the current compilation session.
/// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents
Expand Down
24 changes: 13 additions & 11 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,19 @@ fn write_out_deps(compiler: &Compiler, outputs: &OutputFilenames, out_filenames:
.map(|fmap| escape_dep_filename(&fmap.name))
.collect();

for cnum in compiler.cstore.crates_untracked() {
let metadata = compiler.cstore.crate_data_as_rc_any(cnum);
let metadata = metadata.downcast_ref::<cstore::CrateMetadata>().unwrap();
if let Some((path, _)) = &metadata.source.dylib {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
}
if let Some((path, _)) = &metadata.source.rlib {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
}
if let Some((path, _)) = &metadata.source.rmeta {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
if sess.binary_dep_depinfo() {
for cnum in compiler.cstore.crates_untracked() {
let metadata = compiler.cstore.crate_data_as_rc_any(cnum);
let metadata = metadata.downcast_ref::<cstore::CrateMetadata>().unwrap();
if let Some((path, _)) = &metadata.source.dylib {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
}
if let Some((path, _)) = &metadata.source.rlib {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
}
if let Some((path, _)) = &metadata.source.rmeta {
files.push(escape_dep_filename(&FileName::Real(path.clone())));
}
}
}

Expand Down

0 comments on commit d749b5e

Please sign in to comment.