Change:
Code: If the function is marked as , it doesn't get compiled into the dll file: The reason a function may be marked as both and is so that it gets inlined when compiling the crate as a rust library, but not inlined when compiling the crate as a cdylib. There should be a warning to use something like instead. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
Related to - I think is that we should include 'd functions in s and s, but as a short term solution, a warning is a nice idea
claim

Discussion:
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) => { let def_id = tcx.hir().local_def_id(hir_id); let generics = tcx.generics_of(def_id); <del> if !generics.requires_monomorphization(tcx) && // Functions marked with #[inline] are only ever codegened // with "internal" linkage and are never exported. !Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx) </del> <ins> if !generics.requires_monomorphization(tcx) // Functions marked with #[inline] are codegened with "internal" // linkage and are not exported unless marked with an extern // inidicator && (!Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx) || tcx.codegen_fn_attrs(def_id.to_def_id()).contains_extern_indicator()) </ins> { Some(def_id) } else {

match *self { MonoItem::Fn(ref instance) => { let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id); <del> // If this function isn't inlined or otherwise has explicit // linkage, then we'll be creating a globally shared version. if self.explicit_linkage(tcx).is_some() </del> <ins> // If this function isn't inlined or otherwise has an extern // indicator, then we'll be creating a globally shared version. if tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator() </ins> || !instance.def.generates_cgu_internal_copy(tcx) || Some(instance.def_id()) == entry_def_id.map(LocalDefId::to_def_id) {

// At this point we don't have explicit linkage and we're an // inlined function. If we're inlining into all CGUs then we'll <del> // be creating a local copy per CGU </del> <ins> // be creating a local copy per CGU. </ins> if generate_cgu_internal_copies { return InstantiationMode::LocalCopy; }

<ins> // compile-flags: -C no-prepopulate-passes #![crate_type = "cdylib"] // CHECK: define void @a() #[no_mangle] #[inline] pub extern "C" fn a() {} // CHECK: define void @b() #[export_name = "b"] #[inline] pub extern "C" fn b() {} // CHECK: define void @c() #[no_mangle] #[inline] extern "C" fn c() {} // CHECK: define void @d() #[export_name = "d"] #[inline] extern "C" fn d() {} // CHECK: define void @e() #[no_mangle] #[inline(always)] pub extern "C" fn e() {} // CHECK: define void @f() #[export_name = "f"] #[inline(always)] pub extern "C" fn f() {} // CHECK: define void @g() #[no_mangle] #[inline(always)] extern "C" fn g() {} // CHECK: define void @h() #[export_name = "h"] #[inline(always)] extern "C" fn h() {} </ins>

#[export_name = "BAR"] static BAR: u32 = 3; <del> // CHECK: void @foo() </del> <ins> // CHECK: void @a() </ins> #[no_mangle] <del> pub extern fn foo() {} </del> <ins> pub extern fn a() {} </ins> <del> // CHECK: void @bar() #[export_name = "bar"] extern fn bar() {} </del> <ins> // CHECK: void @b() #[export_name = "b"] extern fn b() {} // CHECK: void @c() #[export_name = "c"] #[inline] extern fn c() {} // CHECK: void @d() #[export_name = "d"] #[inline(always)] extern fn d() {} </ins> }

core::ptr::read_volatile(&42); } } <ins> // CHECK: define void @i() #[no_mangle] #[inline] fn i() {} // CHECK: define void @j() #[no_mangle] #[inline] pub fn j() {} // CHECK: define void @k() #[no_mangle] #[inline(always)] fn k() {} // CHECK: define void @l() #[no_mangle] #[inline(always)] pub fn l() {} </ins>

#![feature(no_sanitize)] // ASAN-LABEL: define void @test <del> // ASAN:         tail call fastcc void @random_inline </del> <ins> // ASAN:         call {{.*}} @random_inline </ins> // ASAN:       } // // LSAN-LABEL: define void @test

<ins> // compile-flags: -C no-prepopulate-passes #![crate_type = "staticlib"] // CHECK: define void @a() #[no_mangle] #[inline] pub extern "C" fn a() {} // CHECK: define void @b() #[export_name = "b"] #[inline] pub extern "C" fn b() {} // CHECK: define void @c() #[no_mangle] #[inline] extern "C" fn c() {} // CHECK: define void @d() #[export_name = "d"] #[inline] extern "C" fn d() {} // CHECK: define void @e() #[no_mangle] #[inline(always)] pub extern "C" fn e() {} // CHECK: define void @f() #[export_name = "f"] #[inline(always)] pub extern "C" fn f() {} // CHECK: define void @g() #[no_mangle] #[inline(always)] extern "C" fn g() {} // CHECK: define void @h() #[export_name = "h"] #[inline(always)] extern "C" fn h() {} </ins>