about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-04 13:17:30 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-26 16:58:37 -0800
commit4cdc6ce3374f934b6c8cab986d3b0c83119fed6f (patch)
treed7404154e3024272336c6893801db5f26f17323a /src
parenta15448c85a557a2b047e4ed94fb36000320cccb5 (diff)
downloadrust-4cdc6ce3374f934b6c8cab986d3b0c83119fed6f.tar.gz
rust-4cdc6ce3374f934b6c8cab986d3b0c83119fed6f.zip
rustc: Don't deduplicate libraries linked to
Linker argument order with respect to libraries is important enough that we
shouldn't be attempting to filter out libraries getting passed through to the
linker. When linking with a native library that has multiple dependant native
libraries, it's useful to have control over the link argument order.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/metadata/cstore.rs7
-rw-r--r--src/test/run-make/no-duplicate-libs/Makefile6
-rw-r--r--src/test/run-make/no-duplicate-libs/bar.c3
-rw-r--r--src/test/run-make/no-duplicate-libs/foo.c1
-rw-r--r--src/test/run-make/no-duplicate-libs/main.rs20
5 files changed, 31 insertions, 6 deletions
diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs
index baca85d50ae..d6cee8fadb5 100644
--- a/src/librustc/metadata/cstore.rs
+++ b/src/librustc/metadata/cstore.rs
@@ -154,15 +154,10 @@ impl CStore {
             .collect()
     }
 
-    pub fn add_used_library(&self, lib: ~str, kind: NativeLibaryKind)
-                            -> bool {
+    pub fn add_used_library(&self, lib: ~str, kind: NativeLibaryKind) {
         assert!(!lib.is_empty());
         let mut used_libraries = self.used_libraries.borrow_mut();
-        if used_libraries.get().iter().any(|&(ref x, _)| x == &lib) {
-            return false;
-        }
         used_libraries.get().push((lib, kind));
-        true
     }
 
     pub fn get_used_libraries<'a>(&'a self)
diff --git a/src/test/run-make/no-duplicate-libs/Makefile b/src/test/run-make/no-duplicate-libs/Makefile
new file mode 100644
index 00000000000..1417da3de36
--- /dev/null
+++ b/src/test/run-make/no-duplicate-libs/Makefile
@@ -0,0 +1,6 @@
+-include ../tools.mk
+
+all: $(call STATICLIB,foo) $(call STATICLIB,bar)
+	$(RUSTC) main.rs
+	$(call RUN,main)
+
diff --git a/src/test/run-make/no-duplicate-libs/bar.c b/src/test/run-make/no-duplicate-libs/bar.c
new file mode 100644
index 00000000000..330d914a011
--- /dev/null
+++ b/src/test/run-make/no-duplicate-libs/bar.c
@@ -0,0 +1,3 @@
+extern void foo();
+
+void bar() { foo(); }
diff --git a/src/test/run-make/no-duplicate-libs/foo.c b/src/test/run-make/no-duplicate-libs/foo.c
new file mode 100644
index 00000000000..85e6cd8c390
--- /dev/null
+++ b/src/test/run-make/no-duplicate-libs/foo.c
@@ -0,0 +1 @@
+void foo() {}
diff --git a/src/test/run-make/no-duplicate-libs/main.rs b/src/test/run-make/no-duplicate-libs/main.rs
new file mode 100644
index 00000000000..12ddce34582
--- /dev/null
+++ b/src/test/run-make/no-duplicate-libs/main.rs
@@ -0,0 +1,20 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[link(name = "foo")]
+#[link(name = "bar")]
+#[link(name = "foo")]
+extern {
+    fn bar();
+}
+
+fn main() {
+    unsafe { bar() }
+}