Skip to content

Commit 46e4aaa

Browse files
committed
rustc: External fns declared as fns not global variables
Issue #2167
1 parent 460b92a commit 46e4aaa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/rustc/middle/trans/base.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1772,11 +1772,17 @@ fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind)
17721772
fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t)
17731773
-> ValueRef {
17741774
let name = csearch::get_symbol(ccx.sess.cstore, did);
1775-
let llty = alt ty::get(t).struct {
1776-
ty::ty_fn(_) { type_of_fn_from_ty(ccx, t) }
1777-
_ { type_of(ccx, t) }
1775+
alt ty::get(t).struct {
1776+
ty::ty_fn(_) {
1777+
let llty = type_of_fn_from_ty(ccx, t);
1778+
ret get_extern_fn(ccx.externs, ccx.llmod, name,
1779+
lib::llvm::CCallConv, llty);
1780+
}
1781+
_ {
1782+
let llty = type_of(ccx, t);
1783+
ret get_extern_const(ccx.externs, ccx.llmod, name, llty);
1784+
}
17781785
};
1779-
ret get_extern_const(ccx.externs, ccx.llmod, name, llty);
17801786
}
17811787

17821788
fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> {
@@ -4498,6 +4504,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
44984504
let start_ty = T_fn([val_ty(rust_main), ccx.int_type, ccx.int_type,
44994505
val_ty(crate_map)], ccx.int_type);
45004506
let start = decl_cdecl_fn(ccx.llmod, "rust_start", start_ty);
4507+
45014508
let args = [rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint),
45024509
llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map];
45034510
let result = unsafe {

0 commit comments

Comments
 (0)