Skip to content

Commit

Permalink
Auto merge of #446 - alexcrichton:link-cfg, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Nov 10, 2016
2 parents 9195462 + f9323d1 commit 106fbed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -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))]
Expand Down
3 changes: 2 additions & 1 deletion src/unix/mod.rs
Expand Up @@ -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")]
Expand Down
5 changes: 3 additions & 2 deletions src/windows.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 106fbed

Please sign in to comment.