Skip to content

Commit 9c2f78e

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`
1 parent 57dfd5b commit 9c2f78e

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
@@ -48,13 +48,20 @@ fn main() {
4848
//
4949
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
5050
// running tests to ensure that the ABI is correct.
51-
let which_freebsd = if libc_ci {
51+
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
52+
// Allow overriding the default version for testing
53+
let which_freebsd = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
54+
let vers = version.parse().unwrap();
55+
println!("cargo:warning=setting FreeBSD version to {vers}");
56+
vers
57+
} else if libc_ci {
5258
which_freebsd().unwrap_or(12)
5359
} else if rustc_dep_of_std {
5460
12
5561
} else {
5662
12
5763
};
64+
5865
match which_freebsd {
5966
x if x < 10 => panic!("FreeBSD older than 10 is not supported"),
6067
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}"
@@ -67,8 +68,31 @@ test_target() {
6768
# Test again without default features, i.e. without "std"
6869
$cmd --no-default-features
6970
$cmd --no-default-features --features extra_traits
71+
72+
# For tier 2 freebsd targets, check with the different versions we support
73+
# if on nightly or stable
74+
case "$rust-$target" in
75+
stable-x86_64-*freebsd*) do_freebsd_checks=1 ;;
76+
nightly-i686*freebsd*) do_freebsd_checks=1 ;;
77+
esac
78+
79+
if [ -n "${do_freebsd_checks:-}" ]; then
80+
for version in $freebsd_versions; do
81+
export RUST_LIBC_UNSTABLE_FREEBSD_VERSION="$version"
82+
$cmd
83+
$cmd --no-default-features
84+
done
85+
fi
7086
}
7187

88+
freebsd_versions="\
89+
11 \
90+
12 \
91+
13 \
92+
14 \
93+
15 \
94+
"
95+
7296
rust_linux_targets="\
7397
aarch64-linux-android \
7498
aarch64-unknown-linux-gnu \
@@ -240,21 +264,19 @@ for target in $targets; do
240264
if echo "$target" | grep -q "$filter"; then
241265
if [ "$os" = "windows" ]; then
242266
TARGET="$target" ./ci/install-rust.sh
243-
test_target "$target"
244-
else
245-
# `wasm32-wasip1` was renamed from `wasm32-wasi`
246-
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
247-
target="wasm32-wasi"
248-
fi
267+
fi
249268

250-
# `wasm32-wasip2` only exists in recent versions of Rust
251-
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
252-
continue
253-
fi
254-
255-
test_target "$target"
269+
# `wasm32-wasip1` was renamed from `wasm32-wasi`
270+
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
271+
target="wasm32-wasi"
256272
fi
257273

274+
# `wasm32-wasip2` only exists in recent versions of Rust
275+
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
276+
continue
277+
fi
278+
279+
test_target "$target"
258280
test_run=1
259281
fi
260282
done
@@ -263,11 +285,9 @@ for target in ${no_dist_targets:-}; do
263285
if echo "$target" | grep -q "$filter"; then
264286
if [ "$os" = "windows" ]; then
265287
TARGET="$target" ./ci/install-rust.sh
266-
test_target "$target" 1
267-
else
268-
test_target "$target" 1
269288
fi
270289

290+
test_target "$target" 1
271291
test_run=1
272292
fi
273293
done

libc-test/build.rs

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

46654665
fn which_freebsd() -> Option<i32> {
4666+
if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
4667+
let vers = version.parse().unwrap();
4668+
println!("cargo:warning=setting FreeBSD version to {vers}");
4669+
return Some(vers);
4670+
}
4671+
46664672
let output = std::process::Command::new("freebsd-version")
46674673
.output()
46684674
.ok()?;
4675+
46694676
if !output.status.success() {
46704677
return None;
46714678
}

0 commit comments

Comments
 (0)