about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-05-28 08:49:07 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2014-05-28 09:03:51 +1000
commita167caf1061ea81cb946ff4be2ca31cc1bc98310 (patch)
treed2c66fe78dcc96e59b90d22c5dadf1565810c57c
parent746d086f9322d24fa7b389dd911e204ca35012ae (diff)
downloadrust-a167caf1061ea81cb946ff4be2ca31cc1bc98310.tar.gz
rust-a167caf1061ea81cb946ff4be2ca31cc1bc98310.zip
rustc: clarify warning about native deps for a staticlib.
This adjusts the "unlinked native library" warning one receives when
compiling with `crate_type="staticlib"`. The warning is just trying to
tell the user that they need to link against these libraries, but the
old text wasn't making this obvious; the new text says this explicitly.
-rw-r--r--src/librustc/back/link.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 89a79dbb80d..3939f708b5d 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -1019,6 +1019,8 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
     a.add_native_library("compiler-rt").unwrap();
 
     let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
+    let mut all_native_libs = vec![];
+
     for &(cnum, ref path) in crates.iter() {
         let name = sess.cstore.get_crate_data(cnum).name.clone();
         let p = match *path {
@@ -1029,17 +1031,25 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
             }
         };
         a.add_rlib(&p, name.as_slice(), sess.lto()).unwrap();
+
         let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
-        for &(kind, ref lib) in native_libs.iter() {
-            let name = match kind {
-                cstore::NativeStatic => "static library",
-                cstore::NativeUnknown => "library",
-                cstore::NativeFramework => "framework",
-            };
-            sess.warn(format!("unlinked native {}: {}",
-                              name,
-                              *lib).as_slice());
-        }
+        all_native_libs.extend(native_libs.move_iter());
+    }
+
+    if !all_native_libs.is_empty() {
+        sess.warn("link against the following native artifacts when linking against \
+                  this static library");
+        sess.note("the order and any duplication can be significant on some platforms, \
+                  and so may need to be preserved");
+    }
+
+    for &(kind, ref lib) in all_native_libs.iter() {
+        let name = match kind {
+            cstore::NativeStatic => "static library",
+            cstore::NativeUnknown => "library",
+            cstore::NativeFramework => "framework",
+        };
+        sess.note(format!("{}: {}", name, *lib).as_slice());
     }
 }