restructure rustc options relating to incr. comp.

You can now pass `-Z incremental=dir` as well as saying `-Z
query-dep-graph` if you want to enable queries for some other
purpose. Accessor functions take the place of computed boolean flags.
This commit is contained in:
Niko Matsakis 2016-03-28 17:43:36 -04:00
parent 943ec3bdfc
commit fe47ca0d0b
10 changed files with 28 additions and 21 deletions

View File

@ -139,11 +139,9 @@ pub struct Options {
pub continue_parse_after_error: bool,
pub mir_opt_level: usize,
/// if true, build up the dep-graph
pub build_dep_graph: bool,
/// if true, -Z dump-dep-graph was passed to dump out the dep-graph
pub dump_dep_graph: bool,
/// if Some, enable incremental compilation, using the given
/// directory to store intermediate results
pub incremental: Option<PathBuf>,
pub no_analysis: bool,
pub debugging_opts: DebuggingOptions,
@ -260,8 +258,7 @@ pub fn basic_options() -> Options {
treat_err_as_bug: false,
continue_parse_after_error: false,
mir_opt_level: 1,
build_dep_graph: false,
dump_dep_graph: false,
incremental: None,
no_analysis: false,
debugging_opts: basic_debugging_options(),
prints: Vec::new(),
@ -276,6 +273,15 @@ pub fn basic_options() -> Options {
}
}
impl Options {
/// True if there is a reason to build the dep graph.
pub fn build_dep_graph(&self) -> bool {
self.incremental.is_some() ||
self.debugging_opts.dump_dep_graph ||
self.debugging_opts.query_dep_graph
}
}
// The type of entry function, so
// users can have their own entry
// functions that don't start a
@ -635,10 +641,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"treat all errors that occur as bugs"),
continue_parse_after_error: bool = (false, parse_bool,
"attempt to recover from parse errors (experimental)"),
incr_comp: bool = (false, parse_bool,
incremental: Option<String> = (None, parse_opt_string,
"enable incremental compilation (experimental)"),
dump_dep_graph: bool = (false, parse_bool,
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
query_dep_graph: bool = (false, parse_bool,
"enable queries of the dependency graph for regression testing"),
no_analysis: bool = (false, parse_bool,
"parse and expand the source, but run no analysis"),
extra_plugins: Vec<String> = (Vec::new(), parse_list,
@ -1051,8 +1059,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let treat_err_as_bug = debugging_opts.treat_err_as_bug;
let continue_parse_after_error = debugging_opts.continue_parse_after_error;
let mir_opt_level = debugging_opts.mir_opt_level.unwrap_or(1);
let incremental_compilation = debugging_opts.incr_comp;
let dump_dep_graph = debugging_opts.dump_dep_graph;
let no_analysis = debugging_opts.no_analysis;
let mut output_types = HashMap::new();
@ -1212,6 +1218,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let crate_name = matches.opt_str("crate-name");
let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
Options {
crate_types: crate_types,
gc: gc,
@ -1231,8 +1239,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
treat_err_as_bug: treat_err_as_bug,
continue_parse_after_error: continue_parse_after_error,
mir_opt_level: mir_opt_level,
build_dep_graph: incremental_compilation || dump_dep_graph,
dump_dep_graph: dump_dep_graph,
incremental: incremental,
no_analysis: no_analysis,
debugging_opts: debugging_opts,
prints: prints,

View File

@ -121,7 +121,7 @@ pub fn compile_input(sess: &Session,
let expanded_crate = assign_node_ids(sess, expanded_crate);
// Lower ast -> hir.
let lcx = LoweringContext::new(sess, Some(&expanded_crate));
let dep_graph = DepGraph::new(sess.opts.build_dep_graph);
let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
let mut hir_forest = time(sess.time_passes(),
"lowering ast -> hir",
|| hir_map::Forest::new(lower_crate(&lcx, &expanded_crate),

View File

@ -11,7 +11,7 @@
// Test that when a trait impl changes, fns whose body uses that trait
// must also be recompiled.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(warnings)]

View File

@ -11,7 +11,7 @@
// Test that immediate callers have to change when callee changes, but
// not callers' callers.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(dead_code)]

View File

@ -11,7 +11,7 @@
// Test cases where a changing struct appears in the signature of fns
// and methods.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(dead_code)]

View File

@ -11,7 +11,7 @@
// Test that adding an impl to a trait `Foo` DOES affect functions
// that only use `Bar` if they have methods in common.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(dead_code)]

View File

@ -11,7 +11,7 @@
// Test that adding an impl to a trait `Foo` does not affect functions
// that only use `Bar`, so long as they do not have methods in common.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(warnings)]

View File

@ -11,7 +11,7 @@
// Test that when a trait impl changes, fns whose body uses that trait
// must also be recompiled.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(warnings)]

View File

@ -10,7 +10,7 @@
// Test that two unrelated functions have no trans dependency.
// compile-flags: -Z incr-comp
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#![allow(dead_code)]

View File

@ -239,7 +239,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
let krate = driver::assign_node_ids(&sess, krate);
let lcx = LoweringContext::new(&sess, Some(&krate));
let dep_graph = DepGraph::new(sess.opts.build_dep_graph);
let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
let mut hir_forest = ast_map::Forest::new(lower_crate(&lcx, &krate), dep_graph);
let arenas = ty::CtxtArenas::new();
let ast_map = driver::make_map(&sess, &mut hir_forest);