Skip to content

Commit 2d3b388

Browse files
committed
Fix stdlib building
1 parent bc435e1 commit 2d3b388

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_metadata/src/locator.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,6 @@ impl<'a> CrateLocator<'a> {
576576
) {
577577
Ok(blob) => {
578578
if let Some(h) = self.crate_matches(&blob, &lib) {
579-
if blob.get_header().is_reference {
580-
if slot.is_none() {
581-
todo!("return error");
582-
}
583-
}
584579
(h, blob)
585580
} else {
586581
info!("metadata mismatch");
@@ -629,7 +624,11 @@ impl<'a> CrateLocator<'a> {
629624
continue;
630625
}
631626

632-
*slot = Some((hash, metadata, lib.clone()));
627+
if !metadata.get_header().is_reference {
628+
// FIXME nicer error when only an rlib or dylib with is_reference is found
629+
// and no .rmeta?
630+
*slot = Some((hash, metadata, lib.clone()));
631+
}
633632
ret = Some((lib, kind));
634633
}
635634

@@ -719,10 +718,12 @@ impl<'a> CrateLocator<'a> {
719718
let loc_canon = loc.canonicalized().clone();
720719
let loc = loc.original();
721720
if loc.file_name().unwrap().to_str().unwrap().ends_with(".rlib") {
721+
rmetas.insert(loc_canon.with_extension("rmeta"), PathKind::ExternFlag);
722722
rlibs.insert(loc_canon, PathKind::ExternFlag);
723723
} else if loc.file_name().unwrap().to_str().unwrap().ends_with(".rmeta") {
724724
rmetas.insert(loc_canon, PathKind::ExternFlag);
725725
} else {
726+
rmetas.insert(loc_canon.with_extension("rmeta"), PathKind::ExternFlag);
726727
dylibs.insert(loc_canon, PathKind::ExternFlag);
727728
}
728729
} else {

src/bootstrap/src/bin/rustc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ fn main() {
113113
}
114114
}
115115

116+
if orig_args.iter().any(|arg| arg == "-Zsplit-metadata") {
117+
if orig_args.windows(2).any(|args| args[0] == "--crate-type" && args[1] == "dylib") {
118+
cmd.arg("--emit").arg("metadata");
119+
}
120+
}
121+
116122
// Print backtrace in case of ICE
117123
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
118124
cmd.env("RUST_BACKTRACE", "1");

0 commit comments

Comments
 (0)