Skip to content

Commit 106fbed

Browse files
authored
Auto merge of #446 - alexcrichton:link-cfg, r=alexcrichton
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.
2 parents 9195462 + f9323d1 commit 106fbed

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575

7676
// Attributes needed when building as part of the standard library
7777
#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))]
78+
#![cfg_attr(stdbuild, feature(link_cfg))]
7879
#![cfg_attr(stdbuild, no_std)]
7980
#![cfg_attr(stdbuild, staged_api)]
8081
#![cfg_attr(stdbuild, allow(warnings))]

src/unix/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ cfg_if! {
205205
// cargo build, don't pull in anything extra as the libstd dep
206206
// already pulls in all libs.
207207
} else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
208-
#[link(name = "c", kind = "static")]
208+
#[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
209+
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
209210
extern {}
210211
} else if #[cfg(target_os = "emscripten")] {
211212
#[link(name = "c")]

src/windows.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ pub const ENOTEMPTY: ::c_int = 41;
146146
pub const EILSEQ: ::c_int = 42;
147147
pub const STRUNCATE: ::c_int = 80;
148148

149-
#[cfg(target_env = "msvc")] // " if " -- appease style checker
150-
#[link(name = "msvcrt")]
149+
#[cfg(all(target_env = "msvc", stdbuild))] // " if " -- appease style checker
150+
#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))]
151+
#[link(name = "libcmt", cfg(target_feature = "crt-static"))]
151152
extern {}
152153

153154
extern {

0 commit comments

Comments
 (0)