Skip to content

Commit 50c1208

Browse files
committed
Fix stdlib building
1 parent 017cca2 commit 50c1208

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Diff for: compiler/rustc_metadata/src/locator.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,6 @@ impl<'a> CrateLocator<'a> {
580580
) {
581581
Ok(blob) => {
582582
if let Some(h) = self.crate_matches(&blob, &lib) {
583-
if blob.get_header().is_reference {
584-
if slot.is_none() {
585-
todo!("return error");
586-
}
587-
}
588583
(h, blob)
589584
} else {
590585
info!("metadata mismatch");
@@ -659,7 +654,12 @@ impl<'a> CrateLocator<'a> {
659654
continue;
660655
}
661656
}
662-
*slot = Some((hash, metadata, lib.clone()));
657+
658+
if !metadata.get_header().is_reference {
659+
// FIXME nicer error when only an rlib or dylib with is_reference is found
660+
// and no .rmeta?
661+
*slot = Some((hash, metadata, lib.clone()));
662+
}
663663
ret = Some((lib, kind));
664664
}
665665

@@ -735,6 +735,14 @@ impl<'a> CrateLocator<'a> {
735735
};
736736
if file.starts_with("lib") {
737737
if file.ends_with(".rlib") {
738+
if let Ok(rmeta_path) = try_canonicalize(
739+
loc_orig
740+
.parent()
741+
.unwrap()
742+
.join(file.strip_suffix(".rlib").unwrap().to_owned() + ".rmeta"),
743+
) {
744+
rmetas.insert(rmeta_path, PathKind::ExternFlag);
745+
}
738746
rlibs.insert(loc_canon.clone(), PathKind::ExternFlag);
739747
continue;
740748
}
@@ -746,6 +754,13 @@ impl<'a> CrateLocator<'a> {
746754
let dll_prefix = self.target.dll_prefix.as_ref();
747755
let dll_suffix = self.target.dll_suffix.as_ref();
748756
if file.starts_with(dll_prefix) && file.ends_with(dll_suffix) {
757+
if let Ok(rmeta_path) = try_canonicalize(loc_orig.parent().unwrap().join(
758+
"lib".to_owned()
759+
+ file.strip_prefix(dll_prefix).unwrap().strip_suffix(dll_suffix).unwrap()
760+
+ ".rmeta",
761+
)) {
762+
rmetas.insert(rmeta_path, PathKind::ExternFlag);
763+
}
749764
dylibs.insert(loc_canon.clone(), PathKind::ExternFlag);
750765
continue;
751766
}

0 commit comments

Comments
 (0)