diff --git a/.cirrus.yml b/.cirrus.yml index 178f5b24690c5..e3f777b52907f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -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: @@ -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 diff --git a/Cargo.toml b/Cargo.toml index c6e1b98c21aee..a39ab2945ceb1 100644 --- a/Cargo.toml +++ b/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" diff --git a/build.rs b/build.rs index f355447a672c6..efc95b6627493 100644 --- a/build.rs +++ b/build.rs @@ -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!( @@ -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: diff --git a/ci/azure.yml b/ci/azure.yml index 04d12dae8f316..4526361aefbe6 100644 --- a/ci/azure.yml +++ b/ci/azure.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/ci/dox.sh b/ci/dox.sh index 49abd546001c8..febe18b35b836 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -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 diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 5fd00614462dc..3c0736a265f7b 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -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 \ diff --git a/ci/run.sh b/ci/run.sh index 8c56979ed657f..6f2ca11fe4090 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -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}" diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index c178b91b9408e..fea680d2af40c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -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 } }