trans: Set COMDAT section for weak symbols so that Windows can handle them.
This commit is contained in:
parent
4c27a3c6d5
commit
b149b9d19b
2 changed files with 10 additions and 1 deletions
|
@ -212,6 +212,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
|
||||||
|
|
||||||
let llfn = get_or_create_closure_declaration(ccx, closure_def_id, closure_substs);
|
let llfn = get_or_create_closure_declaration(ccx, closure_def_id, closure_substs);
|
||||||
llvm::SetLinkage(llfn, llvm::WeakODRLinkage);
|
llvm::SetLinkage(llfn, llvm::WeakODRLinkage);
|
||||||
|
llvm::SetUniqueComdat(ccx.llmod(), llfn);
|
||||||
|
|
||||||
// Get the type of this closure. Use the current `param_substs` as
|
// Get the type of this closure. Use the current `param_substs` as
|
||||||
// the closure substitutions. This makes sense because the closure
|
// the closure substitutions. This makes sense because the closure
|
||||||
|
|
|
@ -190,9 +190,13 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||||
}) => {
|
}) => {
|
||||||
let lldecl = declare::declare_fn(ccx, symbol_name, mono_ty);
|
let lldecl = declare::declare_fn(ccx, symbol_name, mono_ty);
|
||||||
llvm::SetLinkage(lldecl, linkage);
|
llvm::SetLinkage(lldecl, linkage);
|
||||||
attributes::from_fn_attrs(ccx, attrs, lldecl);
|
|
||||||
base::set_link_section(ccx, lldecl, attrs);
|
base::set_link_section(ccx, lldecl, attrs);
|
||||||
|
if linkage == llvm::LinkOnceODRLinkage ||
|
||||||
|
linkage == llvm::WeakODRLinkage {
|
||||||
|
llvm::SetUniqueComdat(ccx.llmod(), lldecl);
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes::from_fn_attrs(ccx, attrs, lldecl);
|
||||||
ccx.instances().borrow_mut().insert(instance, lldecl);
|
ccx.instances().borrow_mut().insert(instance, lldecl);
|
||||||
}
|
}
|
||||||
_ => bug!("Invalid item for TransItem::Fn: `{:?}`", map_node)
|
_ => bug!("Invalid item for TransItem::Fn: `{:?}`", map_node)
|
||||||
|
@ -223,6 +227,10 @@ impl<'a, 'tcx> TransItem<'tcx> {
|
||||||
assert!(declare::get_defined_value(ccx, symbol_name).is_none());
|
assert!(declare::get_defined_value(ccx, symbol_name).is_none());
|
||||||
let llfn = declare::declare_cfn(ccx, symbol_name, llfnty);
|
let llfn = declare::declare_cfn(ccx, symbol_name, llfnty);
|
||||||
llvm::SetLinkage(llfn, linkage);
|
llvm::SetLinkage(llfn, linkage);
|
||||||
|
if linkage == llvm::LinkOnceODRLinkage ||
|
||||||
|
linkage == llvm::WeakODRLinkage {
|
||||||
|
llvm::SetUniqueComdat(ccx.llmod(), llfn);
|
||||||
|
}
|
||||||
attributes::set_frame_pointer_elimination(ccx, llfn);
|
attributes::set_frame_pointer_elimination(ccx, llfn);
|
||||||
ccx.drop_glues().borrow_mut().insert(dg, (llfn, fn_ty));
|
ccx.drop_glues().borrow_mut().insert(dg, (llfn, fn_ty));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue