Skip to content

Commit 1ba6869

Browse files
committed
Handle windows producing two files for every dylib in the duplicate crate check
1 parent 871ec86 commit 1ba6869

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ pub fn add_to_sysroot(
24192419
t!(fs::create_dir_all(sysroot_host_dst));
24202420
t!(fs::create_dir_all(self_contained_dst));
24212421

2422-
let mut rustc_crates = HashSet::new();
2422+
let mut crates = HashSet::new();
24232423
for (path, dependency_type) in builder.read_stamp_file(stamp) {
24242424
let filename = path.file_name().unwrap().to_str().unwrap();
24252425
let dst = match dependency_type {
@@ -2429,16 +2429,23 @@ pub fn add_to_sysroot(
24292429
};
24302430
builder.copy_link(&path, &dst.join(filename), FileType::Regular);
24312431

2432-
// Check that none of the rustc_* crates have multiple versions. Otherwise using them from
2433-
// the sysroot would cause ambiguity errors. We do allow rustc_hash however as it is an
2434-
// external dependency that we build multiple copies of. It is re-exported by
2435-
// rustc_data_structures, so not being able to use extern crate rustc_hash; is not a big
2436-
// issue.
2437-
if !filename.contains("rustc_") || filename.contains("rustc_hash") {
2432+
// Only insert the part before the . to deduplicate different files for the same crate.
2433+
// For example foo-1234.dll and foo-1234.dll.lib.
2434+
crates.insert(filename.split_once('.').unwrap().0.to_owned());
2435+
}
2436+
2437+
// Check that none of the rustc_* crates have multiple versions. Otherwise using them from
2438+
// the sysroot would cause ambiguity errors. We do allow rustc_hash however as it is an
2439+
// external dependency that we build multiple copies of. It is re-exported by
2440+
// rustc_data_structures, so not being able to use extern crate rustc_hash; is not a big
2441+
// issue.
2442+
let mut seen_crates = HashSet::new();
2443+
for filestem in crates {
2444+
if !filestem.contains("rustc_") || filestem.contains("rustc_hash") {
24382445
continue;
24392446
}
2440-
if !rustc_crates.insert(filename.split_once('-').unwrap().0.to_owned()) {
2441-
panic!("duplicate rustc crate at {}", path.display());
2447+
if !seen_crates.insert(filestem.split_once('-').unwrap().0.to_owned()) {
2448+
panic!("duplicate rustc crate {filestem}");
24422449
}
24432450
}
24442451
}

0 commit comments

Comments
 (0)