Skip to content

Commit fe47ca0

Browse files
committed
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.
1 parent 943ec3b commit fe47ca0

File tree

10 files changed

+28
-21
lines changed

10 files changed

+28
-21
lines changed

src/librustc/session/config.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,9 @@ pub struct Options {
139139
pub continue_parse_after_error: bool,
140140
pub mir_opt_level: usize,
141141

142-
/// if true, build up the dep-graph
143-
pub build_dep_graph: bool,
144-
145-
/// if true, -Z dump-dep-graph was passed to dump out the dep-graph
146-
pub dump_dep_graph: bool,
142+
/// if Some, enable incremental compilation, using the given
143+
/// directory to store intermediate results
144+
pub incremental: Option<PathBuf>,
147145

148146
pub no_analysis: bool,
149147
pub debugging_opts: DebuggingOptions,
@@ -260,8 +258,7 @@ pub fn basic_options() -> Options {
260258
treat_err_as_bug: false,
261259
continue_parse_after_error: false,
262260
mir_opt_level: 1,
263-
build_dep_graph: false,
264-
dump_dep_graph: false,
261+
incremental: None,
265262
no_analysis: false,
266263
debugging_opts: basic_debugging_options(),
267264
prints: Vec::new(),
@@ -276,6 +273,15 @@ pub fn basic_options() -> Options {
276273
}
277274
}
278275

276+
impl Options {
277+
/// True if there is a reason to build the dep graph.
278+
pub fn build_dep_graph(&self) -> bool {
279+
self.incremental.is_some() ||
280+
self.debugging_opts.dump_dep_graph ||
281+
self.debugging_opts.query_dep_graph
282+
}
283+
}
284+
279285
// The type of entry function, so
280286
// users can have their own entry
281287
// functions that don't start a
@@ -635,10 +641,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
635641
"treat all errors that occur as bugs"),
636642
continue_parse_after_error: bool = (false, parse_bool,
637643
"attempt to recover from parse errors (experimental)"),
638-
incr_comp: bool = (false, parse_bool,
644+
incremental: Option<String> = (None, parse_opt_string,
639645
"enable incremental compilation (experimental)"),
640646
dump_dep_graph: bool = (false, parse_bool,
641647
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
648+
query_dep_graph: bool = (false, parse_bool,
649+
"enable queries of the dependency graph for regression testing"),
642650
no_analysis: bool = (false, parse_bool,
643651
"parse and expand the source, but run no analysis"),
644652
extra_plugins: Vec<String> = (Vec::new(), parse_list,
@@ -1051,8 +1059,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10511059
let treat_err_as_bug = debugging_opts.treat_err_as_bug;
10521060
let continue_parse_after_error = debugging_opts.continue_parse_after_error;
10531061
let mir_opt_level = debugging_opts.mir_opt_level.unwrap_or(1);
1054-
let incremental_compilation = debugging_opts.incr_comp;
1055-
let dump_dep_graph = debugging_opts.dump_dep_graph;
10561062
let no_analysis = debugging_opts.no_analysis;
10571063

10581064
let mut output_types = HashMap::new();
@@ -1212,6 +1218,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
12121218

12131219
let crate_name = matches.opt_str("crate-name");
12141220

1221+
let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
1222+
12151223
Options {
12161224
crate_types: crate_types,
12171225
gc: gc,
@@ -1231,8 +1239,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
12311239
treat_err_as_bug: treat_err_as_bug,
12321240
continue_parse_after_error: continue_parse_after_error,
12331241
mir_opt_level: mir_opt_level,
1234-
build_dep_graph: incremental_compilation || dump_dep_graph,
1235-
dump_dep_graph: dump_dep_graph,
1242+
incremental: incremental,
12361243
no_analysis: no_analysis,
12371244
debugging_opts: debugging_opts,
12381245
prints: prints,

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn compile_input(sess: &Session,
121121
let expanded_crate = assign_node_ids(sess, expanded_crate);
122122
// Lower ast -> hir.
123123
let lcx = LoweringContext::new(sess, Some(&expanded_crate));
124-
let dep_graph = DepGraph::new(sess.opts.build_dep_graph);
124+
let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
125125
let mut hir_forest = time(sess.time_passes(),
126126
"lowering ast -> hir",
127127
|| hir_map::Forest::new(lower_crate(&lcx, &expanded_crate),

src/test/compile-fail/dep-graph-assoc-type-trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test that when a trait impl changes, fns whose body uses that trait
1212
// must also be recompiled.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(warnings)]

src/test/compile-fail/dep-graph-caller-callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test that immediate callers have to change when callee changes, but
1212
// not callers' callers.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(dead_code)]

src/test/compile-fail/dep-graph-struct-signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test cases where a changing struct appears in the signature of fns
1212
// and methods.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(dead_code)]

src/test/compile-fail/dep-graph-trait-impl-two-traits-same-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test that adding an impl to a trait `Foo` DOES affect functions
1212
// that only use `Bar` if they have methods in common.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(dead_code)]

src/test/compile-fail/dep-graph-trait-impl-two-traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test that adding an impl to a trait `Foo` does not affect functions
1212
// that only use `Bar`, so long as they do not have methods in common.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(warnings)]

src/test/compile-fail/dep-graph-trait-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Test that when a trait impl changes, fns whose body uses that trait
1212
// must also be recompiled.
1313

14-
// compile-flags: -Z incr-comp
14+
// compile-flags: -Z query-dep-graph
1515

1616
#![feature(rustc_attrs)]
1717
#![allow(warnings)]

src/test/compile-fail/dep-graph-unrelated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Test that two unrelated functions have no trans dependency.
1212

13-
// compile-flags: -Z incr-comp
13+
// compile-flags: -Z query-dep-graph
1414

1515
#![feature(rustc_attrs)]
1616
#![allow(dead_code)]

src/test/run-make/execution-engine/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
239239

240240
let krate = driver::assign_node_ids(&sess, krate);
241241
let lcx = LoweringContext::new(&sess, Some(&krate));
242-
let dep_graph = DepGraph::new(sess.opts.build_dep_graph);
242+
let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
243243
let mut hir_forest = ast_map::Forest::new(lower_crate(&lcx, &krate), dep_graph);
244244
let arenas = ty::CtxtArenas::new();
245245
let ast_map = driver::make_map(&sess, &mut hir_forest);

0 commit comments

Comments
 (0)