Skip to content

Commit eb373ad

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 7c3c0da commit eb373ad

File tree

17 files changed

+673
-417
lines changed

17 files changed

+673
-417
lines changed

.cirrus.yml

+7-6
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,9 +11,11 @@ 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

build.rs

+23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ fn main() {
99
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1010
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
1111

12+
if std::env::var("LIBC_CI").is_ok() {
13+
if let Some(12) = which_freebsd() {
14+
println!("cargo:rustc-cfg=freebsd12");
15+
}
16+
}
17+
1218
// Rust >= 1.15 supports private module use:
1319
if rustc_minor_ver >= 15 || rustc_dep_of_std {
1420
println!("cargo:rustc-cfg=libc_priv_mod_use");
@@ -63,3 +69,20 @@ fn rustc_minor_version() -> Option<u32> {
6369

6470
otry!(pieces.next()).parse().ok()
6571
}
72+
73+
fn which_freebsd() -> Option<i32> {
74+
let output = std::process::Command::new("freebsd-version")
75+
.output()
76+
.ok()?;
77+
if !output.status.success() {
78+
return None;
79+
}
80+
81+
let stdout = String::from_utf8(output.stdout).ok()?;
82+
83+
match &stdout {
84+
s if s.starts_with("11") => Some(11),
85+
s if s.starts_with("12") => Some(12),
86+
_ => None,
87+
}
88+
}

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)