From a957c59ffd1f91501fda0baec6077bf71074ec58 Mon Sep 17 00:00:00 2001 From: Others Date: Tue, 25 Jul 2017 14:12:34 -0400 Subject: [PATCH 1/4] 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")] From 222a6ad6e89c8f162153a2c00a61aead0cf62eb2 Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Thu, 20 Jul 2017 12:49:01 -0400 Subject: [PATCH 2/4] Testing CI change --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a397979424b6..2f6076c05d70f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ services: install: - if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi script: - - cargo build - - cargo build --no-default-features + - cargo build --target=$TARGET + - cargo build --no-default-features --target=$TARGET - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - if [[ $TRAVIS_OS_NAME = "linux" ]]; then sh ci/run-docker.sh $TARGET; From 12c82f098421451c24a2a523f13cc07927e316a2 Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 26 Jul 2017 10:59:59 -0400 Subject: [PATCH 3/4] Fix too long lines in src/unix/mod.rs --- src/unix/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2d210196abacb..f8cc0c345c938 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -236,8 +236,12 @@ 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"))))] { - #[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"))))] + #[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")] From 8a3ae0f8f730f5a194eb669273475840dd77cf1d Mon Sep 17 00:00:00 2001 From: Gregor Peach Date: Wed, 26 Jul 2017 21:35:15 -0400 Subject: [PATCH 4/4] Gate all `link` attributes behind stdbuild being enabled --- src/unix/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index f8cc0c345c938..d38ad1b7881a8 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -232,16 +232,12 @@ pub const INADDR_NONE: in_addr_t = 4294967295; cfg_if! { if #[cfg(dox)] { // on dox builds don't pull in anything - } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { + } else if #[cfg(any(not(stdbuild), feature = "use_std"))] { // 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"))))] { - #[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"))))] + #[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")]