summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2020-09-19 16:39:31 -0700
committerJosh Triplett <josh@joshtriplett.org>2020-09-21 01:14:06 -0700
commitac0a783953832205372cb6b6982f2071f9170964 (patch)
tree8205e740fdbb93aca6d3fdede61931b5d346eb0a
parent999e5e1f287458bf5531783da1b500a9ddb5ac74 (diff)
downloadrust-libc-ac0a783953832205372cb6b6982f2071f9170964.tar.gz
Add support for building with static glibc
This will need corresponding changes in rust-lang/rust to activate, but this will make it possible to make those changes. Note that despite the apparent redundancy in config directives, the link directives cannot be simplified any further. Attempting to factor out the checks for `target_feature = "crt-static"` does not work.
-rw-r--r--src/lib.rs2
-rw-r--r--src/unix/mod.rs20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2be57129f0..421631711c 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 e8d9108698..3b2cc3f2ad 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",