Skip to content

Commit 21cf201

Browse files
authored
Rollup merge of #144473 - zeroomega:rustc_inconsistency, r=Mark-Simulacrum
Address libunwind.a inconsistency issues in the bootstrap program We noticed when building rustc multiple time in a roll, some files will not be consistent across the build despite the fact that they are built from same source under the same environment. This patch addresses the inconsistency issue we found on libunwind.a, by sorting the order of the files passed to the linker.
2 parents c97e64a + b3f369d commit 21cf201

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,15 +2384,19 @@ pub fn run_cargo(
23842384
letmut deps = Vec::new();
23852385
letmut toplevel = Vec::new();
23862386
let ok = stream_cargo(builder, cargo, tail_args,&mut |msg| {
2387-
let(filenames, crate_types) = match msg {
2387+
let(filenames_vec, crate_types) = match msg {
23882388
CargoMessage::CompilerArtifact{
23892389
filenames,
23902390
target:CargoTarget{ crate_types },
23912391
..
2392-
} => (filenames, crate_types),
2392+
} => {
2393+
letmut f:Vec<String> = filenames.into_iter().map(|s| s.into_owned()).collect();
2394+
f.sort();// Sort the filenames
2395+
(f, crate_types)
2396+
}
23932397
_ => return,
23942398
};
2395-
for filename infilenames{
2399+
for filename infilenames_vec{
23962400
// Skip files like executables
23972401
letmut keep = false;
23982402
if filename.ends_with(".lib")

‎src/bootstrap/src/core/build_steps/llvm.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,12 @@ impl Step for Libunwind {
15281528

15291529
// FIXME: https://github.com/alexcrichton/cc-rs/issues/545#issuecomment-679242845
15301530
letmut count = 0;
1531-
for entry in fs::read_dir(&out_dir).unwrap(){
1532-
let file = entry.unwrap().path().canonicalize().unwrap();
1531+
letmut files = fs::read_dir(&out_dir)
1532+
.unwrap()
1533+
.map(|entry| entry.unwrap().path().canonicalize().unwrap())
1534+
.collect::<Vec<_>>();
1535+
files.sort();
1536+
for file in files {
15331537
if file.is_file() && file.extension() == Some(OsStr::new("o")){
15341538
// Object file name without the hash prefix is "Unwind-EHABI", "Unwind-seh" or "libunwind".
15351539
let base_name = unhashed_basename(&file);

0 commit comments

Comments
 (0)