about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-08-15 08:35:18 -0700
committerGitHub <noreply@github.com>2016-08-15 08:35:18 -0700
commitf65d96fe3fa3cfae2cfc88be40f7416a22c88bf2 (patch)
tree85911176229bb3d2f8ec21f4aa41545b0fa5b397 /src/test
parentb72fa8ca95c02e4b44b216a425fd563ad2ef58bb (diff)
parent67f19e5e28430773256ee55ab6b315e0130f228f (diff)
downloadrust-f65d96fe3fa3cfae2cfc88be40f7416a22c88bf2.tar.gz
rust-f65d96fe3fa3cfae2cfc88be40f7416a22c88bf2.zip
Auto merge of #35340 - michaelwoerister:incr-comp-cli-args, r=nikomatsakis
Take commandline arguments into account for incr. comp.

Implements the conservative strategy described in https://github.com/rust-lang/rust/issues/33727.

From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples.

The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct.

One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data.

It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map.

Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/incremental/commandline-args.rs30
-rw-r--r--src/test/run-make/issue-19371/foo.rs7
-rw-r--r--src/test/run-pass-fulldeps/compiler-calls.rs4
3 files changed, 38 insertions, 3 deletions
diff --git a/src/test/incremental/commandline-args.rs b/src/test/incremental/commandline-args.rs
new file mode 100644
index 00000000000..95187b825be
--- /dev/null
+++ b/src/test/incremental/commandline-args.rs
@@ -0,0 +1,30 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that changing a tracked commandline argument invalidates
+// the cache while changing an untracked one doesn't.
+
+// revisions:rpass1 rpass2 rpass3
+
+#![feature(rustc_attrs)]
+
+#![rustc_partition_translated(module="commandline_args", cfg="rpass2")]
+#![rustc_partition_reused(module="commandline_args", cfg="rpass3")]
+
+// Between revisions 1 and 2, we are changing the debuginfo-level, which should
+// invalidate the cache. Between revisions 2 and 3, we are adding `--verbose`
+// which should have no effect on the cache:
+//[rpass1] compile-flags: -C debuginfo=0
+//[rpass2] compile-flags: -C debuginfo=2
+//[rpass3] compile-flags: -C debuginfo=2 --verbose
+
+pub fn main() {
+    // empty
+}
diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs
index d5220316a20..35043bdaddf 100644
--- a/src/test/run-make/issue-19371/foo.rs
+++ b/src/test/run-make/issue-19371/foo.rs
@@ -19,7 +19,8 @@ extern crate syntax;
 
 use rustc::dep_graph::DepGraph;
 use rustc::session::{build_session, Session};
-use rustc::session::config::{basic_options, build_configuration, Input, OutputType};
+use rustc::session::config::{basic_options, build_configuration, Input,
+                             OutputType, OutputTypes};
 use rustc_driver::driver::{compile_input, CompileController, anon_src};
 use rustc_metadata::cstore::CStore;
 use rustc_errors::registry::Registry;
@@ -51,7 +52,7 @@ fn main() {
 
 fn basic_sess(sysroot: PathBuf) -> (Session, Rc<CStore>) {
     let mut opts = basic_options();
-    opts.output_types.insert(OutputType::Exe, None);
+    opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
     opts.maybe_sysroot = Some(sysroot);
 
     let descriptions = Registry::new(&rustc::DIAGNOSTICS);
@@ -64,7 +65,7 @@ fn basic_sess(sysroot: PathBuf) -> (Session, Rc<CStore>) {
 
 fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
     let (sess, cstore) = basic_sess(sysroot);
-    let cfg = build_configuration(&sess);
+    let cfg = build_configuration(&sess, vec![]);
     let control = CompileController::basic();
 
     compile_input(&sess, &cstore,
diff --git a/src/test/run-pass-fulldeps/compiler-calls.rs b/src/test/run-pass-fulldeps/compiler-calls.rs
index ff57e9d6b73..775ba38004e 100644
--- a/src/test/run-pass-fulldeps/compiler-calls.rs
+++ b/src/test/run-pass-fulldeps/compiler-calls.rs
@@ -24,6 +24,7 @@ extern crate rustc_errors as errors;
 use rustc::session::Session;
 use rustc::session::config::{self, Input};
 use rustc_driver::{driver, CompilerCalls, Compilation};
+use syntax::ast;
 
 use std::path::PathBuf;
 
@@ -35,6 +36,7 @@ impl<'a> CompilerCalls<'a> for TestCalls {
     fn early_callback(&mut self,
                       _: &getopts::Matches,
                       _: &config::Options,
+                      _: &ast::CrateConfig,
                       _: &errors::registry::Registry,
                       _: config::ErrorOutputType)
                       -> Compilation {
@@ -45,6 +47,7 @@ impl<'a> CompilerCalls<'a> for TestCalls {
     fn late_callback(&mut self,
                      _: &getopts::Matches,
                      _: &Session,
+                     _: &ast::CrateConfig,
                      _: &Input,
                      _: &Option<PathBuf>,
                      _: &Option<PathBuf>)
@@ -62,6 +65,7 @@ impl<'a> CompilerCalls<'a> for TestCalls {
     fn no_input(&mut self,
                 _: &getopts::Matches,
                 _: &config::Options,
+                _: &ast::CrateConfig,
                 _: &Option<PathBuf>,
                 _: &Option<PathBuf>,
                 _: &errors::registry::Registry)