about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-03-18 10:54:35 +1300
committerAlex Crichton <alex@alexcrichton.com>2014-03-18 13:48:12 -0700
commit3301223c99574d53bbdcd06ac85b3cec255128e0 (patch)
tree97122b57772371982471530ca39014825094f9bf /src
parent083d423976359c3a0222907b588df534cfc17a28 (diff)
downloadrust-3301223c99574d53bbdcd06ac85b3cec255128e0.tar.gz
rust-3301223c99574d53bbdcd06ac85b3cec255128e0.zip
Fix linkage1 test which fails due to --as-needed
It appears that the --as-needed flag to linkers will not pull in a dynamic library unless it satisfies a non weak undefined symbol. The linkage1 test was creating a dynamic library where it was only used for a weak-symbol as part of an executable, so the dynamic library was getting discarded.

This commit adds another symbol to the library which satisfies a strong undefined symbol, so the library is pulled in to resolve the weak reference.
Diffstat (limited to 'src')
-rw-r--r--src/test/auxiliary/linkage1.rs2
-rw-r--r--src/test/run-pass/linkage1.rs7
2 files changed, 9 insertions, 0 deletions
diff --git a/src/test/auxiliary/linkage1.rs b/src/test/auxiliary/linkage1.rs
index 9017ee88363..a74c8c47cd9 100644
--- a/src/test/auxiliary/linkage1.rs
+++ b/src/test/auxiliary/linkage1.rs
@@ -10,3 +10,5 @@
 
 #[no_mangle]
 pub static foo: int = 3;
+
+pub fn bar() {}
diff --git a/src/test/run-pass/linkage1.rs b/src/test/run-pass/linkage1.rs
index 8f8b0cfecb2..c6f672c5d34 100644
--- a/src/test/run-pass/linkage1.rs
+++ b/src/test/run-pass/linkage1.rs
@@ -26,6 +26,13 @@ extern {
 }
 
 fn main() {
+    // It appears that the --as-needed flag to linkers will not pull in a dynamic
+    // library unless it satisfies a non weak undefined symbol. The 'other' crate
+    // is compiled as a dynamic library where it would only be used for a
+    // weak-symbol as part of an executable, so the dynamic library woudl be
+    // discarded. By adding and calling `other::bar`, we get around this problem.
+    other::bar();
+
     assert!(!foo.is_null());
     assert_eq!(unsafe { *foo }, 3);
     assert!(something_that_should_never_exist.is_null());