From a957c59ffd1f91501fda0baec6077bf71074ec58 Mon Sep 17 00:00:00 2001 From: Others Date: Tue, 25 Jul 2017 14:12:34 -0400 Subject: [PATCH] Use cfg_attr to gate musl linking Fixes #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.) --- src/unix/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cb66c049fd013..2d210196abacb 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -236,8 +236,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", cfg(target_feature = "crt-static"))] - #[link(name = "c", cfg(not(target_feature = "crt-static")))] + #[cfg_attr(stdbuild, link(name = "c", kind = "static", cfg(target_feature = "crt-static")))] + #[cfg_attr(stdbuild, link(name = "c", cfg(not(target_feature = "crt-static"))))] extern {} } else if #[cfg(target_os = "emscripten")] { #[link(name = "c")]