Skip to content

Commit ab79438

Browse files
committed
canonicalize base incremental path on windows
This sidesteps problems with long paths because the canonical path includes the "magic long path prefix" on Windows.
1 parent 4e844ad commit ab79438

File tree

1 file changed

+13
-0
lines changed
  • src/librustc_incremental/persist

1 file changed

+13
-0
lines changed

src/librustc_incremental/persist/fs.rs

+13
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ pub fn prepare_session_directory(tcx: TyCtxt) -> Result<bool, ()> {
201201
debug!("crate-dir: {}", crate_dir.display());
202202
try!(create_dir(tcx.sess, &crate_dir, "crate"));
203203

204+
// Hack: canonicalize the path *after creating the directory*
205+
// because, on windows, long paths can cause problems;
206+
// canonicalization inserts this weird prefix that makes windows
207+
// tolerate long paths.
208+
let crate_dir = match crate_dir.canonicalize() {
209+
Ok(v) => v,
210+
Err(err) => {
211+
tcx.sess.err(&format!("incremental compilation: error canonicalizing path `{}`: {}",
212+
crate_dir.display(), err));
213+
return Err(());
214+
}
215+
};
216+
204217
let mut source_directories_already_tried = FxHashSet();
205218

206219
loop {

0 commit comments

Comments
 (0)