From f936be41308de044684df86697647b6fb661f9ca Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Thu, 5 Oct 2017 18:58:36 -0400 Subject: [PATCH 1/3] Attempt to fix musl build. --- .travis.yml | 4 ++-- src/unix/mod.rs | 4 ++-- src/windows.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 978772867518d..982b9994480af 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; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cc2de9136f971..398447b030e9d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -229,8 +229,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")] diff --git a/src/windows.rs b/src/windows.rs index bdb0e02f1b5e3..0630e9ef31421 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -160,8 +160,8 @@ pub const STRUNCATE: ::c_int = 80; // inline comment below appeases style checker #[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if " -#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] -#[link(name = "libcmt", cfg(target_feature = "crt-static"))] +#[cfg_attr(stdbuild, link(name = "msvcrt", cfg(not(target_feature = "crt-static"))))] +#[cfg_attr(stdbuild, link(name = "libcmt", cfg(target_feature = "crt-static")))] extern {} extern { From d5d989e26488ea82dc2c48f50f302d6a93f51230 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sun, 8 Oct 2017 18:09:29 -0400 Subject: [PATCH 2/3] Fix style. --- .gitignore | 1 + src/unix/mod.rs | 8 ++++++-- src/windows.rs | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f0ff2599d09b5..48fdc77961230 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target Cargo.lock *~ +/style diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 398447b030e9d..6d62e72f9ae25 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -229,8 +229,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")] diff --git a/src/windows.rs b/src/windows.rs index 0630e9ef31421..0a74f1d57d292 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -160,8 +160,10 @@ pub const STRUNCATE: ::c_int = 80; // inline comment below appeases style checker #[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if " -#[cfg_attr(stdbuild, link(name = "msvcrt", cfg(not(target_feature = "crt-static"))))] -#[cfg_attr(stdbuild, link(name = "libcmt", cfg(target_feature = "crt-static")))] +#[cfg_attr(stdbuild, + link(name = "msvcrt", cfg(not(target_feature = "crt-static"))))] +#[cfg_attr(stdbuild, + link(name = "libcmt", cfg(target_feature = "crt-static")))] extern {} extern { From 59904c6efe05c7c22ca070563b217c7dd1a7762b Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sun, 8 Oct 2017 18:54:39 -0400 Subject: [PATCH 3/3] Fix freebsd. --- src/unix/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6d62e72f9ae25..0d7933af382ed 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -239,7 +239,8 @@ cfg_if! { } else if #[cfg(target_os = "emscripten")] { #[link(name = "c")] extern {} - } else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] { + } else if #[cfg(all(stdbuild, + target_os = "netbsd", target_vendor = "rumprun"))] { // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled // in automatically by the linker. We avoid passing it explicitly, as it // causes some versions of binutils to crash with an assertion failure.