about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-21 15:56:55 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-27 10:11:15 -0700
commit6c048723f83fad6c96c2e19d6dfa1db547371c11 (patch)
treef73cdb4b5a30c302af48c94fc30f126e5d734364 /src/libstd
parentd09851730c47f49555c84b76dd6e71d91b0555ed (diff)
downloadrust-6c048723f83fad6c96c2e19d6dfa1db547371c11.tar.gz
rust-6c048723f83fad6c96c2e19d6dfa1db547371c11.zip
std: Prepare for linking to musl
This commit modifies the standard library and its dependencies to link correctly
when built against MUSL. This primarily ensures that the right libraries are
linked against and when they're linked against they're linked against
statically.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/dynamic_lib.rs4
-rw-r--r--src/libstd/rt/libunwind.rs7
-rw-r--r--src/libstd/rtdeps.rs2
-rw-r--r--src/libstd/sys/unix/time.rs3
-rw-r--r--src/libstd/thread/local.rs1
5 files changed, 13 insertions, 4 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs
index ef72cbc96e1..8b90fce6fc4 100644
--- a/src/libstd/dynamic_lib.rs
+++ b/src/libstd/dynamic_lib.rs
@@ -125,7 +125,9 @@ mod tests {
     use path::Path;
 
     #[test]
-    #[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379
+    #[cfg_attr(any(windows,
+                   target_os = "android",  // FIXME #10379
+                   target_env = "musl"), ignore)]
     fn test_loading_cosine() {
         // The math library does not need to be loaded since it is already
         // statically linked in
diff --git a/src/libstd/rt/libunwind.rs b/src/libstd/rt/libunwind.rs
index 4b754bd5f58..8f75ae5ef5c 100644
--- a/src/libstd/rt/libunwind.rs
+++ b/src/libstd/rt/libunwind.rs
@@ -97,10 +97,15 @@ pub type _Unwind_Exception_Cleanup_Fn =
         extern "C" fn(unwind_code: _Unwind_Reason_Code,
                       exception: *mut _Unwind_Exception);
 
-#[cfg(any(target_os = "linux", target_os = "freebsd"))]
+#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
+          target_os = "freebsd"))]
 #[link(name = "gcc_s")]
 extern {}
 
+#[cfg(all(target_os = "linux", target_env = "musl", not(test)))]
+#[link(name = "unwind", kind = "static")]
+extern {}
+
 #[cfg(any(target_os = "android", target_os = "openbsd"))]
 #[link(name = "gcc")]
 extern {}
diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs
index 96c4bcec853..a7f3bc2bdc8 100644
--- a/src/libstd/rtdeps.rs
+++ b/src/libstd/rtdeps.rs
@@ -24,7 +24,7 @@ extern {}
 //
 // On Linux, librt and libdl are indirect dependencies via std,
 // and binutils 2.22+ won't add them automatically
-#[cfg(target_os = "linux")]
+#[cfg(all(target_os = "linux", not(target_env = "musl")))]
 #[link(name = "dl")]
 #[link(name = "pthread")]
 extern {}
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs
index d2f51678d49..f59eb2c0301 100644
--- a/src/libstd/sys/unix/time.rs
+++ b/src/libstd/sys/unix/time.rs
@@ -82,7 +82,8 @@ mod inner {
     // OpenBSD provide it via libc
     #[cfg(not(any(target_os = "android",
                   target_os = "bitrig",
-                  target_os = "openbsd")))]
+                  target_os = "openbsd",
+                  target_env = "musl")))]
     #[link(name = "rt")]
     extern {}
 
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index 6d8f1cba709..5b7d6fdd864 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -364,6 +364,7 @@ mod imp {
         use sys_common::thread_local as os;
 
         extern {
+            #[linkage = "extern_weak"]
             static __dso_handle: *mut u8;
             #[linkage = "extern_weak"]
             static __cxa_thread_atexit_impl: *const ();