diff options
| author | Haitao Li <lihaitao@gmail.com> | 2012-04-09 14:38:53 +0800 |
|---|---|---|
| committer | Haitao Li <lihaitao@gmail.com> | 2012-04-09 14:38:53 +0800 |
| commit | 46e4aaa0be9400ea9fedf59ce93b073ef8800339 (patch) | |
| tree | 649895ba42b99611bc78b366f15f79d8d34c8c50 | |
| parent | 460b92a37ff8b8a913c1d92c4755be66b3cee8aa (diff) | |
| download | rust-46e4aaa0be9400ea9fedf59ce93b073ef8800339.tar.gz rust-46e4aaa0be9400ea9fedf59ce93b073ef8800339.zip | |
rustc: External fns declared as fns not global variables
Issue #2167
| -rw-r--r-- | src/rustc/middle/trans/base.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 53a088d82aa..93f88b158c2 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -1772,11 +1772,17 @@ fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind) fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) -> ValueRef { let name = csearch::get_symbol(ccx.sess.cstore, did); - let llty = alt ty::get(t).struct { - ty::ty_fn(_) { type_of_fn_from_ty(ccx, t) } - _ { type_of(ccx, t) } + alt ty::get(t).struct { + ty::ty_fn(_) { + let llty = type_of_fn_from_ty(ccx, t); + ret get_extern_fn(ccx.externs, ccx.llmod, name, + lib::llvm::CCallConv, llty); + } + _ { + let llty = type_of(ccx, t); + ret get_extern_const(ccx.externs, ccx.llmod, name, llty); + } }; - ret get_extern_const(ccx.externs, ccx.llmod, name, llty); } 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, let start_ty = T_fn([val_ty(rust_main), ccx.int_type, ccx.int_type, val_ty(crate_map)], ccx.int_type); let start = decl_cdecl_fn(ccx.llmod, "rust_start", start_ty); + let args = [rust_main, llvm::LLVMGetParam(llfn, 0 as c_uint), llvm::LLVMGetParam(llfn, 1 as c_uint), crate_map]; let result = unsafe { |
