Rollup merge of #101738 - dpaoliello:linkname, r=petrochenkov
Fix `#[link kind="raw-dylib"]` to respect `#[link_name]` Issue Details: When using `#[link kind="raw-dylib"]` (#58713), the Rust compiler ignored any `#[link_name]` attributes when generating the import library and so the resulting binary would fail to link due to missing symbols. Fix Details: Use the name from `#[link_name]` if present when generating the `raw-dylib` import library, otherwise default back to the actual symbol name.
This commit is contained in:
commit
61126d3611
13 changed files with 140 additions and 4 deletions
|
@ -560,14 +560,13 @@ impl<'tcx> Collector<'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
let import_name_type = self
|
||||
.tcx
|
||||
.codegen_fn_attrs(item.id.def_id)
|
||||
let codegen_fn_attrs = self.tcx.codegen_fn_attrs(item.id.def_id);
|
||||
let import_name_type = codegen_fn_attrs
|
||||
.link_ordinal
|
||||
.map_or(import_name_type, |ord| Some(PeImportNameType::Ordinal(ord)));
|
||||
|
||||
DllImport {
|
||||
name: item.ident.name,
|
||||
name: codegen_fn_attrs.link_name.unwrap_or(item.ident.name),
|
||||
import_name_type,
|
||||
calling_convention,
|
||||
span: item.span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue