Skip to content

Fix --no-default-features builds #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ build: false

test_script:
- cargo test --target %TARGET%
- cargo test --no-default-features --target %TARGET%
- cargo test --manifest-path libc-test/Cargo.toml --target %TARGET%
1 change: 1 addition & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
opt="--release"
fi

cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target $TARGET
exec cargo test $opt --manifest-path libc-test/Cargo.toml --target $TARGET
10 changes: 8 additions & 2 deletions libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
build = "build.rs"

[dependencies]
libc = { path = ".." }
[dependencies.libc]
path = ".."
default-features = false

[build-dependencies]
ctest = { git = "https://github.com/alexcrichton/ctest" }

[features]
default = [ "use_std" ]
use_std = [ "libc/use_std" ]

[[test]]
name = "main"
path = "test/main.rs"
Expand All @@ -19,3 +24,4 @@ harness = false
name = "linux-fcntl"
path = "test/linux_fcntl.rs"
harness = false

10 changes: 7 additions & 3 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,20 @@ cfg_if! {
// cargo build, don't pull in anything extra as the libstd dep
// already pulls in all libs.
} else if #[cfg(target_env = "musl")] {
#[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
#[cfg_attr(feature = "stdbuild",
link(name = "c", kind = "static",
cfg(target_feature = "crt-static")))]
#[cfg_attr(feature = "stdbuild",
link(name = "c", cfg(not(target_feature = "crt-static"))))]
extern {}
} else if #[cfg(target_os = "emscripten")] {
#[link(name = "c")]
extern {}
} else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] {
} else if #[cfg(all(target_os = "netbsd"))] {
// 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.
#[cfg_attr(feature = "stdbuild", target_vendor = "rumprun")]
#[link(name = "m")]
extern {}
} else if #[cfg(any(target_os = "macos",
Expand Down