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.
This commit is contained in:
parent
d09851730c
commit
6c048723f8
7 changed files with 21 additions and 6 deletions
|
@ -211,7 +211,9 @@ mod imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough
|
// -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough
|
||||||
#[cfg(all(not(windows), not(target_os = "android")))]
|
#[cfg(all(not(windows),
|
||||||
|
not(target_os = "android"),
|
||||||
|
not(target_env = "musl")))]
|
||||||
#[link(name = "pthread")]
|
#[link(name = "pthread")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,15 @@ pub use funcs::bsd43::*;
|
||||||
|
|
||||||
// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them
|
// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them
|
||||||
// in when creating a test crate.
|
// in when creating a test crate.
|
||||||
#[cfg(not(any(windows, all(target_os = "nacl", test))))]
|
#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))]
|
||||||
#[link(name = "c")]
|
#[link(name = "c")]
|
||||||
#[link(name = "m")]
|
#[link(name = "m")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
||||||
|
#[cfg(all(target_env = "musl", not(test)))]
|
||||||
|
#[link(name = "c", kind = "static")]
|
||||||
|
extern {}
|
||||||
|
|
||||||
// libnacl provides functions that require a trip through the IRT to work.
|
// libnacl provides functions that require a trip through the IRT to work.
|
||||||
// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip
|
// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip
|
||||||
// to the kernel.
|
// to the kernel.
|
||||||
|
|
|
@ -125,7 +125,9 @@ mod tests {
|
||||||
use path::Path;
|
use path::Path;
|
||||||
|
|
||||||
#[test]
|
#[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() {
|
fn test_loading_cosine() {
|
||||||
// The math library does not need to be loaded since it is already
|
// The math library does not need to be loaded since it is already
|
||||||
// statically linked in
|
// statically linked in
|
||||||
|
|
|
@ -97,10 +97,15 @@ pub type _Unwind_Exception_Cleanup_Fn =
|
||||||
extern "C" fn(unwind_code: _Unwind_Reason_Code,
|
extern "C" fn(unwind_code: _Unwind_Reason_Code,
|
||||||
exception: *mut _Unwind_Exception);
|
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")]
|
#[link(name = "gcc_s")]
|
||||||
extern {}
|
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"))]
|
#[cfg(any(target_os = "android", target_os = "openbsd"))]
|
||||||
#[link(name = "gcc")]
|
#[link(name = "gcc")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern {}
|
||||||
//
|
//
|
||||||
// On Linux, librt and libdl are indirect dependencies via std,
|
// On Linux, librt and libdl are indirect dependencies via std,
|
||||||
// and binutils 2.22+ won't add them automatically
|
// 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 = "dl")]
|
||||||
#[link(name = "pthread")]
|
#[link(name = "pthread")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
|
@ -82,7 +82,8 @@ mod inner {
|
||||||
// OpenBSD provide it via libc
|
// OpenBSD provide it via libc
|
||||||
#[cfg(not(any(target_os = "android",
|
#[cfg(not(any(target_os = "android",
|
||||||
target_os = "bitrig",
|
target_os = "bitrig",
|
||||||
target_os = "openbsd")))]
|
target_os = "openbsd",
|
||||||
|
target_env = "musl")))]
|
||||||
#[link(name = "rt")]
|
#[link(name = "rt")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
||||||
|
|
|
@ -364,6 +364,7 @@ mod imp {
|
||||||
use sys_common::thread_local as os;
|
use sys_common::thread_local as os;
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
|
#[linkage = "extern_weak"]
|
||||||
static __dso_handle: *mut u8;
|
static __dso_handle: *mut u8;
|
||||||
#[linkage = "extern_weak"]
|
#[linkage = "extern_weak"]
|
||||||
static __cxa_thread_atexit_impl: *const ();
|
static __cxa_thread_atexit_impl: *const ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue