summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_incremental
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_incremental')
-rw-r--r--compiler/rustc_incremental/Cargo.toml1
-rw-r--r--compiler/rustc_incremental/messages.ftl140
-rw-r--r--compiler/rustc_incremental/src/lib.rs2
-rw-r--r--compiler/rustc_incremental/src/persist/dirty_clean.rs2
-rw-r--r--compiler/rustc_incremental/src/persist/file_format.rs35
-rw-r--r--compiler/rustc_incremental/src/persist/fs.rs4
-rw-r--r--compiler/rustc_incremental/src/persist/load.rs42
-rw-r--r--compiler/rustc_incremental/src/persist/save.rs4
8 files changed, 118 insertions, 112 deletions
diff --git a/compiler/rustc_incremental/Cargo.toml b/compiler/rustc_incremental/Cargo.toml
index ad8939395..59a0623c1 100644
--- a/compiler/rustc_incremental/Cargo.toml
+++ b/compiler/rustc_incremental/Cargo.toml
@@ -11,6 +11,7 @@ rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fs_util = { path = "../rustc_fs_util" }
+rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hir = { path = "../rustc_hir" }
rustc_macros = { path = "../rustc_macros" }
diff --git a/compiler/rustc_incremental/messages.ftl b/compiler/rustc_incremental/messages.ftl
index b760620e3..9fa4e0fb2 100644
--- a/compiler/rustc_incremental/messages.ftl
+++ b/compiler/rustc_incremental/messages.ftl
@@ -1,118 +1,118 @@
-incremental_unrecognized_depnode = unrecognized `DepNode` variant: {$name}
+incremental_assert_loaded =
+ we asserted that an existing incremental cache directory should be successfully loaded, but it was not
-incremental_missing_depnode = missing `DepNode` variant
+incremental_assert_not_loaded =
+ we asserted that the incremental cache should not be loaded, but it was loaded
-incremental_missing_if_this_changed = no `#[rustc_if_this_changed]` annotation detected
+incremental_assertion_auto =
+ `except` specified DepNodes that can not be affected for "{$name}": "{$e}"
-incremental_no_path = no path from `{$source}` to `{$target}`
+incremental_associated_value_expected = expected an associated value
-incremental_ok = OK
+incremental_associated_value_expected_for = associated value expected for `{$ident}`
-incremental_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
+incremental_canonicalize_path = incremental compilation: error canonicalizing path `{$path}`: {$err}
-incremental_missing_query_depgraph =
- found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
+incremental_cargo_help_1 =
+ incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
+incremental_cargo_help_2 =
+ the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)
-incremental_malformed_cgu_name =
- found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
+incremental_copy_workproduct_to_cache =
+ error copying object file `{$from}` to incremental directory as `{$to}`: {$err}
-incremental_no_module_named =
- no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
+incremental_create_dep_graph = failed to create dependency graph at `{$path}`: {$err}
-incremental_field_associated_value_expected = associated value expected for `{$name}`
+incremental_create_incr_comp_dir =
+ could not create incremental compilation {$tag} directory `{$path}`: {$err}
-incremental_no_field = no field `{$name}`
+incremental_create_lock =
+ incremental compilation: could not create session directory lock file: {$lock_err}
+incremental_create_new = failed to create {$name} at `{$path}`: {$err}
-incremental_assertion_auto =
- `except` specified DepNodes that can not be affected for "{$name}": "{$e}"
+incremental_decode_incr_cache = could not decode incremental cache: {$err}
-incremental_undefined_clean_dirty_assertions_item =
- clean/dirty auto-assertions not yet defined for Node::Item.node={$kind}
+incremental_delete_full = error deleting incremental compilation session directory `{$path}`: {$err}
-incremental_undefined_clean_dirty_assertions =
- clean/dirty auto-assertions not yet defined for {$kind}
+incremental_delete_incompatible =
+ failed to delete invalidated or incompatible incremental compilation session directory contents `{$path}`: {$err}
-incremental_repeated_depnode_label = dep-node label `{$label}` is repeated
+incremental_delete_lock =
+ error deleting lock file for incremental compilation session directory `{$path}`: {$err}
-incremental_unrecognized_depnode_label = dep-node label `{$label}` not recognized
+incremental_delete_old = unable to delete old {$name} at `{$path}`: {$err}
-incremental_not_dirty = `{$dep_node_str}` should be dirty but is not
+incremental_delete_partial = failed to delete partly initialized session dir `{$path}`: {$err}
-incremental_not_clean = `{$dep_node_str}` should be clean but is not
+incremental_delete_workproduct = file-system error deleting outdated file `{$path}`: {$err}
-incremental_not_loaded = `{$dep_node_str}` should have been loaded from disk but it was not
+incremental_field_associated_value_expected = associated value expected for `{$name}`
-incremental_unknown_item = unknown item `{$name}`
+incremental_finalize = error finalizing incremental compilation session directory `{$path}`: {$err}
-incremental_no_cfg = no cfg attribute
+incremental_finalized_gc_failed =
+ failed to garbage collect finalized incremental compilation session directory `{$path}`: {$err}
-incremental_associated_value_expected_for = associated value expected for `{$ident}`
+incremental_hard_link_failed =
+ hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `{$path}`
-incremental_associated_value_expected = expected an associated value
+incremental_invalid_gc_failed =
+ failed to garbage collect invalid incremental compilation session directory `{$path}`: {$err}
-incremental_unchecked_clean = found unchecked `#[rustc_clean]` attribute
+incremental_load_dep_graph = could not load dep-graph from `{$path}`: {$err}
-incremental_delete_old = unable to delete old {$name} at `{$path}`: {$err}
+incremental_lock_unsupported =
+ the filesystem for the incremental path at {$session_dir} does not appear to support locking, consider changing the incremental path to a filesystem that supports locking or disable incremental compilation
+incremental_malformed_cgu_name =
+ found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
-incremental_create_new = failed to create {$name} at `{$path}`: {$err}
+incremental_missing_depnode = missing `DepNode` variant
-incremental_write_new = failed to write {$name} to `{$path}`: {$err}
+incremental_missing_if_this_changed = no `#[rustc_if_this_changed]` annotation detected
-incremental_canonicalize_path = incremental compilation: error canonicalizing path `{$path}`: {$err}
+incremental_missing_query_depgraph =
+ found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
-incremental_create_incr_comp_dir =
- could not create incremental compilation {$tag} directory `{$path}`: {$err}
+incremental_move_dep_graph = failed to move dependency graph from `{$from}` to `{$to}`: {$err}
-incremental_create_lock =
- incremental compilation: could not create session directory lock file: {$lock_err}
-incremental_lock_unsupported =
- the filesystem for the incremental path at {$session_dir} does not appear to support locking, consider changing the incremental path to a filesystem that supports locking or disable incremental compilation
-incremental_cargo_help_1 =
- incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
-incremental_cargo_help_2 =
- the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)
+incremental_no_cfg = no cfg attribute
-incremental_delete_lock =
- error deleting lock file for incremental compilation session directory `{$path}`: {$err}
+incremental_no_field = no field `{$name}`
-incremental_hard_link_failed =
- hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `{$path}`
+incremental_no_module_named =
+ no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
-incremental_delete_partial = failed to delete partly initialized session dir `{$path}`: {$err}
+incremental_no_path = no path from `{$source}` to `{$target}`
-incremental_delete_full = error deleting incremental compilation session directory `{$path}`: {$err}
+incremental_not_clean = `{$dep_node_str}` should be clean but is not
-incremental_finalize = error finalizing incremental compilation session directory `{$path}`: {$err}
+incremental_not_dirty = `{$dep_node_str}` should be dirty but is not
-incremental_invalid_gc_failed =
- failed to garbage collect invalid incremental compilation session directory `{$path}`: {$err}
+incremental_not_loaded = `{$dep_node_str}` should have been loaded from disk but it was not
-incremental_finalized_gc_failed =
- failed to garbage collect finalized incremental compilation session directory `{$path}`: {$err}
+incremental_ok = OK
+
+incremental_repeated_depnode_label = dep-node label `{$label}` is repeated
incremental_session_gc_failed =
failed to garbage collect incremental compilation session directory `{$path}`: {$err}
-incremental_assert_not_loaded =
- we asserted that the incremental cache should not be loaded, but it was loaded
-
-incremental_assert_loaded =
- we asserted that an existing incremental cache directory should be successfully loaded, but it was not
+incremental_unchecked_clean = found unchecked `#[rustc_clean]` attribute
-incremental_delete_incompatible =
- failed to delete invalidated or incompatible incremental compilation session directory contents `{$path}`: {$err}
+incremental_undefined_clean_dirty_assertions =
+ clean/dirty auto-assertions not yet defined for {$kind}
-incremental_load_dep_graph = could not load dep-graph from `{$path}`: {$err}
+incremental_undefined_clean_dirty_assertions_item =
+ clean/dirty auto-assertions not yet defined for Node::Item.node={$kind}
-incremental_decode_incr_cache = could not decode incremental cache: {$err}
+incremental_unknown_item = unknown item `{$name}`
-incremental_write_dep_graph = failed to write dependency graph to `{$path}`: {$err}
+incremental_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
-incremental_move_dep_graph = failed to move dependency graph from `{$from}` to `{$to}`: {$err}
+incremental_unrecognized_depnode = unrecognized `DepNode` variant: {$name}
-incremental_create_dep_graph = failed to create dependency graph at `{$path}`: {$err}
+incremental_unrecognized_depnode_label = dep-node label `{$label}` not recognized
-incremental_copy_workproduct_to_cache =
- error copying object file `{$from}` to incremental directory as `{$to}`: {$err}
+incremental_write_dep_graph = failed to write dependency graph to `{$path}`: {$err}
-incremental_delete_workproduct = file-system error deleting outdated file `{$path}`: {$err}
+incremental_write_new = failed to write {$name} to `{$path}`: {$err}
diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs
index df958e4a6..11710c368 100644
--- a/compiler/rustc_incremental/src/lib.rs
+++ b/compiler/rustc_incremental/src/lib.rs
@@ -33,6 +33,6 @@ pub use persist::LoadResult;
pub use persist::{build_dep_graph, load_dep_graph, DepGraphFuture};
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
-use rustc_macros::fluent_messages;
+use rustc_fluent_macro::fluent_messages;
fluent_messages! { "../messages.ftl" }
diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs
index 1d88dfd20..43274091c 100644
--- a/compiler/rustc_incremental/src/persist/dirty_clean.rs
+++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs
@@ -139,7 +139,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
return;
}
- // can't add `#[rustc_clean]` etc without opting in to this feature
+ // can't add `#[rustc_clean]` etc without opting into this feature
if !tcx.features().rustc_attrs {
return;
}
diff --git a/compiler/rustc_incremental/src/persist/file_format.rs b/compiler/rustc_incremental/src/persist/file_format.rs
index dc981c617..25bf83f64 100644
--- a/compiler/rustc_incremental/src/persist/file_format.rs
+++ b/compiler/rustc_incremental/src/persist/file_format.rs
@@ -14,6 +14,7 @@ use rustc_data_structures::memmap::Mmap;
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
use rustc_serialize::Encoder;
use rustc_session::Session;
+use std::borrow::Cow;
use std::env;
use std::fs;
use std::io::{self, Read};
@@ -25,17 +26,12 @@ const FILE_MAGIC: &[u8] = b"RSIC";
/// Change this if the header format changes.
const HEADER_FORMAT_VERSION: u16 = 0;
-/// A version string that hopefully is always different for compiler versions
-/// with different encodings of incremental compilation artifacts. Contains
-/// the Git commit hash.
-const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
-
-pub(crate) fn write_file_header(stream: &mut FileEncoder, nightly_build: bool) {
+pub(crate) fn write_file_header(stream: &mut FileEncoder, sess: &Session) {
stream.emit_raw_bytes(FILE_MAGIC);
stream
.emit_raw_bytes(&[(HEADER_FORMAT_VERSION >> 0) as u8, (HEADER_FORMAT_VERSION >> 8) as u8]);
- let rustc_version = rustc_version(nightly_build);
+ let rustc_version = rustc_version(sess.is_nightly_build(), sess.cfg_version);
assert_eq!(rustc_version.len(), (rustc_version.len() as u8) as usize);
stream.emit_raw_bytes(&[rustc_version.len() as u8]);
stream.emit_raw_bytes(rustc_version.as_bytes());
@@ -73,7 +69,7 @@ where
}
};
- write_file_header(&mut encoder, sess.is_nightly_build());
+ write_file_header(&mut encoder, sess);
match encode(encoder) {
Ok(position) => {
@@ -100,9 +96,10 @@ where
/// - Returns `Err(..)` if some kind of IO error occurred while reading the
/// file.
pub fn read_file(
- report_incremental_info: bool,
path: &Path,
- nightly_build: bool,
+ report_incremental_info: bool,
+ is_nightly_build: bool,
+ cfg_version: &'static str,
) -> io::Result<Option<(Mmap, usize)>> {
let file = match fs::File::open(path) {
Ok(file) => file,
@@ -152,7 +149,7 @@ pub fn read_file(
let mut buffer = vec![0; rustc_version_str_len];
file.read_exact(&mut buffer)?;
- if buffer != rustc_version(nightly_build).as_bytes() {
+ if buffer != rustc_version(is_nightly_build, cfg_version).as_bytes() {
report_format_mismatch(report_incremental_info, path, "Different compiler version");
return Ok(None);
}
@@ -174,17 +171,15 @@ fn report_format_mismatch(report_incremental_info: bool, file: &Path, message: &
}
}
-fn rustc_version(nightly_build: bool) -> String {
+/// A version string that hopefully is always different for compiler versions
+/// with different encodings of incremental compilation artifacts. Contains
+/// the Git commit hash.
+fn rustc_version(nightly_build: bool, cfg_version: &'static str) -> Cow<'static, str> {
if nightly_build {
- if let Some(val) = env::var_os("RUSTC_FORCE_RUSTC_VERSION") {
- return val.to_string_lossy().into_owned();
+ if let Ok(val) = env::var("RUSTC_FORCE_RUSTC_VERSION") {
+ return val.into();
}
}
- RUSTC_VERSION
- .expect(
- "Cannot use rustc without explicit version for \
- incremental compilation",
- )
- .to_string()
+ cfg_version.into()
}
diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs
index d6f83838a..e3c688b3e 100644
--- a/compiler/rustc_incremental/src/persist/fs.rs
+++ b/compiler/rustc_incremental/src/persist/fs.rs
@@ -346,7 +346,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
let mut new_sub_dir_name = String::from(&old_sub_dir_name[..=dash_indices[2]]);
// Append the svh
- base_n::push_str(svh.as_u64() as u128, INT_ENCODE_BASE, &mut new_sub_dir_name);
+ base_n::push_str(svh.as_u128(), INT_ENCODE_BASE, &mut new_sub_dir_name);
// Create the full path
let new_path = incr_comp_session_dir.parent().unwrap().join(new_sub_dir_name);
@@ -601,7 +601,7 @@ fn string_to_timestamp(s: &str) -> Result<SystemTime, ()> {
fn crate_path(sess: &Session, crate_name: Symbol, stable_crate_id: StableCrateId) -> PathBuf {
let incr_dir = sess.opts.incremental.as_ref().unwrap().clone();
- let stable_crate_id = base_n::encode(stable_crate_id.to_u64() as u128, INT_ENCODE_BASE);
+ let stable_crate_id = base_n::encode(stable_crate_id.as_u64() as u128, INT_ENCODE_BASE);
let crate_name = format!("{}-{}", crate_name, stable_crate_id);
incr_dir.join(crate_name)
diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs
index d5097065d..a4407a93f 100644
--- a/compiler/rustc_incremental/src/persist/load.rs
+++ b/compiler/rustc_incremental/src/persist/load.rs
@@ -4,7 +4,7 @@ use crate::errors;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::memmap::Mmap;
use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId};
-use rustc_middle::ty::OnDiskCache;
+use rustc_middle::query::on_disk_cache::OnDiskCache;
use rustc_serialize::opaque::MemDecoder;
use rustc_serialize::Decodable;
use rustc_session::config::IncrementalStateAssertion;
@@ -73,12 +73,22 @@ impl<T: Default> LoadResult<T> {
}
}
-fn load_data(
- report_incremental_info: bool,
+fn load_data(path: &Path, sess: &Session) -> LoadResult<(Mmap, usize)> {
+ load_data_no_sess(
+ path,
+ sess.opts.unstable_opts.incremental_info,
+ sess.is_nightly_build(),
+ sess.cfg_version,
+ )
+}
+
+fn load_data_no_sess(
path: &Path,
- nightly_build: bool,
+ report_incremental_info: bool,
+ is_nightly_build: bool,
+ cfg_version: &'static str,
) -> LoadResult<(Mmap, usize)> {
- match file_format::read_file(report_incremental_info, path, nightly_build) {
+ match file_format::read_file(path, report_incremental_info, is_nightly_build, cfg_version) {
Ok(Some(data_and_pos)) => LoadResult::Ok { data: data_and_pos },
Ok(None) => {
// The file either didn't exist or was produced by an incompatible
@@ -138,14 +148,13 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
let expected_hash = sess.opts.dep_tracking_hash(false);
let mut prev_work_products = FxHashMap::default();
- let nightly_build = sess.is_nightly_build();
// If we are only building with -Zquery-dep-graph but without an actual
// incr. comp. session directory, we skip this. Otherwise we'd fail
// when trying to load work products.
if sess.incr_comp_session_dir_opt().is_some() {
let work_products_path = work_products_path(sess);
- let load_result = load_data(report_incremental_info, &work_products_path, nightly_build);
+ let load_result = load_data(&work_products_path, sess);
if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
@@ -173,10 +182,13 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
}
}
+ let is_nightly_build = sess.is_nightly_build();
+ let cfg_version = sess.cfg_version;
+
MaybeAsync::Async(std::thread::spawn(move || {
let _prof_timer = prof.generic_activity("incr_comp_load_dep_graph");
- match load_data(report_incremental_info, &path, nightly_build) {
+ match load_data_no_sess(&path, report_incremental_info, is_nightly_build, cfg_version) {
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
LoadResult::LoadDepGraph(path, err) => LoadResult::LoadDepGraph(path, err),
LoadResult::DecodeIncrCache(err) => LoadResult::DecodeIncrCache(err),
@@ -211,19 +223,17 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
/// If we are not in incremental compilation mode, returns `None`.
/// Otherwise, tries to load the query result cache from disk,
/// creating an empty cache if it could not be loaded.
-pub fn load_query_result_cache<'a, C: OnDiskCache<'a>>(sess: &'a Session) -> Option<C> {
+pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache<'_>> {
if sess.opts.incremental.is_none() {
return None;
}
let _prof_timer = sess.prof.generic_activity("incr_comp_load_query_result_cache");
- match load_data(
- sess.opts.unstable_opts.incremental_info,
- &query_cache_path(sess),
- sess.is_nightly_build(),
- ) {
- LoadResult::Ok { data: (bytes, start_pos) } => Some(C::new(sess, bytes, start_pos)),
- _ => Some(C::new_empty(sess.source_map())),
+ match load_data(&query_cache_path(sess), sess) {
+ LoadResult::Ok { data: (bytes, start_pos) } => {
+ Some(OnDiskCache::new(sess, bytes, start_pos))
+ }
+ _ => Some(OnDiskCache::new_empty(sess.source_map())),
}
}
diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs
index 27be56eac..7376be6be 100644
--- a/compiler/rustc_incremental/src/persist/save.rs
+++ b/compiler/rustc_incremental/src/persist/save.rs
@@ -48,7 +48,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) {
move || {
sess.time("incr_comp_persist_result_cache", || {
// Drop the memory map so that we can remove the file and write to it.
- if let Some(odc) = &tcx.on_disk_cache {
+ if let Some(odc) = &tcx.query_system.on_disk_cache {
odc.drop_serialized_data(tcx);
}
@@ -164,7 +164,7 @@ pub fn build_dep_graph(
}
};
- file_format::write_file_header(&mut encoder, sess.is_nightly_build());
+ file_format::write_file_header(&mut encoder, sess);
// First encode the commandline arguments hash
sess.opts.dep_tracking_hash(false).encode(&mut encoder);