Skip to content

Commit

Permalink
Auto merge of #1467 - gnzlbg:fix_freebsd, r=gnzlbg
Browse files Browse the repository at this point in the history
Fix FreeBSD

#1440 broke FreeBSD by changing `libc` FreeBSD targets to require a `cfg(freebsdXX)` to be defined, but not updating `build.rs` to define `freebsd11` when `LIBC_CI` is not available. Since `LIBC_CI` is always defined on CI, this issue went undetected.

This PR fixes that issue in the `build.rs` and introduces a build task that tests FreeBSD without `LIBC_CI` on FreeBSD11, although I'm  not sure this would have caught the issue in #1466 .

Closes #1466 .
  • Loading branch information
bors committed Aug 15, 2019
2 parents d7907c0 + f081694 commit 37f8f8d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .cirrus.yml
Expand Up @@ -10,6 +10,7 @@ task:
- rustup default stable
test_script:
- . $HOME/.cargo/env
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
- sh ci/run.sh x86_64-unknown-freebsd

task:
Expand All @@ -24,4 +25,5 @@ task:
- rustup default nightly
test_script:
- . $HOME/.cargo/env
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
- sh ci/run.sh x86_64-unknown-freebsd
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "libc"
version = "0.2.61"
version = "0.2.62"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
21 changes: 11 additions & 10 deletions build.rs
Expand Up @@ -7,6 +7,8 @@ fn main() {
rustc_minor_version().expect("Failed to get rustc version");
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
#[allow(unused)]
let libc_ci = env::var("LIBC_CI").is_ok();

if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
Expand All @@ -15,16 +17,15 @@ fn main() {
);
}

if env::var("LIBC_CI").is_ok() {
if let Some(11) = which_freebsd() {
println!("cargo:rustc-cfg=freebsd11");
}
if let Some(12) = which_freebsd() {
println!("cargo:rustc-cfg=freebsd12");
}
if let Some(13) = which_freebsd() {
println!("cargo:rustc-cfg=freebsd13");
}
// The ABI of libc is backward compatible with FreeBSD 11.
//
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
// running tests to ensure that the ABI is correct.
match which_freebsd() {
Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
}

// Rust >= 1.15 supports private module use:
Expand Down
10 changes: 5 additions & 5 deletions ci/azure.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
vmImage: ubuntu-16.04
steps:
- template: azure-install-rust.yml
- bash: sh ./ci/run-docker.sh $TARGET
- bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
displayName: Execute run-docker.sh
strategy:
matrix:
Expand All @@ -30,7 +30,7 @@ jobs:
vmImage: ubuntu-16.04
steps:
- template: azure-install-rust.yml
- bash: sh ./ci/run-docker.sh $TARGET
- bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
displayName: Execute run-docker.sh
strategy:
matrix:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
vmImage: macos-10.14
steps:
- template: azure-install-rust.yml
- bash: sh ./ci/run.sh $TARGET
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
displayName: Execute run.sh
strategy:
matrix:
Expand All @@ -100,7 +100,7 @@ jobs:
vmImage: macos-10.13
steps:
- template: azure-install-rust.yml
- bash: sh ./ci/run.sh $TARGET
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
displayName: Execute run.sh
strategy:
matrix:
Expand All @@ -112,7 +112,7 @@ jobs:
vmImage: vs2017-win2016
steps:
- template: azure-install-rust.yml
- bash: sh ./ci/run.sh $TARGET
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
displayName: Execute run.sh
strategy:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions ci/dox.sh
Expand Up @@ -47,6 +47,9 @@ while read -r target; do

rustup target add "${target}" || true

# Enable extra configuration flags:
export RUSTDOCFLAGS="--cfg freebsd11"

# If cargo doc fails, then try xargo:
if ! cargo doc --target "${target}" \
--no-default-features --features extra_traits ; then
Expand Down
1 change: 1 addition & 0 deletions ci/run-docker.sh
Expand Up @@ -23,6 +23,7 @@ run() {
docker run \
--rm \
--user "$(id -u)":"$(id -g)" \
--env LIBC_CI \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \
Expand Down
2 changes: 0 additions & 2 deletions ci/run.sh
Expand Up @@ -87,8 +87,6 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
opt="--release"
fi

export LIBC_CI=1

cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \
--target "${TARGET}"

Expand Down
4 changes: 3 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -1334,9 +1334,11 @@ cfg_if! {
} else if #[cfg(freebsd13)] {
mod freebsd12;
pub use self::freebsd12::*;
} else {
} else if #[cfg(freebsd11)] {
mod freebsd11;
pub use self::freebsd11::*;
} else {
// Unknown freebsd version
}
}

Expand Down

0 comments on commit 37f8f8d

Please sign in to comment.