Skip to content

Commit

Permalink
Auto merge of #33476 - nikomatsakis:incr-comp-xcrate, r=mw
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed May 18, 2016
2 parents 487ee8a + 613ce0a commit 6b206c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ pub fn run_core(search_paths: SearchPaths,
false,
codemap.clone());

let cstore = Rc::new(CStore::new(token::get_ident_interner()));
let sess = session::build_session_(sessopts, cpath, diagnostic_handler,
let dep_graph = DepGraph::new(false);
let _ignore = dep_graph.in_ignore();
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let sess = session::build_session_(sessopts, &dep_graph, cpath, diagnostic_handler,
codemap, cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));

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

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

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

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

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

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

// Convert from a NodeId set to a DefId set since we don't always have easy access
Expand Down
13 changes: 9 additions & 4 deletions test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ pub fn run(input: &str,
false,
codemap.clone());

let cstore = Rc::new(CStore::new(token::get_ident_interner()));
let dep_graph = DepGraph::new(false);
let _ignore = dep_graph.in_ignore();
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let sess = session::build_session_(sessopts,
&dep_graph,
Some(input_path.clone()),
diagnostic_handler,
codemap,
Expand All @@ -98,12 +101,12 @@ pub fn run(input: &str,
let defs = hir_map::collect_definitions(&krate);

let mut dummy_resolver = DummyResolver;
let krate = lower_crate(&krate, &sess, &mut dummy_resolver);
let krate = lower_crate(&sess, &krate, &sess, &mut dummy_resolver);

let opts = scrape_test_config(&krate);

let _ignore = dep_graph.in_ignore();
let mut forest = hir_map::Forest::new(krate, dep_graph.clone());
let mut forest = hir_map::Forest::new(krate, &dep_graph);
let map = hir_map::map_crate(&mut forest, defs);

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

let cstore = Rc::new(CStore::new(token::get_ident_interner()));
let dep_graph = DepGraph::new(false);
let cstore = Rc::new(CStore::new(&dep_graph, token::get_ident_interner()));
let sess = session::build_session_(sessopts,
&dep_graph,
None,
diagnostic_handler,
codemap,
Expand Down

0 comments on commit 6b206c5

Please sign in to comment.