diff --git a/src/Cargo.lock b/src/Cargo.lock index 476b33b372d..45396a45a4c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1785,7 +1785,6 @@ dependencies = [ "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_back 0.0.0", - "rustc_incremental 0.0.0", "syntax 0.0.0", "syntax_pos 0.0.0", ] diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 154e54f92a8..ec4cec331d0 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -94,6 +94,8 @@ use syntax::ast; use mir::lvalue::Alignment; +pub use rustc_trans_utils::find_exported_symbols; + pub struct StatRecorder<'a, 'tcx: 'a> { ccx: &'a CrateContext<'a, 'tcx>, name: Option, @@ -887,7 +889,6 @@ fn iter_globals(llmod: llvm::ModuleRef) -> ValueIter { pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, rx: mpsc::Receiver>) -> OngoingCrateTranslation { - use rustc_trans_utils::find_exported_symbols; check_for_rustc_errors_attr(tcx); diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 13c3ce69248..8a2c478cea0 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -138,12 +138,13 @@ mod type_; mod type_of; mod value; -use rustc::ty::{self, TyCtxt, CrateAnalysis}; +use std::sync::mpsc; +use std::any::Any; +use rustc::ty::{self, TyCtxt}; use rustc::session::Session; use rustc::session::config::OutputFilenames; use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; -use rustc_incremental::IncrementalHashesMap; pub struct LlvmTransCrate(()); @@ -162,17 +163,19 @@ impl rustc_trans_utils::trans_crate::TransCrate for LlvmTransCrate { box metadata::LlvmMetadataLoader } - fn provide(providers: &mut ty::maps::Providers) { - back::symbol_names::provide(providers); + fn provide_local(providers: &mut ty::maps::Providers) { + provide_local(providers); + } + + fn provide_extern(providers: &mut ty::maps::Providers) { + provide_extern(providers); } fn trans_crate<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - analysis: CrateAnalysis, - incr_hashes_map: IncrementalHashesMap, - output_filenames: &OutputFilenames + rx: mpsc::Receiver> ) -> Self::OngoingCrateTranslation { - base::trans_crate(tcx, analysis, incr_hashes_map, output_filenames) + base::trans_crate(tcx, rx) } fn join_trans( diff --git a/src/librustc_trans_utils/Cargo.toml b/src/librustc_trans_utils/Cargo.toml index 2a4a27dd892..bedbea00688 100644 --- a/src/librustc_trans_utils/Cargo.toml +++ b/src/librustc_trans_utils/Cargo.toml @@ -19,4 +19,3 @@ syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } -rustc_incremental = { path = "../librustc_incremental" } diff --git a/src/librustc_trans_utils/lib.rs b/src/librustc_trans_utils/lib.rs index 06500e944ca..1de3175e2fc 100644 --- a/src/librustc_trans_utils/lib.rs +++ b/src/librustc_trans_utils/lib.rs @@ -38,12 +38,12 @@ extern crate log; #[macro_use] extern crate rustc; extern crate rustc_back; -extern crate rustc_incremental; extern crate syntax; extern crate syntax_pos; use rustc::ty::TyCtxt; use rustc::hir; +use rustc::hir::def_id::LOCAL_CRATE; use rustc::hir::map as hir_map; use rustc::util::nodemap::NodeSet; @@ -60,8 +60,8 @@ pub mod trans_crate; /// /// This list is later used by linkers to determine the set of symbols needed to /// be exposed from a dynamic library and it's also encoded into the metadata. -pub fn find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet { - reachable.iter().cloned().filter(|&id| { +pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet { + tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| { // Next, we want to ignore some FFI functions that are not exposed from // this crate. Reachable FFI functions can be lumped into two // categories: diff --git a/src/librustc_trans_utils/link.rs b/src/librustc_trans_utils/link.rs index ccd5739efe0..47484488fb8 100644 --- a/src/librustc_trans_utils/link.rs +++ b/src/librustc_trans_utils/link.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use rustc::ich::Fingerprint; use rustc::session::config::{self, OutputFilenames, Input, OutputType}; use rustc::session::Session; use rustc::middle::cstore::{self, LinkMeta}; -use rustc::dep_graph::{DepKind, DepNode}; use rustc::hir::svh::Svh; -use rustc_incremental::IncrementalHashesMap; use std::path::{Path, PathBuf}; use syntax::ast; use syntax_pos::Span; @@ -51,10 +50,9 @@ fn is_writeable(p: &Path) -> bool { } } -pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta { - let krate_dep_node = &DepNode::new_no_params(DepKind::Krate); +pub fn build_link_meta(crate_hash: Fingerprint) -> LinkMeta { let r = LinkMeta { - crate_hash: Svh::new(incremental_hashes_map[krate_dep_node].to_smaller_hash()), + crate_hash: Svh::new(crate_hash.to_smaller_hash()), }; info!("{:?}", r); return r; diff --git a/src/librustc_trans_utils/trans_crate.rs b/src/librustc_trans_utils/trans_crate.rs index df85fae2cb6..d8f87ee834c 100644 --- a/src/librustc_trans_utils/trans_crate.rs +++ b/src/librustc_trans_utils/trans_crate.rs @@ -21,10 +21,12 @@ #![feature(box_syntax)] +use std::any::Any; use std::io::prelude::*; use std::io::{self, Cursor}; use std::fs::File; use std::path::Path; +use std::sync::mpsc; use owning_ref::{ErasedBoxRef, OwningRef}; use ar::{Archive, Builder, Header}; @@ -35,13 +37,12 @@ use syntax::symbol::Symbol; use rustc::hir::def_id::LOCAL_CRATE; use rustc::session::Session; use rustc::session::config::{CrateType, OutputFilenames}; -use rustc::ty::{CrateAnalysis, TyCtxt}; +use rustc::ty::TyCtxt; use rustc::ty::maps::Providers; use rustc::middle::cstore::EncodedMetadata; use rustc::middle::cstore::MetadataLoader as MetadataLoaderTrait; -use rustc::dep_graph::DepGraph; +use rustc::dep_graph::{DepGraph, DepNode, DepKind}; use rustc_back::target::Target; -use rustc_incremental::IncrementalHashesMap; use link::{build_link_meta, out_filename}; pub trait TransCrate { @@ -50,12 +51,11 @@ pub trait TransCrate { type TranslatedCrate; fn metadata_loader() -> Box; - fn provide(_providers: &mut Providers); + fn provide_local(_providers: &mut Providers); + fn provide_extern(_providers: &mut Providers); fn trans_crate<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - analysis: CrateAnalysis, - incr_hashes_map: IncrementalHashesMap, - output_filenames: &OutputFilenames + rx: mpsc::Receiver> ) -> Self::OngoingCrateTranslation; fn join_trans( trans: Self::OngoingCrateTranslation, @@ -77,15 +77,17 @@ impl TransCrate for DummyTransCrate { box DummyMetadataLoader(()) } - fn provide(_providers: &mut Providers) { - bug!("DummyTransCrate::provide"); + fn provide_local(_providers: &mut Providers) { + bug!("DummyTransCrate::provide_local"); + } + + fn provide_extern(_providers: &mut Providers) { + bug!("DummyTransCrate::provide_extern"); } fn trans_crate<'a, 'tcx>( _tcx: TyCtxt<'a, 'tcx, 'tcx>, - _analysis: CrateAnalysis, - _incr_hashes_map: IncrementalHashesMap, - _output_filenames: &OutputFilenames + _rx: mpsc::Receiver> ) -> Self::OngoingCrateTranslation { bug!("DummyTransCrate::trans_crate"); } @@ -176,16 +178,18 @@ impl TransCrate for MetadataOnlyTransCrate { box NoLlvmMetadataLoader } - fn provide(_providers: &mut Providers) {} + fn provide_local(_providers: &mut Providers) {} + fn provide_extern(_providers: &mut Providers) {} fn trans_crate<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - analysis: CrateAnalysis, - incr_hashes_map: IncrementalHashesMap, - _output_filenames: &OutputFilenames, + _rx: mpsc::Receiver> ) -> Self::OngoingCrateTranslation { - let link_meta = build_link_meta(&incr_hashes_map); - let exported_symbols = ::find_exported_symbols(tcx, &analysis.reachable); + let crate_hash = tcx.dep_graph + .fingerprint_of(&DepNode::new_no_params(DepKind::Krate)) + .unwrap(); + let link_meta = build_link_meta(crate_hash); + let exported_symbols = ::find_exported_symbols(tcx); let (metadata, _hashes) = tcx.encode_metadata(&link_meta, &exported_symbols); OngoingCrateTranslation {