1
Fork 0

Review comments

This commit is contained in:
bjorn3 2024-12-20 08:35:02 +00:00
parent 943f6a8ca9
commit 0daa921f0e
2 changed files with 9 additions and 3 deletions

View file

@ -234,8 +234,6 @@ pub fn each_linked_rlib(
crate_type: Option<CrateType>,
f: &mut dyn FnMut(CrateNum, &Path),
) -> Result<(), errors::LinkRlibError> {
let crates = info.used_crates.iter();
let fmts = if let Some(crate_type) = crate_type {
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
return Err(errors::LinkRlibError::MissingFormat);
@ -261,7 +259,8 @@ pub fn each_linked_rlib(
info.dependency_formats.first().unwrap().1
};
for &cnum in crates {
let used_dep_crates = info.used_crates.iter();
for &cnum in used_dep_crates {
match fmts.get(cnum) {
Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue,
Some(_) => {}

View file

@ -212,7 +212,14 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
// Collect what we've got so far in the return vector.
let last_crate = tcx.crates(()).len();
let mut ret = IndexVec::new();
// We need to fill in something for LOCAL_CRATE as IndexVec is a dense map.
// Linkage::Static semantically the most correct thing to use as the local
// crate is always statically linked into the linker output, even when
// linking a dylib. Using Linkage::Static also allow avoiding special cases
// for LOCAL_CRATE in some places.
assert_eq!(ret.push(Linkage::Static), LOCAL_CRATE);
for cnum in 1..last_crate + 1 {
let cnum = CrateNum::new(cnum);
assert_eq!(