Skip to content

Commit 15b716c

Browse files
committed
Handle cross-compilation in the duplicate crate check
1 parent 3805401 commit 15b716c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,15 +2423,25 @@ pub fn add_to_sysroot(
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 {
2426-
DependencyType::Host => sysroot_host_dst,
2427-
DependencyType::Target => sysroot_dst,
2426+
DependencyType::Host => {
2427+
if sysroot_dst == sysroot_host_dst {
2428+
// Only insert the part before the . to deduplicate different files for the same crate.
2429+
// For example foo-1234.dll and foo-1234.dll.lib.
2430+
crates.insert(filename.split_once('.').unwrap().0.to_owned(), path.clone());
2431+
}
2432+
2433+
sysroot_host_dst
2434+
}
2435+
DependencyType::Target => {
2436+
// Only insert the part before the . to deduplicate different files for the same crate.
2437+
// For example foo-1234.dll and foo-1234.dll.lib.
2438+
crates.insert(filename.split_once('.').unwrap().0.to_owned(), path.clone());
2439+
2440+
sysroot_dst
2441+
}
24282442
DependencyType::TargetSelfContained => self_contained_dst,
24292443
};
24302444
builder.copy_link(&path, &dst.join(filename), FileType::Regular);
2431-
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(), path);
24352445
}
24362446

24372447
// Check that none of the rustc_* crates have multiple versions. Otherwise using them from

0 commit comments

Comments
 (0)