@@ -1003,6 +1003,7 @@ fn link_rlib(sess: Session,
1003
1003
fn link_staticlib ( sess : Session , obj_filename : & Path , out_filename : & Path ) {
1004
1004
let mut a = link_rlib ( sess, None , obj_filename, out_filename) ;
1005
1005
a. add_native_library ( "morestack" ) . unwrap ( ) ;
1006
+ a. add_native_library ( "compiler-rt" ) . unwrap ( ) ;
1006
1007
1007
1008
let crates = sess. cstore . get_used_crates ( cstore:: RequireStatic ) ;
1008
1009
for & ( cnum, ref path) in crates. iter ( ) {
@@ -1130,6 +1131,19 @@ fn link_args(sess: Session,
1130
1131
args. push ( ~"-shared-libgcc") ;
1131
1132
}
1132
1133
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
+
1133
1147
add_local_native_libraries ( & mut args, sess) ;
1134
1148
add_upstream_rust_crates ( & mut args, sess, dylib, tmpdir) ;
1135
1149
add_upstream_native_libraries ( & mut args, sess) ;
@@ -1157,9 +1171,6 @@ fn link_args(sess: Session,
1157
1171
~"-L /usr/local/lib/gcc44"] ) ;
1158
1172
}
1159
1173
1160
- // Stack growth requires statically linking a __morestack function
1161
- args. push ( ~"-lmorestack") ;
1162
-
1163
1174
// FIXME (#2397): At some point we want to rpath our guesses as to
1164
1175
// where extern libraries might live, based on the
1165
1176
// addl_lib_search_paths
0 commit comments