Skip to content

mark functions internal if not building a library #9474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,23 @@ pub fn trans_mod(ccx: @mut CrateContext, m: &ast::_mod) {
}
}

fn finish_register_fn(ccx: @mut CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId,
llfn: ValueRef) {
ccx.item_symbols.insert(node_id, sym);

if !*ccx.sess.building_library {
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
}

// FIXME #4404 android JNI hacks
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
(*ccx.sess.building_library &&
ccx.sess.targ_cfg.os == session::OsAndroid));
if is_entry {
create_entry_wrapper(ccx, sp, llfn);
}
}

pub fn register_fn(ccx: @mut CrateContext,
sp: Span,
sym: ~str,
Expand All @@ -2336,15 +2353,7 @@ pub fn register_fn(ccx: @mut CrateContext,
};

let llfn = decl_rust_fn(ccx, f.sig.inputs, f.sig.output, sym);
ccx.item_symbols.insert(node_id, sym);

// FIXME #4404 android JNI hacks
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
(*ccx.sess.building_library &&
ccx.sess.targ_cfg.os == session::OsAndroid));
if is_entry {
create_entry_wrapper(ccx, sp, llfn);
}
finish_register_fn(ccx, sp, sym, node_id, llfn);
llfn
}

Expand All @@ -2361,15 +2370,7 @@ pub fn register_fn_llvmty(ccx: @mut CrateContext,
ast_map::path_to_str(item_path(ccx, &node_id), token::get_ident_interner()));

let llfn = decl_fn(ccx.llmod, sym, cc, fn_ty);
ccx.item_symbols.insert(node_id, sym);

// FIXME #4404 android JNI hacks
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
(*ccx.sess.building_library &&
ccx.sess.targ_cfg.os == session::OsAndroid));
if is_entry {
create_entry_wrapper(ccx, sp, llfn);
}
finish_register_fn(ccx, sp, sym, node_id, llfn);
llfn
}

Expand Down