Skip to content

Commit 6b206c5

Browse files
committed
Auto merge of #33476 - nikomatsakis:incr-comp-xcrate, r=mw
track incr. comp. dependencies across crates This PR refactors the compiler's incremental compilation hashing so that it can track dependencies across crates. The main bits are: - computing a hash representing the metadata for an item we are emitting - we do this by making `MetaData(X)` be the current task while computing metadata for an item - this naturally registers reads from any tables and things that we read for that purpose - we can then hash all the inputs to those tables - tracking when we access metadata - we do this by registering a read of `MetaData(X)` for each foreign item `X` whose metadata we read - hashing metadata from foreign items - we do this by loading up metadata from a file in the incr. comp. directory - if there is no file, we use the SVH for the entire crate There is one very simple test only at this point. The next PR will be focused on expanding out the tests. Note that this is based on top of rust-lang/rust#33228 r? @michaelwoerister
2 parents 487ee8a + 613ce0a commit 6b206c5

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

core.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ pub fn run_core(search_paths: SearchPaths,
134134
false,
135135
codemap.clone());
136136

137-
let cstore = Rc::new(CStore::new(token::get_ident_interner()));
138-
let sess = session::build_session_(sessopts, cpath, diagnostic_handler,
137+
let dep_graph = DepGraph::new(false);
138+
let _ignore = dep_graph.in_ignore();
139+
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
140+
let sess = session::build_session_(sessopts, &dep_graph, cpath, diagnostic_handler,
139141
codemap, cstore.clone());
140142
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
141143

@@ -151,15 +153,14 @@ pub fn run_core(search_paths: SearchPaths,
151153
.expect("phase_2_configure_and_expand aborted in rustdoc!");
152154

153155
let krate = driver::assign_node_ids(&sess, krate);
154-
let dep_graph = DepGraph::new(false);
155156

156157
let mut defs = hir_map::collect_definitions(&krate);
157158
read_local_crates(&sess, &cstore, &defs, &krate, &name, &dep_graph);
158159

159160
// Lower ast -> hir and resolve.
160161
let (analysis, resolutions, mut hir_forest) = {
161-
driver::lower_and_resolve(&sess, &name, &mut defs, &krate, dep_graph,
162-
resolve::MakeGlobMap::No)
162+
driver::lower_and_resolve(&sess, &name, &mut defs, &krate,
163+
&sess.dep_graph, resolve::MakeGlobMap::No)
163164
};
164165

165166
let arenas = ty::CtxtArenas::new();
@@ -177,7 +178,6 @@ pub fn run_core(search_paths: SearchPaths,
177178
return None
178179
}
179180

180-
let _ignore = tcx.dep_graph.in_ignore();
181181
let ty::CrateAnalysis { access_levels, .. } = analysis;
182182

183183
// Convert from a NodeId set to a DefId set since we don't always have easy access

test.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ pub fn run(input: &str,
7979
false,
8080
codemap.clone());
8181

82-
let cstore = Rc::new(CStore::new(token::get_ident_interner()));
82+
let dep_graph = DepGraph::new(false);
83+
let _ignore = dep_graph.in_ignore();
84+
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
8385
let sess = session::build_session_(sessopts,
86+
&dep_graph,
8487
Some(input_path.clone()),
8588
diagnostic_handler,
8689
codemap,
@@ -98,12 +101,12 @@ pub fn run(input: &str,
98101
let defs = hir_map::collect_definitions(&krate);
99102

100103
let mut dummy_resolver = DummyResolver;
101-
let krate = lower_crate(&krate, &sess, &mut dummy_resolver);
104+
let krate = lower_crate(&sess, &krate, &sess, &mut dummy_resolver);
102105

103106
let opts = scrape_test_config(&krate);
104107

105108
let _ignore = dep_graph.in_ignore();
106-
let mut forest = hir_map::Forest::new(krate, dep_graph.clone());
109+
let mut forest = hir_map::Forest::new(krate, &dep_graph);
107110
let map = hir_map::map_crate(&mut forest, defs);
108111

109112
let ctx = core::DocContext {
@@ -238,8 +241,10 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
238241
// Compile the code
239242
let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
240243

241-
let cstore = Rc::new(CStore::new(token::get_ident_interner()));
244+
let dep_graph = DepGraph::new(false);
245+
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
242246
let sess = session::build_session_(sessopts,
247+
&dep_graph,
243248
None,
244249
diagnostic_handler,
245250
codemap,

0 commit comments

Comments
 (0)