Use the linkage and visibility produced by tcx.collect_and_partition_mono_itemscc #209
This commit is contained in:
parent
0b4ede39e5
commit
3d05ff922c
@ -12,6 +12,7 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
|
||||
pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
|
||||
cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>,
|
||||
mono_item: MonoItem<'tcx>,
|
||||
linkage: Linkage,
|
||||
) {
|
||||
let tcx = cx.tcx;
|
||||
match mono_item {
|
||||
@ -42,7 +43,7 @@ pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
|
||||
}
|
||||
});
|
||||
|
||||
trans_fn(cx, inst);
|
||||
trans_fn(cx, inst, linkage);
|
||||
}
|
||||
MonoItem::Static(def_id) => {
|
||||
crate::constant::codegen_static(&mut cx.ccx, def_id);
|
||||
@ -56,6 +57,7 @@ pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
|
||||
fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
|
||||
cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>,
|
||||
instance: Instance<'tcx>,
|
||||
linkage: Linkage,
|
||||
) {
|
||||
let tcx = cx.tcx;
|
||||
|
||||
@ -65,7 +67,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
|
||||
// Step 2. Declare function
|
||||
let (name, sig) = get_function_name_and_sig(tcx, instance);
|
||||
let func_id = cx.module
|
||||
.declare_function(&name, Linkage::Export, &sig)
|
||||
.declare_function(&name, linkage, &sig)
|
||||
.unwrap();
|
||||
|
||||
// Step 3. Make FunctionBuilder
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -393,9 +393,17 @@ fn codegen_mono_items<'a, 'tcx: 'a>(
|
||||
) {
|
||||
let mut cx = CodegenCx::new(tcx, module);
|
||||
time("codegen mono items", move || {
|
||||
for (mono_item, (_linkage, _vis)) in mono_items {
|
||||
for (mono_item, (linkage, vis)) in mono_items {
|
||||
unimpl::try_unimpl(tcx, log, || {
|
||||
base::trans_mono_item(&mut cx, mono_item);
|
||||
let linkage = match (linkage, vis) {
|
||||
(RLinkage::External, Visibility::Default) => Linkage::Export,
|
||||
(RLinkage::Internal, Visibility::Default) => Linkage::Local,
|
||||
// FIXME this should get external linkage, but hidden visibility,
|
||||
// not internal linkage and default visibility
|
||||
| (RLinkage::External, Visibility::Hidden) => Linkage::Local,
|
||||
_ => panic!("{:?} = {:?} {:?}", mono_item, linkage, vis),
|
||||
};
|
||||
base::trans_mono_item(&mut cx, mono_item, linkage);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user