Skip to content

Commit a167caf

Browse files
committed
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.
1 parent 746d086 commit a167caf

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/librustc/back/link.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,8 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
10191019
a.add_native_library("compiler-rt").unwrap();
10201020

10211021
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
1022+
let mut all_native_libs = vec![];
1023+
10221024
for &(cnum, ref path) in crates.iter() {
10231025
let name = sess.cstore.get_crate_data(cnum).name.clone();
10241026
let p = match *path {
@@ -1029,17 +1031,25 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
10291031
}
10301032
};
10311033
a.add_rlib(&p, name.as_slice(), sess.lto()).unwrap();
1034+
10321035
let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
1033-
for &(kind, ref lib) in native_libs.iter() {
1034-
let name = match kind {
1035-
cstore::NativeStatic => "static library",
1036-
cstore::NativeUnknown => "library",
1037-
cstore::NativeFramework => "framework",
1038-
};
1039-
sess.warn(format!("unlinked native {}: {}",
1040-
name,
1041-
*lib).as_slice());
1042-
}
1036+
all_native_libs.extend(native_libs.move_iter());
1037+
}
1038+
1039+
if !all_native_libs.is_empty() {
1040+
sess.warn("link against the following native artifacts when linking against \
1041+
this static library");
1042+
sess.note("the order and any duplication can be significant on some platforms, \
1043+
and so may need to be preserved");
1044+
}
1045+
1046+
for &(kind, ref lib) in all_native_libs.iter() {
1047+
let name = match kind {
1048+
cstore::NativeStatic => "static library",
1049+
cstore::NativeUnknown => "library",
1050+
cstore::NativeFramework => "framework",
1051+
};
1052+
sess.note(format!("{}: {}", name, *lib).as_slice());
10431053
}
10441054
}
10451055

0 commit comments

Comments
 (0)