Review comments
This commit is contained in:
parent
943f6a8ca9
commit
0daa921f0e
2 changed files with 9 additions and 3 deletions
|
@ -234,8 +234,6 @@ pub fn each_linked_rlib(
|
||||||
crate_type: Option<CrateType>,
|
crate_type: Option<CrateType>,
|
||||||
f: &mut dyn FnMut(CrateNum, &Path),
|
f: &mut dyn FnMut(CrateNum, &Path),
|
||||||
) -> Result<(), errors::LinkRlibError> {
|
) -> Result<(), errors::LinkRlibError> {
|
||||||
let crates = info.used_crates.iter();
|
|
||||||
|
|
||||||
let fmts = if let Some(crate_type) = crate_type {
|
let fmts = if let Some(crate_type) = crate_type {
|
||||||
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
|
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
|
||||||
return Err(errors::LinkRlibError::MissingFormat);
|
return Err(errors::LinkRlibError::MissingFormat);
|
||||||
|
@ -261,7 +259,8 @@ pub fn each_linked_rlib(
|
||||||
info.dependency_formats.first().unwrap().1
|
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) {
|
match fmts.get(cnum) {
|
||||||
Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue,
|
Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue,
|
||||||
Some(_) => {}
|
Some(_) => {}
|
||||||
|
|
|
@ -212,7 +212,14 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||||
// Collect what we've got so far in the return vector.
|
// Collect what we've got so far in the return vector.
|
||||||
let last_crate = tcx.crates(()).len();
|
let last_crate = tcx.crates(()).len();
|
||||||
let mut ret = IndexVec::new();
|
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);
|
assert_eq!(ret.push(Linkage::Static), LOCAL_CRATE);
|
||||||
|
|
||||||
for cnum in 1..last_crate + 1 {
|
for cnum in 1..last_crate + 1 {
|
||||||
let cnum = CrateNum::new(cnum);
|
let cnum = CrateNum::new(cnum);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue