diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-16 11:17:00 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-16 11:17:00 +0530 |
| commit | 61126d3611c173fce47954fc4bf4671a8cea3ce9 (patch) | |
| tree | 4a7d2e4e9853ebcab57c7d51fe9c02ffc0f64c42 /compiler | |
| parent | b763cd53f4a2d2eedf043ff34954599b5941fa4d (diff) | |
| parent | 3c184db386ee3e1c4a9ae1b46836d29d657d5f43 (diff) | |
| download | rust-61126d3611c173fce47954fc4bf4671a8cea3ce9.tar.gz rust-61126d3611c173fce47954fc4bf4671a8cea3ce9.zip | |
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.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_metadata/src/native_libs.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index cc33ad07db6..257741c13f5 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -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, |
