summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-10-31 16:44:29 -0700
committerAlex Crichton <alex@alexcrichton.com>2016-11-09 18:45:00 -0800
commitf9323d1a0a9afae5e017d2ec47e56c75ea268e2c (patch)
tree57f0c352094a6cc404df3724856a7f115e4bd2d2
parentb347e64ab1599b9f33a4dd2bf41e4203c59d20a6 (diff)
downloadrust-libc-f9323d1a0a9afae5e017d2ec47e56c75ea268e2c.tar.gz
Use `#[link(cfg(..))]` in preparation for libstd
In preparation for rust-lang/rust#37545 this is adding the appropriate directives to libc to get included.
-rw-r--r--src/lib.rs1
-rw-r--r--src/unix/mod.rs3
-rw-r--r--src/windows.rs5
3 files changed, 6 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index dcc4791f9a..2bc26aad61 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -75,6 +75,7 @@
// Attributes needed when building as part of the standard library
#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))]
+#![cfg_attr(stdbuild, feature(link_cfg))]
#![cfg_attr(stdbuild, no_std)]
#![cfg_attr(stdbuild, staged_api)]
#![cfg_attr(stdbuild, allow(warnings))]
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 0cb3f78dd2..b79bb9f8c5 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -205,7 +205,8 @@ cfg_if! {
// cargo build, don't pull in anything extra as the libstd dep
// already pulls in all libs.
} else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
- #[link(name = "c", kind = "static")]
+ #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
+ #[link(name = "c", cfg(not(target_feature = "crt-static")))]
extern {}
} else if #[cfg(target_os = "emscripten")] {
#[link(name = "c")]
diff --git a/src/windows.rs b/src/windows.rs
index b916fd4bd6..6c8332a62e 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -146,8 +146,9 @@ pub const ENOTEMPTY: ::c_int = 41;
pub const EILSEQ: ::c_int = 42;
pub const STRUNCATE: ::c_int = 80;
-#[cfg(target_env = "msvc")] // " if " -- appease style checker
-#[link(name = "msvcrt")]
+#[cfg(all(target_env = "msvc", stdbuild))] // " if " -- appease style checker
+#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
+#[link(name = "libcmt", cfg(target_feature = "crt-static"))]
extern {}
extern {