Skip to content

Commit 414fe8b

Browse files
committed
Auto merge of #122186 - bjorn3:remove_bug_workaround, r=petrochenkov
Remove a workaround for a bug I don't think it is necessary anymore. As I understand it from issue 39504 the original problem was that rustbuild changed a hardlink in the cargo build dir to point to copy in the sysroot while cargo may have hardlinked it to the original first. I don't think this happens anymore and as such this workaround is no longer necessary. Split out of #120855
2 parents af69f4c + 446708b commit 414fe8b

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

compiler/rustc_metadata/src/locator.rs

-28
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ use std::{cmp, fmt};
243243
pub(crate) struct CrateLocator<'a> {
244244
// Immutable per-session configuration.
245245
only_needs_metadata: bool,
246-
sysroot: &'a Path,
247246
metadata_loader: &'a dyn MetadataLoader,
248247
cfg_version: &'static str,
249248

@@ -319,7 +318,6 @@ impl<'a> CrateLocator<'a> {
319318

320319
CrateLocator {
321320
only_needs_metadata,
322-
sysroot: &sess.sysroot,
323321
metadata_loader,
324322
cfg_version: sess.cfg_version,
325323
crate_name,
@@ -626,32 +624,6 @@ impl<'a> CrateLocator<'a> {
626624
continue;
627625
}
628626

629-
// Ok so at this point we've determined that `(lib, kind)` above is
630-
// a candidate crate to load, and that `slot` is either none (this
631-
// is the first crate of its kind) or if some the previous path has
632-
// the exact same hash (e.g., it's the exact same crate).
633-
//
634-
// In principle these two candidate crates are exactly the same so
635-
// we can choose either of them to link. As a stupidly gross hack,
636-
// however, we favor crate in the sysroot.
637-
//
638-
// You can find more info in rust-lang/rust#39518 and various linked
639-
// issues, but the general gist is that during testing libstd the
640-
// compilers has two candidates to choose from: one in the sysroot
641-
// and one in the deps folder. These two crates are the exact same
642-
// crate but if the compiler chooses the one in the deps folder
643-
// it'll cause spurious errors on Windows.
644-
//
645-
// As a result, we favor the sysroot crate here. Note that the
646-
// candidates are all canonicalized, so we canonicalize the sysroot
647-
// as well.
648-
if let Some((prev, _)) = &ret {
649-
let sysroot = self.sysroot;
650-
let sysroot = try_canonicalize(sysroot).unwrap_or_else(|_| sysroot.to_path_buf());
651-
if prev.starts_with(&sysroot) {
652-
continue;
653-
}
654-
}
655627
*slot = Some((hash, metadata, lib.clone()));
656628
ret = Some((lib, kind));
657629
}

0 commit comments

Comments
 (0)