@@ -2321,6 +2321,23 @@ pub fn trans_mod(ccx: @mut CrateContext, m: &ast::_mod) {
23212321 }
23222322}
23232323
2324+ fn finish_register_fn ( ccx : @mut CrateContext , sp : Span , sym : ~str , node_id : ast:: NodeId ,
2325+ llfn : ValueRef ) {
2326+ ccx. item_symbols . insert ( node_id, sym) ;
2327+
2328+ if !* ccx. sess . building_library {
2329+ lib:: llvm:: SetLinkage ( llfn, lib:: llvm:: InternalLinkage ) ;
2330+ }
2331+
2332+ // FIXME #4404 android JNI hacks
2333+ let is_entry = is_entry_fn ( & ccx. sess , node_id) && ( !* ccx. sess . building_library ||
2334+ ( * ccx. sess . building_library &&
2335+ ccx. sess . targ_cfg . os == session:: OsAndroid ) ) ;
2336+ if is_entry {
2337+ create_entry_wrapper ( ccx, sp, llfn) ;
2338+ }
2339+ }
2340+
23242341pub fn register_fn ( ccx : @mut CrateContext ,
23252342 sp : Span ,
23262343 sym : ~str ,
@@ -2336,15 +2353,7 @@ pub fn register_fn(ccx: @mut CrateContext,
23362353 } ;
23372354
23382355 let llfn = decl_rust_fn ( ccx, f. sig . inputs , f. sig . output , sym) ;
2339- ccx. item_symbols . insert ( node_id, sym) ;
2340-
2341- // FIXME #4404 android JNI hacks
2342- let is_entry = is_entry_fn ( & ccx. sess , node_id) && ( !* ccx. sess . building_library ||
2343- ( * ccx. sess . building_library &&
2344- ccx. sess . targ_cfg . os == session:: OsAndroid ) ) ;
2345- if is_entry {
2346- create_entry_wrapper ( ccx, sp, llfn) ;
2347- }
2356+ finish_register_fn ( ccx, sp, sym, node_id, llfn) ;
23482357 llfn
23492358}
23502359
@@ -2361,15 +2370,7 @@ pub fn register_fn_llvmty(ccx: @mut CrateContext,
23612370 ast_map:: path_to_str( item_path( ccx, & node_id) , token:: get_ident_interner( ) ) ) ;
23622371
23632372 let llfn = decl_fn ( ccx. llmod , sym, cc, fn_ty) ;
2364- ccx. item_symbols . insert ( node_id, sym) ;
2365-
2366- // FIXME #4404 android JNI hacks
2367- let is_entry = is_entry_fn ( & ccx. sess , node_id) && ( !* ccx. sess . building_library ||
2368- ( * ccx. sess . building_library &&
2369- ccx. sess . targ_cfg . os == session:: OsAndroid ) ) ;
2370- if is_entry {
2371- create_entry_wrapper ( ccx, sp, llfn) ;
2372- }
2373+ finish_register_fn ( ccx, sp, sym, node_id, llfn) ;
23732374 llfn
23742375}
23752376
0 commit comments