diff --git a/src/lib.rs b/src/lib.rs index 2be57129f0636b42ea39540d6370b6cf540a9e29..421631711cc4b48857ae3995a0d5ea9e2d8ea6ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ // Attributes needed when building as part of the standard library #![cfg_attr( feature = "rustc-dep-of-std", - feature(cfg_target_vendor, link_cfg, no_core) + feature(cfg_target_vendor, link_cfg, no_core, static_nobundle) )] #![cfg_attr(libc_thread_local, feature(thread_local))] // Enable extra lints: diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e8d91086989b05e58770e54e53c356010d37c283..3b2cc3f2ad049140533a123779a00b8bb1bc36ad 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -298,6 +298,26 @@ cfg_if! { } else if #[cfg(feature = "std")] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. + } else if #[cfg(all(target_os = "linux", + target_env = "gnu", + feature = "rustc-dep-of-std"))] { + #[link(name = "rt", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "pthread", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "m", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "c", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "gcc_eh", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "gcc", kind = "static-nobundle", + cfg(target_feature = "crt-static"))] + #[link(name = "rt", cfg(not(target_feature = "crt-static")))] + #[link(name = "pthread", cfg(not(target_feature = "crt-static")))] + #[link(name = "m", cfg(not(target_feature = "crt-static")))] + #[link(name = "c", cfg(not(target_feature = "crt-static")))] + extern {} } else if #[cfg(target_env = "musl")] { #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", kind = "static",