Skip to content

Commit e13cde2

Browse files
committed
ci: Check various FreeBSD versions
Since we suport multiple versions and this is tier 2, we should make sure that we can build with a couple versions. This does not run tests. Additionally, introduce an environment variable for an easy way to override the version for testing. This includes an unrelated cleanup adjustment in `verify-build.sh` (backport <#4159>) (cherry picked from commit 9c2f78e)
1 parent deed988 commit e13cde2

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,20 @@ fn main() {
4949
//
5050
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
5151
// running tests to ensure that the ABI is correct.
52-
let which_freebsd = if libc_ci {
52+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
53+
// Allow overriding the default version for testing
54+
let which_freebsd = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
55+
let vers = version.parse().unwrap();
56+
println!("cargo:warning=setting FreeBSD version to {vers}");
57+
vers
58+
} else if libc_ci {
5359
which_freebsd().unwrap_or(11)
5460
} else if rustc_dep_of_std {
5561
12
5662
} else {
5763
11
5864
};
65+
5966
match which_freebsd {
6067
x if x < 10 => panic!("FreeBSD older than 10 is not supported"),
6168
10 => set_cfg("freebsd10"),

ci/verify-build.sh

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then
2828
rustup component add rust-src
2929
fi
3030

31+
# Run the tests for a specific target
3132
test_target() {
3233
target="${1}"
3334
no_dist="${2:-0}"
@@ -68,8 +69,31 @@ test_target() {
6869
# Test again without default features, i.e. without "std"
6970
$cmd --no-default-features
7071
$cmd --no-default-features --features extra_traits
72+
73+
# For tier 2 freebsd targets, check with the different versions we support
74+
# if on nightly or stable
75+
case "$rust-$target" in
76+
stable-x86_64-*freebsd*) do_freebsd_checks=1 ;;
77+
nightly-i686*freebsd*) do_freebsd_checks=1 ;;
78+
esac
79+
80+
if [ -n "${do_freebsd_checks:-}" ]; then
81+
for version in $freebsd_versions; do
82+
export RUST_LIBC_UNSTABLE_FREEBSD_VERSION="$version"
83+
$cmd
84+
$cmd --no-default-features
85+
done
86+
fi
7187
}
7288

89+
freebsd_versions="\
90+
11 \
91+
12 \
92+
13 \
93+
14 \
94+
15 \
95+
"
96+
7397
rust_linux_targets="\
7498
aarch64-linux-android \
7599
aarch64-unknown-linux-gnu \
@@ -244,21 +268,19 @@ for target in $targets; do
244268
if echo "$target" | grep -q "$filter"; then
245269
if [ "$os" = "windows" ]; then
246270
TARGET="$target" ./ci/install-rust.sh
247-
test_target "$target"
248-
else
249-
# `wasm32-wasip1` was renamed from `wasm32-wasi`
250-
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
251-
target="wasm32-wasi"
252-
fi
271+
fi
253272

254-
# `wasm32-wasip2` only exists in recent versions of Rust
255-
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
256-
continue
257-
fi
258-
259-
test_target "$target"
273+
# `wasm32-wasip1` was renamed from `wasm32-wasi`
274+
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
275+
target="wasm32-wasi"
260276
fi
261277

278+
# `wasm32-wasip2` only exists in recent versions of Rust
279+
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
280+
continue
281+
fi
282+
283+
test_target "$target"
262284
test_run=1
263285
fi
264286
done
@@ -267,11 +289,9 @@ for target in ${no_dist_targets:-}; do
267289
if echo "$target" | grep -q "$filter"; then
268290
if [ "$os" = "windows" ]; then
269291
TARGET="$target" ./ci/install-rust.sh
270-
test_target "$target" 1
271-
else
272-
test_target "$target" 1
273292
fi
274293

294+
test_target "$target" 1
275295
test_run=1
276296
fi
277297
done

libc-test/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4734,9 +4734,16 @@ fn test_linux_like_apis(target: &str) {
47344734
}
47354735

47364736
fn which_freebsd() -> Option<i32> {
4737+
if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
4738+
let vers = version.parse().unwrap();
4739+
println!("cargo:warning=setting FreeBSD version to {vers}");
4740+
return Some(vers);
4741+
}
4742+
47374743
let output = std::process::Command::new("freebsd-version")
47384744
.output()
47394745
.ok()?;
4746+
47404747
if !output.status.success() {
47414748
return None;
47424749
}

0 commit comments

Comments
 (0)