1
Fork 0

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:
Dylan DPC 2022-09-16 11:17:00 +05:30 committed by GitHub
commit 61126d3611
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 140 additions and 4 deletions

View file

@ -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,