Skip to content

Commit 2a50d12

Browse files
incr.comp.: Remove support for loading metadata fingerprints.
1 parent 5974ec7 commit 2a50d12

File tree

17 files changed

+105
-308
lines changed

17 files changed

+105
-308
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! user of the `DepNode` API of having to know how to compute the expected
6161
//! fingerprint for a given set of node parameters.
6262
63-
use hir::def_id::{CrateNum, DefId, DefIndex};
63+
use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
6464
use hir::map::DefPathHash;
6565
use hir::{HirId, ItemLocalId};
6666

@@ -420,7 +420,7 @@ define_dep_nodes!( <'tcx>
420420
[input] Hir(DefId),
421421

422422
// Represents metadata from an extern crate.
423-
[input] MetaData(DefId),
423+
[input] CrateMetadata(CrateNum),
424424

425425
// Represents some artifact that we save to disk. Note that these
426426
// do not have a def-id as part of their identifier.
@@ -678,6 +678,22 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIndex,
678678
}
679679
}
680680

681+
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (CrateNum,) {
682+
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
683+
684+
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
685+
let def_id = DefId {
686+
krate: self.0,
687+
index: CRATE_DEF_INDEX,
688+
};
689+
tcx.def_path_hash(def_id).0
690+
}
691+
692+
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
693+
tcx.crate_name(self.0).as_str().to_string()
694+
}
695+
}
696+
681697
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, DefId) {
682698
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
683699

src/librustc/middle/cstore.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ pub trait CrateStore {
267267
fn export_macros_untracked(&self, cnum: CrateNum);
268268
fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind;
269269
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol;
270+
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> Symbol;
271+
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;
270272
fn struct_field_names_untracked(&self, def: DefId) -> Vec<ast::Name>;
271273
fn item_children_untracked(&self, did: DefId, sess: &Session) -> Vec<def::Export>;
272274
fn load_macro_untracked(&self, did: DefId, sess: &Session) -> LoadedMacro;
@@ -336,6 +338,10 @@ impl CrateStore for DummyCrateStore {
336338
fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
337339
fn export_macros_untracked(&self, cnum: CrateNum) { bug!("export_macros") }
338340
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") }
341+
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> Symbol {
342+
bug!("crate_disambiguator")
343+
}
344+
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
339345

340346
// resolve
341347
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }

src/librustc/session/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10211021
"attempt to recover from parse errors (experimental)"),
10221022
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
10231023
"enable incremental compilation (experimental)"),
1024-
incremental_cc: bool = (true, parse_bool, [UNTRACKED],
1024+
incremental_cc: bool = (false, parse_bool, [UNTRACKED],
10251025
"enable cross-crate incremental compilation (even more experimental)"),
10261026
incremental_info: bool = (false, parse_bool, [UNTRACKED],
10271027
"print high-level information about incremental reuse (or the lack thereof)"),

src/librustc/ty/context.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! type context book-keeping
1212
1313
use dep_graph::DepGraph;
14+
use dep_graph::{DepNode, DepConstructor};
1415
use errors::DiagnosticBuilder;
1516
use session::Session;
1617
use session::config::OutputFilenames;
@@ -1237,6 +1238,25 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12371238
self.cstore)
12381239
}
12391240

1241+
// This method makes sure that we have a DepNode and a Fingerprint for
1242+
// every upstream crate. It needs to be called once right after the tcx is
1243+
// created.
1244+
// With full-fledged red/green, the method will probably become unnecessary
1245+
// as this will be done on-demand.
1246+
pub fn allocate_metadata_dep_nodes(self) {
1247+
// We cannot use the query versions of crates() and crate_hash(), since
1248+
// those would need the DepNodes that we are allocating here.
1249+
for cnum in self.cstore.crates_untracked() {
1250+
let dep_node = DepNode::new(self, DepConstructor::CrateMetadata(cnum));
1251+
let crate_hash = self.cstore.crate_hash_untracked(cnum);
1252+
self.dep_graph.with_task(dep_node,
1253+
self,
1254+
crate_hash,
1255+
|_, x| x // No transformation needed
1256+
);
1257+
}
1258+
}
1259+
12401260
// This method exercises the `in_scope_traits_map` query for all possible
12411261
// values so that we have their fingerprints available in the DepGraph.
12421262
// This is only required as long as we still use the old dependency tracking

src/librustc_incremental/persist/fs.rs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,12 @@
114114
//! unsupported file system and emit a warning in that case. This is not yet
115115
//! implemented.
116116
117-
use rustc::hir::def_id::CrateNum;
118117
use rustc::hir::svh::Svh;
119118
use rustc::session::Session;
120-
use rustc::ty::TyCtxt;
121119
use rustc::util::fs as fs_util;
122120
use rustc_data_structures::{flock, base_n};
123121
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
124122

125-
use std::ffi::OsString;
126123
use std::fs as std_fs;
127124
use std::io;
128125
use std::mem;
@@ -158,10 +155,6 @@ pub fn metadata_hash_export_path(sess: &Session) -> PathBuf {
158155
in_incr_comp_dir_sess(sess, METADATA_HASHES_FILENAME)
159156
}
160157

161-
pub fn metadata_hash_import_path(import_session_dir: &Path) -> PathBuf {
162-
import_session_dir.join(METADATA_HASHES_FILENAME)
163-
}
164-
165158
pub fn lock_file_path(session_dir: &Path) -> PathBuf {
166159
let crate_dir = session_dir.parent().unwrap();
167160

@@ -621,70 +614,6 @@ fn string_to_timestamp(s: &str) -> Result<SystemTime, ()> {
621614
Ok(UNIX_EPOCH + duration)
622615
}
623616

624-
fn crate_path_tcx(tcx: TyCtxt, cnum: CrateNum) -> PathBuf {
625-
crate_path(tcx.sess, &tcx.crate_name(cnum).as_str(), &tcx.crate_disambiguator(cnum).as_str())
626-
}
627-
628-
/// Finds the session directory containing the correct metadata hashes file for
629-
/// the given crate. In order to do that it has to compute the crate directory
630-
/// of the given crate, and in there, look for the session directory with the
631-
/// correct SVH in it.
632-
/// Note that we have to match on the exact SVH here, not just the
633-
/// crate's (name, disambiguator) pair. The metadata hashes are only valid for
634-
/// the exact version of the binary we are reading from now (i.e. the hashes
635-
/// are part of the dependency graph of a specific compilation session).
636-
pub fn find_metadata_hashes_for(tcx: TyCtxt, cnum: CrateNum) -> Option<PathBuf> {
637-
let crate_directory = crate_path_tcx(tcx, cnum);
638-
639-
if !crate_directory.exists() {
640-
return None
641-
}
642-
643-
let dir_entries = match crate_directory.read_dir() {
644-
Ok(dir_entries) => dir_entries,
645-
Err(e) => {
646-
tcx.sess
647-
.err(&format!("incremental compilation: Could not read crate directory `{}`: {}",
648-
crate_directory.display(), e));
649-
return None
650-
}
651-
};
652-
653-
let target_svh = tcx.crate_hash(cnum);
654-
let target_svh = base_n::encode(target_svh.as_u64(), INT_ENCODE_BASE);
655-
656-
let sub_dir = find_metadata_hashes_iter(&target_svh, dir_entries.filter_map(|e| {
657-
e.ok().map(|e| e.file_name().to_string_lossy().into_owned())
658-
}));
659-
660-
sub_dir.map(|sub_dir_name| crate_directory.join(&sub_dir_name))
661-
}
662-
663-
fn find_metadata_hashes_iter<'a, I>(target_svh: &str, iter: I) -> Option<OsString>
664-
where I: Iterator<Item=String>
665-
{
666-
for sub_dir_name in iter {
667-
if !is_session_directory(&sub_dir_name) || !is_finalized(&sub_dir_name) {
668-
// This is not a usable session directory
669-
continue
670-
}
671-
672-
let is_match = if let Some(last_dash_pos) = sub_dir_name.rfind("-") {
673-
let candidate_svh = &sub_dir_name[last_dash_pos + 1 .. ];
674-
target_svh == candidate_svh
675-
} else {
676-
// some kind of invalid directory name
677-
continue
678-
};
679-
680-
if is_match {
681-
return Some(OsString::from(sub_dir_name))
682-
}
683-
}
684-
685-
None
686-
}
687-
688617
fn crate_path(sess: &Session,
689618
crate_name: &str,
690619
crate_disambiguator: &str)

0 commit comments

Comments
 (0)