提交 fece9c73 编写于 作者: B bors

Auto merge of #39281 - michaelwoerister:make-cc-incr-comp-opt-in, r=nikomatsakis

incr.comp.: Make cross-crate tracking for incr. comp. opt-in.

The current implementation of cross-crate dependency tracking can cause quite long compile times and high memory usage for some crates (see #39208 for example). This PR therefore makes that part of dependency tracking optional. Incremental compilation still works, it will only have very coarse dep-tracking for upstream crates.

r? @nikomatsakis
...@@ -899,6 +899,8 @@ fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bo ...@@ -899,6 +899,8 @@ fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bo
"attempt to recover from parse errors (experimental)"), "attempt to recover from parse errors (experimental)"),
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED], incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation (experimental)"), "enable incremental compilation (experimental)"),
incremental_cc: bool = (false, parse_bool, [UNTRACKED],
"enable cross-crate incremental compilation (even more experimental)"),
incremental_info: bool = (false, parse_bool, [UNTRACKED], incremental_info: bool = (false, parse_bool, [UNTRACKED],
"print high-level information about incremental reuse (or the lack thereof)"), "print high-level information about incremental reuse (or the lack thereof)"),
incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED], incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
......
...@@ -33,8 +33,12 @@ pub struct Predecessors<'query> { ...@@ -33,8 +33,12 @@ pub struct Predecessors<'query> {
impl<'q> Predecessors<'q> { impl<'q> Predecessors<'q> {
pub fn new(query: &'q DepGraphQuery<DefId>, hcx: &mut HashContext) -> Self { pub fn new(query: &'q DepGraphQuery<DefId>, hcx: &mut HashContext) -> Self {
// Find nodes for which we want to know the full set of preds
let tcx = hcx.tcx; let tcx = hcx.tcx;
let collect_for_metadata = tcx.sess.opts.debugging_opts.incremental_cc ||
tcx.sess.opts.debugging_opts.query_dep_graph;
// Find nodes for which we want to know the full set of preds
let node_count = query.graph.len_nodes(); let node_count = query.graph.len_nodes();
// Set up some data structures the cache predecessor search needs: // Set up some data structures the cache predecessor search needs:
...@@ -52,7 +56,7 @@ pub fn new(query: &'q DepGraphQuery<DefId>, hcx: &mut HashContext) -> Self { ...@@ -52,7 +56,7 @@ pub fn new(query: &'q DepGraphQuery<DefId>, hcx: &mut HashContext) -> Self {
.enumerate() .enumerate()
.filter(|&(_, node)| match node.data { .filter(|&(_, node)| match node.data {
DepNode::WorkProduct(_) => true, DepNode::WorkProduct(_) => true,
DepNode::MetaData(ref def_id) => def_id.is_local(), DepNode::MetaData(ref def_id) => collect_for_metadata && def_id.is_local(),
// if -Z query-dep-graph is passed, save more extended data // if -Z query-dep-graph is passed, save more extended data
// to enable better unit testing // to enable better unit testing
......
...@@ -55,17 +55,21 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ...@@ -55,17 +55,21 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let preds = Predecessors::new(&query, &mut hcx); let preds = Predecessors::new(&query, &mut hcx);
let mut current_metadata_hashes = FxHashMap(); let mut current_metadata_hashes = FxHashMap();
// IMPORTANT: We are saving the metadata hashes *before* the dep-graph, if sess.opts.debugging_opts.incremental_cc ||
// since metadata-encoding might add new entries to the sess.opts.debugging_opts.query_dep_graph {
// DefIdDirectory (which is saved in the dep-graph file). // IMPORTANT: We are saving the metadata hashes *before* the dep-graph,
save_in(sess, // since metadata-encoding might add new entries to the
metadata_hash_export_path(sess), // DefIdDirectory (which is saved in the dep-graph file).
|e| encode_metadata_hashes(tcx, save_in(sess,
svh, metadata_hash_export_path(sess),
&preds, |e| encode_metadata_hashes(tcx,
&mut builder, svh,
&mut current_metadata_hashes, &preds,
e)); &mut builder,
&mut current_metadata_hashes,
e));
}
save_in(sess, save_in(sess,
dep_graph_path(sess), dep_graph_path(sess),
|e| encode_dep_graph(&preds, &mut builder, e)); |e| encode_dep_graph(&preds, &mut builder, e));
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
pub struct Point { pub struct Point {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
#![crate_type="rlib"] #![crate_type="rlib"]
#[cfg(rpass1)] #[cfg(rpass1)]
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
pub struct Point { pub struct Point {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
pub struct Point { pub struct Point {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
#![allow(warnings)] #![allow(warnings)]
#![crate_name = "a"] #![crate_name = "a"]
#![crate_type = "rlib"] #![crate_type = "rlib"]
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
// no-prefer-dynamic // no-prefer-dynamic
#![crate_type="rlib"] #![crate_type="rlib"]
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
#![crate_type="rlib"] #![crate_type="rlib"]
#[cfg(rpass1)] #[cfg(rpass1)]
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-flags: -Z incremental-cc
#![crate_type="rlib"] #![crate_type="rlib"]
#[cfg(rpass1)] #[cfg(rpass1)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册