Skip to content

Commit

Permalink
Add a FreeBSD 12 build job and test FreeBSD12 APIs
Browse files Browse the repository at this point in the history
This commits adds a second FreeBSD 12 build job,
and splits the implementation of the FreeBSD module
into two modules, one for FreeBSD 11, and one for FreeBSD 12.

The FreeBSD 11 module is compiled always by default, and is
mostly forward compatible with FreeBSD 12 systems.

The FreeBSD 12 module is only built for now in libc's CI,
and uses FreeBSD 12 data types and APIs, linking to symbols
that are only available in FreeBSD 12.

Basically, when LIBC_CI env variable is defined, and the host
system is a FreeBSD 12 system, then the FreeBSD 12 module is
automatically built and tested. Conditional compilation is done
using a `cfg(freebsd12)` flag.

This commit also re-enables many tests, and documents why
some remain disabled.
  • Loading branch information
gnzlbg committed May 24, 2019
1 parent 5653a60 commit 7437d0a
Show file tree
Hide file tree
Showing 17 changed files with 698 additions and 421 deletions.
15 changes: 8 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
freebsd_instance:
image: freebsd-11-1-release-amd64

task:
name: stable x86_64-unknown-freebsd
name: stable x86_64-unknown-freebsd-11
freebsd_instance:
image: freebsd-11-2-release-amd64
setup_script:
- pkg install -y curl
- curl https://sh.rustup.rs -sSf --output rustup.sh
Expand All @@ -12,13 +11,15 @@ task:
test_script:
- . $HOME/.cargo/env
- sh ci/run.sh x86_64-unknown-freebsd

task:
name: nightly x86_64-unknown-freebsd
name: nightly x86_64-unknown-freebsd-12
freebsd_instance:
image: freebsd-12-0-release-amd64
setup_script:
- pkg install -y curl
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y
- sh rustup.sh --default-toolchain nightly -y
- . $HOME/.cargo/env
- rustup default nightly
test_script:
Expand Down
29 changes: 29 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ fn main() {
);
}

if std::env::var("LIBC_CI").is_ok() {
if let Some(12) = which_freebsd() {
println!("cargo:rustc-cfg=freebsd12");
}
}

// Rust >= 1.15 supports private module use:
if rustc_minor_ver >= 15 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_priv_mod_use");
Expand Down Expand Up @@ -70,3 +76,26 @@ fn rustc_minor_version() -> Option<u32> {

otry!(pieces.next()).parse().ok()
}

fn which_freebsd() -> Option<i32> {
let output = std::process::Command::new("freebsd-version").output().ok();
if output.is_none() {
return None;
}
let output = output.unwrap();
if !output.status.success() {
return None;
}

let stdout = String::from_utf8(output.stdout).ok();
if stdout.is_none() {
return None;
}
let stdout = stdout.unwrap();

match &stdout {
s if s.starts_with("11") => Some(11),
s if s.starts_with("12") => Some(12),
_ => None,
}
}
8 changes: 5 additions & 3 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
opt="--release"
fi

cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml \
export LIBC_CI=1

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

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

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

0 comments on commit 7437d0a

Please sign in to comment.