mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-08 13:55:25 +00:00
Handle path prefix mapping in a more stable way when computing the crate hash.
This commit is contained in:
parent
16362c737f
commit
0397fc1b3a
@ -9,14 +9,15 @@
|
||||
// except according to those terms.
|
||||
|
||||
use super::*;
|
||||
|
||||
use dep_graph::{DepGraph, DepKind, DepNodeIndex};
|
||||
use hir::def_id::{LOCAL_CRATE, CrateNum};
|
||||
use hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use hir::svh::Svh;
|
||||
use middle::cstore::CrateStore;
|
||||
use session::CrateDisambiguator;
|
||||
use std::iter::repeat;
|
||||
use syntax::ast::{NodeId, CRATE_NODE_ID};
|
||||
use syntax::codemap::CodeMap;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use ich::StableHashingContext;
|
||||
@ -123,6 +124,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
||||
pub(super) fn finalize_and_compute_crate_hash(self,
|
||||
crate_disambiguator: CrateDisambiguator,
|
||||
cstore: &CrateStore,
|
||||
codemap: &CodeMap,
|
||||
commandline_args_hash: u64)
|
||||
-> (Vec<MapEntry<'hir>>, Svh) {
|
||||
let mut node_hashes: Vec<_> = self
|
||||
@ -147,11 +149,25 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
||||
(name1, dis1).cmp(&(name2, dis2))
|
||||
});
|
||||
|
||||
// We hash the final, remapped names of all local source files so we
|
||||
// don't have to include the path prefix remapping commandline args.
|
||||
// If we included the full mapping in the SVH, we could only have
|
||||
// reproducible builds by compiling from the same directory. So we just
|
||||
// hash the result of the mapping instead of the mapping itself.
|
||||
let mut source_file_names: Vec<_> = codemap
|
||||
.files()
|
||||
.iter()
|
||||
.filter(|filemap| CrateNum::from_u32(filemap.crate_of_origin) == LOCAL_CRATE)
|
||||
.map(|filemap| filemap.name_hash)
|
||||
.collect();
|
||||
|
||||
source_file_names.sort_unstable();
|
||||
|
||||
let (_, crate_dep_node_index) = self
|
||||
.dep_graph
|
||||
.with_task(DepNode::new_no_params(DepKind::Krate),
|
||||
&self.hcx,
|
||||
((node_hashes, upstream_crates),
|
||||
(((node_hashes, upstream_crates), source_file_names),
|
||||
(commandline_args_hash,
|
||||
crate_disambiguator.to_fingerprint())),
|
||||
identity_fn);
|
||||
|
@ -1065,6 +1065,7 @@ pub fn map_crate<'hir>(sess: &::session::Session,
|
||||
let cmdline_args = sess.opts.dep_tracking_hash();
|
||||
collector.finalize_and_compute_crate_hash(crate_disambiguator,
|
||||
cstore,
|
||||
sess.codemap(),
|
||||
cmdline_args)
|
||||
};
|
||||
|
||||
|
@ -1269,9 +1269,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||
"set the optimization fuel quota for a crate"),
|
||||
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"make Rustc print the total optimization fuel used by a crate"),
|
||||
remap_path_prefix_from: Vec<PathBuf> = (vec![], parse_pathbuf_push, [TRACKED],
|
||||
remap_path_prefix_from: Vec<PathBuf> = (vec![], parse_pathbuf_push, [UNTRACKED],
|
||||
"add a source pattern to the file path remapping config"),
|
||||
remap_path_prefix_to: Vec<PathBuf> = (vec![], parse_pathbuf_push, [TRACKED],
|
||||
remap_path_prefix_to: Vec<PathBuf> = (vec![], parse_pathbuf_push, [UNTRACKED],
|
||||
"add a mapping target to the file path remapping config"),
|
||||
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
|
||||
"force all crates to be `rustc_private` unstable"),
|
||||
@ -1717,7 +1717,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||
}
|
||||
|
||||
let remap_path_prefix_sources = debugging_opts.remap_path_prefix_from.len();
|
||||
let remap_path_prefix_targets = debugging_opts.remap_path_prefix_from.len();
|
||||
let remap_path_prefix_targets = debugging_opts.remap_path_prefix_to.len();
|
||||
|
||||
if remap_path_prefix_targets < remap_path_prefix_sources {
|
||||
for source in &debugging_opts.remap_path_prefix_from[remap_path_prefix_targets..] {
|
||||
|
Loading…
Reference in New Issue
Block a user