Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 721fe3b

Browse files
committed
Predefine all local functions before codegen
Otherwise only calls to previously codegened functions use relative addressing instead of the GOT Fixes rust-lang#692
1 parent 39796d1 commit 721fe3b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/driver.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,19 @@ fn codegen_mono_items<'tcx>(
307307
mono_items: FxHashMap<MonoItem<'tcx>, (RLinkage, Visibility)>,
308308
) {
309309
let mut cx = CodegenCx::new(tcx, module, debug_context);
310+
310311
time("codegen mono items", move || {
312+
for (&mono_item, &(linkage, visibility)) in &mono_items {
313+
match mono_item {
314+
MonoItem::Fn(instance) => {
315+
let (name, sig) = get_function_name_and_sig(tcx, instance, false);
316+
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
317+
cx.module.declare_function(&name, linkage, &sig).unwrap();
318+
}
319+
MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {}
320+
}
321+
}
322+
311323
for (mono_item, (linkage, visibility)) in mono_items {
312324
crate::unimpl::try_unimpl(tcx, log, || {
313325
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);

0 commit comments

Comments
 (0)