1
Fork 0

Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoerister

Implement `#[link_ordinal(n)]`

Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name.  As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL.

Part of #58713.
This commit is contained in:
Jubilee 2021-10-07 20:26:11 -07:00 committed by GitHub
commit 6c17601a2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 201 additions and 23 deletions

View file

@ -433,6 +433,12 @@ impl Collector<'tcx> {
}
}
};
DllImport { name: item.ident.name, ordinal: None, calling_convention, span: item.span }
DllImport {
name: item.ident.name,
ordinal: self.tcx.codegen_fn_attrs(item.id.def_id).link_ordinal,
calling_convention,
span: item.span,
}
}
}