Skip to content

Commit

Permalink
Fix stdlib building
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jun 30, 2024
1 parent 56c075b commit 06d5845
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 8 additions & 6 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,6 @@ impl<'a> CrateLocator<'a> {
) {
Ok(blob) => {
if let Some(h) = self.crate_matches(&blob, &lib) {
if blob.get_header().is_reference {
if slot.is_none() {
todo!("return error");
}
}
(h, blob)
} else {
info!("metadata mismatch");
Expand Down Expand Up @@ -654,7 +649,12 @@ impl<'a> CrateLocator<'a> {
continue;
}
}
*slot = Some((hash, metadata, lib.clone()));

if !metadata.get_header().is_reference {
// FIXME nicer error when only an rlib or dylib with is_reference is found
// and no .rmeta?
*slot = Some((hash, metadata, lib.clone()));
}
ret = Some((lib, kind));
}

Expand Down Expand Up @@ -744,10 +744,12 @@ impl<'a> CrateLocator<'a> {
let loc_canon = loc.canonicalized().clone();
let loc = loc.original();
if loc.file_name().unwrap().to_str().unwrap().ends_with(".rlib") {
rmetas.insert(loc_canon.with_extension("rmeta"), PathKind::ExternFlag);
rlibs.insert(loc_canon, PathKind::ExternFlag);
} else if loc.file_name().unwrap().to_str().unwrap().ends_with(".rmeta") {
rmetas.insert(loc_canon, PathKind::ExternFlag);
} else {
rmetas.insert(loc_canon.with_extension("rmeta"), PathKind::ExternFlag);
dylibs.insert(loc_canon, PathKind::ExternFlag);
}
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ fn main() {
}
}

if orig_args.iter().any(|arg| arg == "-Zsplit-metadata")
&& orig_args.windows(2).any(|args| args[0] == "--crate-type" && args[1] == "dylib")
{
cmd.arg("--emit").arg("metadata");
}

// Print backtrace in case of ICE
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
cmd.env("RUST_BACKTRACE", "1");
Expand Down

0 comments on commit 06d5845

Please sign in to comment.