Skip to content

Commit f77c5ba

Browse files
committed
rustc: Wait until generic glue is actually emitted to define it as internal
The verifier was not liking this when generating unoptimized bitcode. Per LLVM docs it is not valid for function declarations to be marked internal, but their implementations may be.
1 parent 8eaafda commit f77c5ba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,8 @@ fn decl_fastcall_fn(ModuleRef llmod, &str name, TypeRef llty) -> ValueRef {
10391039
ret decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
10401040
}
10411041

1042+
// Only use this if you are going to actually define the function. It's
1043+
// not valid to simply declare a function as internal.
10421044
fn decl_internal_fastcall_fn(ModuleRef llmod,
10431045
&str name, TypeRef llty) -> ValueRef {
10441046
auto llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
@@ -1861,7 +1863,7 @@ fn declare_generic_glue(&@local_ctxt cx,
18611863
} else {
18621864
fn_nm = mangle_name_by_seq(cx.ccx, cx.path, "glue_" + name);
18631865
}
1864-
auto llfn = decl_internal_fastcall_fn(cx.ccx.llmod, fn_nm, llfnty);
1866+
auto llfn = decl_fastcall_fn(cx.ccx.llmod, fn_nm, llfnty);
18651867
ret llfn;
18661868
}
18671869

@@ -1872,6 +1874,9 @@ fn make_generic_glue(&@local_ctxt cx,
18721874
&vec[uint] ty_params) -> ValueRef {
18731875
auto fcx = new_fn_ctxt(cx, llfn);
18741876

1877+
llvm::LLVMSetLinkage(llfn, lib::llvm::LLVMInternalLinkage
1878+
as llvm::Linkage);
1879+
18751880
cx.ccx.stats.n_glues_created += 1u;
18761881

18771882
// Any nontrivial glue is with values passed *by alias*; this is a

0 commit comments

Comments
 (0)