Skip to content

Commit

Permalink
Rollup merge of rust-lang#122186 - bjorn3:remove_bug_workaround, r=pe…
Browse files Browse the repository at this point in the history
…trochenkov

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 rust-lang#120855
  • Loading branch information
matthiaskrgr authored Mar 9, 2024
2 parents 1404734 + 446708b commit be4523b
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ use std::{cmp, fmt};
pub(crate) struct CrateLocator<'a> {
// Immutable per-session configuration.
only_needs_metadata: bool,
sysroot: &'a Path,
metadata_loader: &'a dyn MetadataLoader,
cfg_version: &'static str,

Expand Down Expand Up @@ -319,7 +318,6 @@ impl<'a> CrateLocator<'a> {

CrateLocator {
only_needs_metadata,
sysroot: &sess.sysroot,
metadata_loader,
cfg_version: sess.cfg_version,
crate_name,
Expand Down Expand Up @@ -610,32 +608,6 @@ impl<'a> CrateLocator<'a> {
continue;
}

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

0 comments on commit be4523b

Please sign in to comment.