@@ -1003,6 +1003,7 @@ fn link_rlib(sess: Session,
10031003fn link_staticlib ( sess : Session , obj_filename : & Path , out_filename : & Path ) {
10041004 let mut a = link_rlib ( sess, None , obj_filename, out_filename) ;
10051005 a. add_native_library ( "morestack" ) . unwrap ( ) ;
1006+ a. add_native_library ( "compiler-rt" ) . unwrap ( ) ;
10061007
10071008 let crates = sess. cstore . get_used_crates ( cstore:: RequireStatic ) ;
10081009 for & ( cnum, ref path) in crates. iter ( ) {
@@ -1130,6 +1131,19 @@ fn link_args(sess: Session,
11301131 args. push ( ~"-shared-libgcc") ;
11311132 }
11321133
1134+ if sess. targ_cfg . os == abi:: OsAndroid {
1135+ // Many of the symbols defined in compiler-rt are also defined in libgcc.
1136+ // Android linker doesn't like that by default.
1137+ args. push ( ~"-Wl , --allow-multiple-definition") ;
1138+ }
1139+
1140+ // Stack growth requires statically linking a __morestack function
1141+ args. push ( ~"-lmorestack") ;
1142+ // compiler-rt contains implementations of low-level LLVM helpers
1143+ // It should go before platform and user libraries, so it has first dibs
1144+ // at resolving symbols that also appear in libgcc.
1145+ args. push ( ~"-lcompiler-rt") ;
1146+
11331147 add_local_native_libraries ( & mut args, sess) ;
11341148 add_upstream_rust_crates ( & mut args, sess, dylib, tmpdir) ;
11351149 add_upstream_native_libraries ( & mut args, sess) ;
@@ -1157,9 +1171,6 @@ fn link_args(sess: Session,
11571171 ~"-L /usr/local/lib/gcc44"] ) ;
11581172 }
11591173
1160- // Stack growth requires statically linking a __morestack function
1161- args. push ( ~"-lmorestack") ;
1162-
11631174 // FIXME (#2397): At some point we want to rpath our guesses as to
11641175 // where extern libraries might live, based on the
11651176 // addl_lib_search_paths
0 commit comments