Skip to content

Commit 3ce89e2

Browse files
committed
Use the actual StableCrateId for the incr comp session dir
Previously only --crate-type would be taken into account, not #![crate_type].
1 parent 4b53279 commit 3ce89e2

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

compiler/rustc_incremental/src/persist/fs.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ use rustc_data_structures::unord::{UnordMap, UnordSet};
116116
use rustc_data_structures::{base_n, flock};
117117
use rustc_fs_util::{LinkOrCopy, link_or_copy, try_canonicalize};
118118
use rustc_middle::bug;
119-
use rustc_session::config::CrateType;
120-
use rustc_session::output::collect_crate_types;
121119
use rustc_session::{Session, StableCrateId};
122120
use rustc_span::Symbol;
123121
use tracing::debug;
@@ -212,7 +210,11 @@ pub fn in_incr_comp_dir(incr_comp_session_dir: &Path, file_name: &str) -> PathBu
212210
/// The garbage collection will take care of it.
213211
///
214212
/// [`rustc_interface::queries::dep_graph`]: ../../rustc_interface/struct.Queries.html#structfield.dep_graph
215-
pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) {
213+
pub(crate) fn prepare_session_directory(
214+
sess: &Session,
215+
crate_name: Symbol,
216+
stable_crate_id: StableCrateId,
217+
) {
216218
if sess.opts.incremental.is_none() {
217219
return;
218220
}
@@ -222,7 +224,7 @@ pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) {
222224
debug!("prepare_session_directory");
223225

224226
// {incr-comp-dir}/{crate-name-and-disambiguator}
225-
let crate_dir = crate_path(sess, crate_name);
227+
let crate_dir = crate_path(sess, crate_name, stable_crate_id);
226228
debug!("crate-dir: {}", crate_dir.display());
227229
create_dir(sess, &crate_dir, "crate");
228230

@@ -595,17 +597,9 @@ fn string_to_timestamp(s: &str) -> Result<SystemTime, &'static str> {
595597
Ok(UNIX_EPOCH + duration)
596598
}
597599

598-
fn crate_path(sess: &Session, crate_name: Symbol) -> PathBuf {
600+
fn crate_path(sess: &Session, crate_name: Symbol, stable_crate_id: StableCrateId) -> PathBuf {
599601
let incr_dir = sess.opts.incremental.as_ref().unwrap().clone();
600602

601-
let crate_types = collect_crate_types(sess, &[]);
602-
let stable_crate_id = StableCrateId::new(
603-
crate_name,
604-
crate_types.contains(&CrateType::Executable),
605-
sess.opts.cg.metadata.clone(),
606-
sess.cfg_version,
607-
);
608-
609603
let crate_name =
610604
format!("{crate_name}-{}", stable_crate_id.as_u64().to_base_fixed_len(CASE_INSENSITIVE));
611605
incr_dir.join(crate_name)

compiler/rustc_incremental/src/persist/load.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_middle::dep_graph::{DepGraph, DepsType, SerializedDepGraph, WorkProduc
1010
use rustc_middle::query::on_disk_cache::OnDiskCache;
1111
use rustc_serialize::Decodable;
1212
use rustc_serialize::opaque::MemDecoder;
13-
use rustc_session::Session;
1413
use rustc_session::config::IncrementalStateAssertion;
14+
use rustc_session::{Session, StableCrateId};
1515
use rustc_span::Symbol;
1616
use tracing::{debug, warn};
1717

@@ -208,9 +208,14 @@ pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache> {
208208

209209
/// Setups the dependency graph by loading an existing graph from disk and set up streaming of a
210210
/// new graph to an incremental session directory.
211-
pub fn setup_dep_graph(sess: &Session, crate_name: Symbol, deps: &DepsType) -> DepGraph {
211+
pub fn setup_dep_graph(
212+
sess: &Session,
213+
crate_name: Symbol,
214+
stable_crate_id: StableCrateId,
215+
deps: &DepsType,
216+
) -> DepGraph {
212217
// `load_dep_graph` can only be called after `prepare_session_directory`.
213-
prepare_session_directory(sess, crate_name);
218+
prepare_session_directory(sess, crate_name, stable_crate_id);
214219

215220
let res = sess.opts.build_dep_graph().then(|| load_dep_graph(sess, deps));
216221

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
936936
let outputs = util::build_output_filenames(&pre_configured_attrs, sess);
937937

938938
let dep_type = DepsType { dep_names: rustc_query_impl::dep_kind_names() };
939-
let dep_graph = setup_dep_graph(sess, crate_name, &dep_type);
939+
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id, &dep_type);
940940

941941
let cstore =
942942
FreezeLock::new(Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _);

0 commit comments

Comments
 (0)