about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-11 18:21:49 -0800
committerbors <bors@rust-lang.org>2014-02-11 18:21:49 -0800
commitdb8a580fb42cac26d2f2c69a6ecacc8c499ab71f (patch)
tree27e8b1b7929a4ed3af520c076a77904b44174345 /src
parenta4a908eafd49236e9b887031e3474fc5148b4e82 (diff)
parentb7651325eb3863c9869b7c684b1a4d9401544091 (diff)
downloadrust-db8a580fb42cac26d2f2c69a6ecacc8c499ab71f.tar.gz
rust-db8a580fb42cac26d2f2c69a6ecacc8c499ab71f.zip
auto merge of #12027 : vadimcn/rust/compiler-rt, r=alexcrichton
This is an attempt to remove some more of Rust's dependencies on libgcc and replace it with LLVM's compiler-rt lib.  I've added compiler-rt as a submodule and changed libstd to link with it.  
As far as I could verify, after this change, the only symbols still imported by std from libgcc are the stack unwinding functions.   Other crates, however, still picked up symbols from libgcc, not from libstd, as I had hoped.  So linking definitely requires some work. 

I've only tested this on windows, 32-bit linux and android and fully expect it to fail on other platforms. Patches are welcome.
Diffstat (limited to 'src')
m---------src/compiler-rt0
-rw-r--r--src/librustc/back/link.rs17
2 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler-rt b/src/compiler-rt
new file mode 160000
+Subproject d4606f1818dd8dfeaa3e509cd1cbac4482c3513
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 099f376aded..72ae70565a7 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -1005,6 +1005,7 @@ fn link_rlib(sess: Session,
 fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
     let mut a = link_rlib(sess, None, obj_filename, out_filename);
     a.add_native_library("morestack").unwrap();
+    a.add_native_library("compiler-rt").unwrap();
 
     let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
     for &(cnum, ref path) in crates.iter() {
@@ -1132,6 +1133,19 @@ fn link_args(sess: Session,
         args.push(~"-shared-libgcc");
     }
 
+    if sess.targ_cfg.os == abi::OsAndroid {
+        // Many of the symbols defined in compiler-rt are also defined in libgcc.
+        // Android linker doesn't like that by default.
+        args.push(~"-Wl,--allow-multiple-definition");
+    }
+
+    // Stack growth requires statically linking a __morestack function
+    args.push(~"-lmorestack");
+    // compiler-rt contains implementations of low-level LLVM helpers
+    // It should go before platform and user libraries, so it has first dibs
+    // at resolving symbols that also appear in libgcc.
+    args.push(~"-lcompiler-rt");
+
     add_local_native_libraries(&mut args, sess);
     add_upstream_rust_crates(&mut args, sess, dylib, tmpdir);
     add_upstream_native_libraries(&mut args, sess);
@@ -1159,9 +1173,6 @@ fn link_args(sess: Session,
                        ~"-L/usr/local/lib/gcc44"]);
     }
 
-    // Stack growth requires statically linking a __morestack function
-    args.push(~"-lmorestack");
-
     // FIXME (#2397): At some point we want to rpath our guesses as to
     // where extern libraries might live, based on the
     // addl_lib_search_paths