Skip to content

Commit a957c59

Browse files
authored
Use cfg_attr to gate musl linking
Fixes rust-lang#684. Previously building libc for musl would fail, because we don't want to use #[link(...)] outside a stdbuild. This commit fixes that issue. (Although it may leave other targets broken, I'm not sure.)
1 parent f9119d5 commit a957c59

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/unix/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ cfg_if! {
236236
// cargo build, don't pull in anything extra as the libstd dep
237237
// already pulls in all libs.
238238
} else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
239-
#[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
240-
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
239+
#[cfg_attr(stdbuild, link(name = "c", kind = "static", cfg(target_feature = "crt-static")))]
240+
#[cfg_attr(stdbuild, link(name = "c", cfg(not(target_feature = "crt-static"))))]
241241
extern {}
242242
} else if #[cfg(target_os = "emscripten")] {
243243
#[link(name = "c")]

0 commit comments

Comments
 (0)