Rollup merge of #81598 - sivadeilra:windows_dll_imports_fix_x86, r=m-ou-se

Fix calling convention for CRT startup

My PR #81478 used the wrong calling convention for a set of
functions that are called by the CRT. These functions need to use
`extern "C"`.

This would only affect x86, which is the only target (that I know of)
that has multiple calling conventions.

```@bors``` r? ```@m-ou-se```
This commit is contained in:
Jonas Schievink 2021-02-01 14:29:45 +01:00 committed by GitHub
commit 2622227208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,9 +74,9 @@ pub mod $symbol {
/// used, and would remove it. /// used, and would remove it.
#[used] #[used]
#[link_section = ".CRT$XCU"] #[link_section = ".CRT$XCU"]
static INIT_TABLE_ENTRY: fn() = init; static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init;
fn init() { unsafe extern "C" fn init() {
// There is no locking here. This code is executed before main() is entered, and // There is no locking here. This code is executed before main() is entered, and
// is guaranteed to be single-threaded. // is guaranteed to be single-threaded.
// //
@ -84,7 +84,6 @@ fn init() {
// any Rust functions or CRT functions, if those functions touch any global state, // any Rust functions or CRT functions, if those functions touch any global state,
// because this function runs during global initialization. For example, DO NOT // because this function runs during global initialization. For example, DO NOT
// do any dynamic allocation, don't call LoadLibrary, etc. // do any dynamic allocation, don't call LoadLibrary, etc.
unsafe {
let module_name: *const u8 = concat!($module, "\0").as_ptr(); let module_name: *const u8 = concat!($module, "\0").as_ptr();
let symbol_name: *const u8 = concat!(stringify!($symbol), "\0").as_ptr(); let symbol_name: *const u8 = concat!(stringify!($symbol), "\0").as_ptr();
let module_handle = $crate::sys::c::GetModuleHandleA(module_name as *const i8); let module_handle = $crate::sys::c::GetModuleHandleA(module_name as *const i8);
@ -97,7 +96,6 @@ fn init() {
} }
} }
} }
}
#[allow(dead_code)] #[allow(dead_code)]
pub fn option() -> Option<F> { pub fn option() -> Option<F> {