// Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
// This is required to satisfy `dllimport` references to static data in .rlibs
// when using MSVC linker.  We do this only for data, as linker can fix up
// code references on its own.
// See #26591, #27438
Create a `__imp_ = &symbol` global for every public static `symbol`.
This is required to satisfy `dllimport` references to static data in .rlibs
when using MSVC linker.  We do this only for data, as linker can fix up
code references on its own.
Create a ` __imp_ = &symbol ` global for every public static ` symbol ` . This is required to satisfy ` dllimport ` references to static data in . rlibs when using MSVC linker . We do this only for data as linker can fix up code references on its own .
fn create_imps(cx: &CrateContextList) {
    // The x86 ABI seems to require that leading underscores are added to symbol
    // names, so we need an extra underscore on 32-bit. There's also a leading
    // '\x01' here which disables LLVM's symbol mangling (e.g. no extra
    // underscores added in front).
    let prefix = if cx.shared().sess().target.target.target_pointer_width == "32" {
        "\x01__imp__"
    } else {
        "\x01__imp_"
    };
    unsafe {
        for ccx in cx.iter() {
            let exported: Vec<_> = iter_globals(ccx.llmod())
                                       .filter(|&val| {
                                           llvm::LLVMGetLinkage(val) ==
                                           llvm::ExternalLinkage as c_uint &&
                                           llvm::LLVMIsDeclaration(val) == 0
                                       })
                                       .collect();
            let i8p_ty = Type::i8p(&ccx);
            for val in exported {
                let name = CStr::from_ptr(llvm::LLVMGetValueName(val));
                let mut imp_name = prefix.as_bytes().to_vec();
                imp_name.extend(name.to_bytes());
                let imp_name = CString::new(imp_name).unwrap();
                let imp = llvm::LLVMAddGlobal(ccx.llmod(),
                                              i8p_ty.to_ref(),
                                              imp_name.as_ptr() as *const _);
                let init = llvm::LLVMConstBitCast(val, i8p_ty.to_ref());
                llvm::LLVMSetInitializer(imp, init);
                llvm::SetLinkage(imp, llvm::ExternalLinkage);
            }
        }
    }
}
fn create_imps ( cx : & CrateContextList ) { // The x86 ABI seems to require that leading underscores are added to symbol // names, so we need an extra underscore on 32-bit. There's also a leading // '\x01' here which disables LLVM's symbol mangling (e.g. no extra // underscores added in front). let prefix = if cx . shared ( ) . sess ( ) . target . target . target_pointer_width == " " { " \x01 " } else { " \x01 " } ; unsafe { for ccx in cx . iter ( ) { let exported : Vec < _ > = iter_globals ( ccx . llmod ( ) ) . filter ( | & val | { llvm :: LLVMGetLinkage ( val ) == llvm :: ExternalLinkage as c_uint && llvm :: LLVMIsDeclaration ( val ) == 0 } ) . collect ( ) ; let i8p_ty = Type :: i8p ( & ccx ) ; for val in exported { let name = CStr :: from_ptr ( llvm :: LLVMGetValueName ( val ) ) ; let mut imp_name = prefix . as_bytes ( ) . to_vec ( ) ; imp_name . extend ( name . to_bytes ( ) ) ; let imp_name = CString :: new ( imp_name ) . unwrap ( ) ; let imp = llvm :: LLVMAddGlobal ( ccx . llmod ( ) , i8p_ty . to_ref ( ) , imp_name . as_ptr ( ) as * const _ ) ; let init = llvm :: LLVMConstBitCast ( val , i8p_ty . to_ref ( ) ) ; llvm :: LLVMSetInitializer ( imp , init ) ; llvm :: SetLinkage ( imp , llvm :: ExternalLinkage ) ; } } } }
Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
Create a ` __imp_<symbol > = &symbol ` global for every public static ` symbol ` .
cx
&CrateContextList