提交 32414310 编写于 作者: M Michael Woerister

Add the notion of a dependency tracking status to commandline arguments.

Commandline arguments influence whether incremental compilation
can use its compilation cache and thus their changes relative to
previous compilation sessions need to be taking into account. This
commit makes sure that one has to specify for every commandline
argument whether it influences incremental compilation or not.
上级 695b3d82
......@@ -269,7 +269,7 @@ pub fn as_str(&self) -> String {
}
/// Setting for how to handle a lint.
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug)]
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
pub enum Level {
Allow, Warn, Deny, Forbid
}
......
......@@ -73,7 +73,7 @@ pub enum LinkagePreference {
}
enum_from_u32! {
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum NativeLibraryKind {
NativeStatic, // native static library (.a archive)
NativeFramework, // OSX-specific
......
此差异已折叠。
......@@ -363,7 +363,7 @@ pub fn build_session_with_codemap(sopts: config::Options,
.map(|&(_, ref level)| *level != lint::Allow)
.last()
.unwrap_or(true);
let treat_err_as_bug = sopts.treat_err_as_bug;
let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug;
let emitter: Box<Emitter> = match sopts.error_format {
config::ErrorOutputType::HumanReadable(color_config) => {
......
......@@ -22,7 +22,7 @@ pub struct Iter<'a> {
iter: slice::Iter<'a, (PathKind, PathBuf)>,
}
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
#[derive(Eq, PartialEq, Clone, Copy, Debug, PartialOrd, Ord, Hash)]
pub enum PathKind {
Native,
Crate,
......
......@@ -15,7 +15,8 @@
use rustc_mir as mir;
use rustc::mir::mir_map::MirMap;
use rustc::session::{Session, CompileResult, compile_result_from_err_count};
use rustc::session::config::{self, Input, OutputFilenames, OutputType};
use rustc::session::config::{self, Input, OutputFilenames, OutputType,
OutputTypes};
use rustc::session::search_paths::PathKind;
use rustc::lint;
use rustc::middle::{self, dependency_format, stability, reachable};
......@@ -42,7 +43,6 @@
use serialize::json;
use std::collections::HashMap;
use std::env;
use std::ffi::{OsString, OsStr};
use std::fs;
......@@ -478,7 +478,7 @@ pub fn phase_1_parse_input<'a>(sess: &'a Session,
cfg: ast::CrateConfig,
input: &Input)
-> PResult<'a, ast::Crate> {
let continue_after_error = sess.opts.continue_parse_after_error;
let continue_after_error = sess.opts.debugging_opts.continue_parse_after_error;
sess.diagnostic().set_continue_after_error(continue_after_error);
let krate = time(sess.time_passes(), "parsing", || {
......@@ -1026,11 +1026,10 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
trans: &trans::CrateTranslation,
outputs: &OutputFilenames) -> CompileResult {
if sess.opts.cg.no_integrated_as {
let mut map = HashMap::new();
map.insert(OutputType::Assembly, None);
let output_types = OutputTypes::new(&[(OutputType::Assembly, None)]);
time(sess.time_passes(),
"LLVM passes",
|| write::run_passes(sess, trans, &map, outputs));
|| write::run_passes(sess, trans, &output_types, outputs));
write::run_assembler(sess, outputs);
......
......@@ -506,12 +506,14 @@ fn build_controller(&mut self,
return control;
}
if sess.opts.parse_only || sess.opts.debugging_opts.show_span.is_some() ||
if sess.opts.debugging_opts.parse_only ||
sess.opts.debugging_opts.show_span.is_some() ||
sess.opts.debugging_opts.ast_json_noexpand {
control.after_parse.stop = Compilation::Stop;
}
if sess.opts.no_analysis || sess.opts.debugging_opts.ast_json {
if sess.opts.debugging_opts.no_analysis ||
sess.opts.debugging_opts.ast_json {
control.after_hir_lowering.stop = Compilation::Stop;
}
......
......@@ -400,7 +400,7 @@ fn find_library_crate(&mut self) -> Option<Library> {
if self.hash.is_none() {
self.should_match_name = false;
if let Some(s) = self.sess.opts.externs.get(self.crate_name) {
return self.find_commandline_library(s);
return self.find_commandline_library(s.iter());
}
self.should_match_name = true;
}
......@@ -661,7 +661,9 @@ fn staticlibname(&self) -> (String, String) {
(t.options.staticlib_prefix.clone(), t.options.staticlib_suffix.clone())
}
fn find_commandline_library(&mut self, locs: &[String]) -> Option<Library> {
fn find_commandline_library<'b, LOCS> (&mut self, locs: LOCS) -> Option<Library>
where LOCS: Iterator<Item=&'b String>
{
// First, filter out all libraries that look suspicious. We only accept
// files which actually exist that have the correct naming scheme for
// rlibs/dylibs.
......@@ -670,7 +672,7 @@ fn find_commandline_library(&mut self, locs: &[String]) -> Option<Library> {
let mut rlibs = HashMap::new();
let mut dylibs = HashMap::new();
{
let locs = locs.iter().map(|l| PathBuf::from(l)).filter(|loc| {
let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| {
if !loc.exists() {
sess.err(&format!("extern location for {} does not exist: {}",
self.crate_name, loc.display()));
......
......@@ -190,7 +190,8 @@ pub fn link_binary(sess: &Session,
let mut out_filenames = Vec::new();
for &crate_type in sess.crate_types.borrow().iter() {
// Ignore executable crates if we have -Z no-trans, as they will error.
if sess.opts.no_trans && crate_type == config::CrateTypeExecutable {
if sess.opts.debugging_opts.no_trans &&
crate_type == config::CrateTypeExecutable {
continue;
}
......
......@@ -11,7 +11,7 @@
use back::lto;
use back::link::{get_linker, remove};
use rustc_incremental::save_trans_partition;
use session::config::{OutputFilenames, Passes, SomePasses, AllPasses};
use session::config::{OutputFilenames, OutputTypes, Passes, SomePasses, AllPasses};
use session::Session;
use session::config::{self, OutputType};
use llvm;
......@@ -26,7 +26,6 @@
use syntax_pos::MultiSpan;
use context::{is_pie_binary, get_reloc_model};
use std::collections::HashMap;
use std::ffi::{CStr, CString};
use std::fs;
use std::path::{Path, PathBuf};
......@@ -641,7 +640,7 @@ pub fn cleanup_llvm(trans: &CrateTranslation) {
pub fn run_passes(sess: &Session,
trans: &CrateTranslation,
output_types: &HashMap<OutputType, Option<PathBuf>>,
output_types: &OutputTypes,
crate_output: &OutputFilenames) {
// It's possible that we have `codegen_units > 1` but only one item in
// `trans.modules`. We could theoretically proceed and do LTO in that
......
......@@ -2569,7 +2569,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
assert_module_sources::assert_module_sources(tcx, &modules);
// Skip crate items and just output metadata in -Z no-trans mode.
if tcx.sess.opts.no_trans {
if tcx.sess.opts.debugging_opts.no_trans {
let linker_info = LinkerInfo::new(&shared_ccx, &[]);
return CrateTranslation {
modules: modules,
......
......@@ -45,7 +45,6 @@ pub enum MaybeTyped<'a, 'tcx: 'a> {
NotTyped(&'a session::Session)
}
pub type Externs = HashMap<String, Vec<String>>;
pub type ExternalPaths = HashMap<DefId, (Vec<String>, clean::TypeKind)>;
pub struct DocContext<'a, 'tcx: 'a> {
......@@ -99,7 +98,7 @@ fn is_doc_reachable(&self, did: DefId) -> bool {
pub fn run_core(search_paths: SearchPaths,
cfgs: Vec<String>,
externs: Externs,
externs: config::Externs,
input: Input,
triple: Option<String>) -> (clean::Crate, RenderInfo)
{
......
......@@ -51,7 +51,7 @@
extern crate serialize as rustc_serialize; // used by deriving
use std::collections::HashMap;
use std::collections::{BTreeMap, BTreeSet};
use std::default::Default;
use std::env;
use std::path::PathBuf;
......@@ -60,7 +60,8 @@
use externalfiles::ExternalHtml;
use rustc::session::search_paths::SearchPaths;
use rustc::session::config::{ErrorOutputType, RustcOptGroup, nightly_options};
use rustc::session::config::{ErrorOutputType, RustcOptGroup, nightly_options,
Externs};
#[macro_use]
pub mod externalfiles;
......@@ -323,7 +324,7 @@ pub fn main_args(args: &[String]) -> isize {
/// Looks inside the command line arguments to extract the relevant input format
/// and files and then generates the necessary rustdoc output for formatting.
fn acquire_input(input: &str,
externs: core::Externs,
externs: Externs,
matches: &getopts::Matches) -> Result<Output, String> {
match matches.opt_str("r").as_ref().map(|s| &**s) {
Some("rust") => Ok(rust_input(input, externs, matches)),
......@@ -335,10 +336,10 @@ fn acquire_input(input: &str,
}
/// Extracts `--extern CRATE=PATH` arguments from `matches` and
/// returns a `HashMap` mapping crate names to their paths or else an
/// returns a map mapping crate names to their paths or else an
/// error message.
fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
let mut externs = HashMap::new();
fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
let mut externs = BTreeMap::new();
for arg in &matches.opt_strs("extern") {
let mut parts = arg.splitn(2, '=');
let name = parts.next().ok_or("--extern value must not be empty".to_string())?;
......@@ -346,9 +347,9 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
.ok_or("--extern value must be of the format `foo=bar`"
.to_string())?;
let name = name.to_string();
externs.entry(name).or_insert(vec![]).push(location.to_string());
externs.entry(name).or_insert_with(BTreeSet::new).insert(location.to_string());
}
Ok(externs)
Ok(Externs::new(externs))
}
/// Interprets the input file as a rust source file, passing it through the
......@@ -356,7 +357,7 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
/// generated from the cleaned AST of the crate.
///
/// This form of input will run all of the plug/cleaning passes
fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matches) -> Output {
fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) -> Output {
let mut default_passes = !matches.opt_present("no-defaults");
let mut passes = matches.opt_strs("passes");
let mut plugins = matches.opt_strs("plugins");
......
......@@ -14,10 +14,10 @@
use std::io;
use std::path::{PathBuf, Path};
use core;
use getopts;
use testing;
use rustc::session::search_paths::SearchPaths;
use rustc::session::config::Externs;
use externalfiles::ExternalHtml;
......@@ -142,7 +142,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
}
/// Run any tests/code examples in the markdown file `input`.
pub fn test(input: &str, cfgs: Vec<String>, libs: SearchPaths, externs: core::Externs,
pub fn test(input: &str, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
mut test_args: Vec<String>) -> isize {
let input_str = load_or_return!(input, 1, 2);
......
......@@ -26,7 +26,8 @@
use rustc::dep_graph::DepGraph;
use rustc::hir::map as hir_map;
use rustc::session::{self, config};
use rustc::session::config::{get_unstable_features_setting, OutputType};
use rustc::session::config::{get_unstable_features_setting, OutputType,
OutputTypes, Externs};
use rustc::session::search_paths::{SearchPaths, PathKind};
use rustc_back::dynamic_lib::DynamicLibrary;
use rustc_back::tempdir::TempDir;
......@@ -55,7 +56,7 @@ pub struct TestOptions {
pub fn run(input: &str,
cfgs: Vec<String>,
libs: SearchPaths,
externs: core::Externs,
externs: Externs,
mut test_args: Vec<String>,
crate_name: Option<String>)
-> isize {
......@@ -172,7 +173,7 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions {
}
fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
externs: core::Externs,
externs: Externs,
should_panic: bool, no_run: bool, as_test_harness: bool,
compile_fail: bool, mut error_codes: Vec<String>, opts: &TestOptions) {
// the test harness wants its own `main` & top level functions, so
......@@ -182,8 +183,7 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
name: driver::anon_src(),
input: test.to_owned(),
};
let mut outputs = HashMap::new();
outputs.insert(OutputType::Exe, None);
let outputs = OutputTypes::new(&[(OutputType::Exe, None)]);
let sessopts = config::Options {
maybe_sysroot: Some(env::current_exe().unwrap().parent().unwrap()
......@@ -396,7 +396,7 @@ pub struct Collector {
names: Vec<String>,
cfgs: Vec<String>,
libs: SearchPaths,
externs: core::Externs,
externs: Externs,
cnt: usize,
use_headers: bool,
current_header: Option<String>,
......@@ -405,7 +405,7 @@ pub struct Collector {
}
impl Collector {
pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, externs: core::Externs,
pub fn new(cratename: String, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
use_headers: bool, opts: TestOptions) -> Collector {
Collector {
tests: Vec::new(),
......
......@@ -1171,7 +1171,7 @@ pub fn check_crate(krate: &ast::Crate,
visit::walk_crate(&mut PostExpansionVisitor { context: &ctx }, krate);
}
#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub enum UnstableFeatures {
/// Hard errors for unstable features are active, as on
/// beta/stable channels.
......
......@@ -19,7 +19,8 @@
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册