Skip to content

Commit 8075133

Browse files
authored
Merge pull request #4159 from tgross35/freebsd-build-check
ci: Check various FreeBSD versions
2 parents 57dfd5b + 9a942b3 commit 8075133

File tree

6 files changed

+163
-131
lines changed

6 files changed

+163
-131
lines changed

build.rs

+8-1
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

+35-15
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

+7
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
}

src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ use crate::{c_long, off_t};
33
#[repr(C)]
44
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
55
pub struct stat {
6-
pub st_dev: ::dev_t,
7-
pub st_ino: ::ino_t,
8-
pub st_mode: ::mode_t,
9-
pub st_nlink: ::nlink_t,
10-
pub st_uid: ::uid_t,
11-
pub st_gid: ::gid_t,
12-
pub st_rdev: ::dev_t,
13-
pub st_atime: ::time_t,
6+
pub st_dev: crate::dev_t,
7+
pub st_ino: crate::ino_t,
8+
pub st_mode: crate::mode_t,
9+
pub st_nlink: crate::nlink_t,
10+
pub st_uid: crate::uid_t,
11+
pub st_gid: crate::gid_t,
12+
pub st_rdev: crate::dev_t,
13+
pub st_atime: crate::time_t,
1414
pub st_atime_nsec: c_long,
15-
pub st_mtime: ::time_t,
15+
pub st_mtime: crate::time_t,
1616
pub st_mtime_nsec: c_long,
17-
pub st_ctime: ::time_t,
17+
pub st_ctime: crate::time_t,
1818
pub st_ctime_nsec: c_long,
1919
pub st_size: off_t,
20-
pub st_blocks: ::blkcnt_t,
21-
pub st_blksize: ::blksize_t,
22-
pub st_flags: ::fflags_t,
20+
pub st_blocks: crate::blkcnt_t,
21+
pub st_blksize: crate::blksize_t,
22+
pub st_flags: crate::fflags_t,
2323
pub st_gen: u32,
2424
pub st_lspare: i32,
25-
pub st_birthtime: ::time_t,
25+
pub st_birthtime: crate::time_t,
2626
pub st_birthtime_nsec: c_long,
2727
__unused: [u8; 8],
2828
}
2929

30-
impl Copy for ::stat {}
31-
impl Clone for ::stat {
32-
fn clone(&self) -> ::stat {
30+
impl Copy for crate::stat {}
31+
impl Clone for crate::stat {
32+
fn clone(&self) -> crate::stat {
3333
*self
3434
}
3535
}

src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ use crate::{c_long, off_t};
33
#[repr(C)]
44
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
55
pub struct stat {
6-
pub st_dev: ::dev_t,
7-
pub st_ino: ::ino_t,
8-
pub st_mode: ::mode_t,
9-
pub st_nlink: ::nlink_t,
10-
pub st_uid: ::uid_t,
11-
pub st_gid: ::gid_t,
12-
pub st_rdev: ::dev_t,
13-
pub st_atime: ::time_t,
6+
pub st_dev: crate::dev_t,
7+
pub st_ino: crate::ino_t,
8+
pub st_mode: crate::mode_t,
9+
pub st_nlink: crate::nlink_t,
10+
pub st_uid: crate::uid_t,
11+
pub st_gid: crate::gid_t,
12+
pub st_rdev: crate::dev_t,
13+
pub st_atime: crate::time_t,
1414
pub st_atime_nsec: c_long,
15-
pub st_mtime: ::time_t,
15+
pub st_mtime: crate::time_t,
1616
pub st_mtime_nsec: c_long,
17-
pub st_ctime: ::time_t,
17+
pub st_ctime: crate::time_t,
1818
pub st_ctime_nsec: c_long,
1919
pub st_size: off_t,
20-
pub st_blocks: ::blkcnt_t,
21-
pub st_blksize: ::blksize_t,
22-
pub st_flags: ::fflags_t,
20+
pub st_blocks: crate::blkcnt_t,
21+
pub st_blksize: crate::blksize_t,
22+
pub st_flags: crate::fflags_t,
2323
pub st_gen: u32,
2424
pub st_lspare: i32,
25-
pub st_birthtime: ::time_t,
25+
pub st_birthtime: crate::time_t,
2626
pub st_birthtime_nsec: c_long,
2727
}
2828

29-
impl Copy for ::stat {}
30-
impl Clone for ::stat {
31-
fn clone(&self) -> ::stat {
29+
impl Copy for crate::stat {}
30+
impl Clone for crate::stat {
31+
fn clone(&self) -> crate::stat {
3232
*self
3333
}
3434
}

0 commit comments

Comments
 (0)