Skip to content

Commit 7437d0a

Browse files
committed
Add a FreeBSD 12 build job and test FreeBSD12 APIs
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.
1 parent 5653a60 commit 7437d0a

File tree

17 files changed

+698
-421
lines changed

17 files changed

+698
-421
lines changed

.cirrus.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
freebsd_instance:
2-
image: freebsd-11-1-release-amd64
3-
41
task:
5-
name: stable x86_64-unknown-freebsd
2+
name: stable x86_64-unknown-freebsd-11
3+
freebsd_instance:
4+
image: freebsd-11-2-release-amd64
65
setup_script:
76
- pkg install -y curl
87
- curl https://sh.rustup.rs -sSf --output rustup.sh
@@ -12,13 +11,15 @@ task:
1211
test_script:
1312
- . $HOME/.cargo/env
1413
- sh ci/run.sh x86_64-unknown-freebsd
15-
14+
1615
task:
17-
name: nightly x86_64-unknown-freebsd
16+
name: nightly x86_64-unknown-freebsd-12
17+
freebsd_instance:
18+
image: freebsd-12-0-release-amd64
1819
setup_script:
1920
- pkg install -y curl
2021
- curl https://sh.rustup.rs -sSf --output rustup.sh
21-
- sh rustup.sh -y
22+
- sh rustup.sh --default-toolchain nightly -y
2223
- . $HOME/.cargo/env
2324
- rustup default nightly
2425
test_script:

build.rs

+29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ fn main() {
1616
);
1717
}
1818

19+
if std::env::var("LIBC_CI").is_ok() {
20+
if let Some(12) = which_freebsd() {
21+
println!("cargo:rustc-cfg=freebsd12");
22+
}
23+
}
24+
1925
// Rust >= 1.15 supports private module use:
2026
if rustc_minor_ver >= 15 || rustc_dep_of_std {
2127
println!("cargo:rustc-cfg=libc_priv_mod_use");
@@ -70,3 +76,26 @@ fn rustc_minor_version() -> Option<u32> {
7076

7177
otry!(pieces.next()).parse().ok()
7278
}
79+
80+
fn which_freebsd() -> Option<i32> {
81+
let output = std::process::Command::new("freebsd-version").output().ok();
82+
if output.is_none() {
83+
return None;
84+
}
85+
let output = output.unwrap();
86+
if !output.status.success() {
87+
return None;
88+
}
89+
90+
let stdout = String::from_utf8(output.stdout).ok();
91+
if stdout.is_none() {
92+
return None;
93+
}
94+
let stdout = stdout.unwrap();
95+
96+
match &stdout {
97+
s if s.starts_with("11") => Some(11),
98+
s if s.starts_with("12") => Some(12),
99+
_ => None,
100+
}
101+
}

ci/run.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
8787
opt="--release"
8888
fi
8989

90-
cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml \
90+
export LIBC_CI=1
91+
92+
cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \
9193
--target "${TARGET}"
9294

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

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

0 commit comments

Comments
 (0)