Skip to content

Commit

Permalink
Merge pull request #4159 from tgross35/freebsd-build-check
Browse files Browse the repository at this point in the history
ci: Check various FreeBSD versions
  • Loading branch information
tgross35 authored Nov 27, 2024
2 parents 57dfd5b + 9a942b3 commit 8075133
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 131 deletions.
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ fn main() {
//
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
// running tests to ensure that the ABI is correct.
let which_freebsd = if libc_ci {
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
// Allow overriding the default version for testing
let which_freebsd = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
let vers = version.parse().unwrap();
println!("cargo:warning=setting FreeBSD version to {vers}");
vers
} else if libc_ci {
which_freebsd().unwrap_or(12)
} else if rustc_dep_of_std {
12
} else {
12
};

match which_freebsd {
x if x < 10 => panic!("FreeBSD older than 10 is not supported"),
10 => set_cfg("freebsd10"),
Expand Down
50 changes: 35 additions & 15 deletions ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then
rustup component add rust-src
fi

# Run the tests for a specific target
test_target() {
target="${1}"
no_dist="${2:-0}"
Expand Down Expand Up @@ -67,8 +68,31 @@ test_target() {
# Test again without default features, i.e. without "std"
$cmd --no-default-features
$cmd --no-default-features --features extra_traits

# For tier 2 freebsd targets, check with the different versions we support
# if on nightly or stable
case "$rust-$target" in
stable-x86_64-*freebsd*) do_freebsd_checks=1 ;;
nightly-i686*freebsd*) do_freebsd_checks=1 ;;
esac

if [ -n "${do_freebsd_checks:-}" ]; then
for version in $freebsd_versions; do
export RUST_LIBC_UNSTABLE_FREEBSD_VERSION="$version"
$cmd
$cmd --no-default-features
done
fi
}

freebsd_versions="\
11 \
12 \
13 \
14 \
15 \
"

rust_linux_targets="\
aarch64-linux-android \
aarch64-unknown-linux-gnu \
Expand Down Expand Up @@ -240,21 +264,19 @@ for target in $targets; do
if echo "$target" | grep -q "$filter"; then
if [ "$os" = "windows" ]; then
TARGET="$target" ./ci/install-rust.sh
test_target "$target"
else
# `wasm32-wasip1` was renamed from `wasm32-wasi`
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
target="wasm32-wasi"
fi
fi

# `wasm32-wasip2` only exists in recent versions of Rust
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
continue
fi

test_target "$target"
# `wasm32-wasip1` was renamed from `wasm32-wasi`
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
target="wasm32-wasi"
fi

# `wasm32-wasip2` only exists in recent versions of Rust
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
continue
fi

test_target "$target"
test_run=1
fi
done
Expand All @@ -263,11 +285,9 @@ for target in ${no_dist_targets:-}; do
if echo "$target" | grep -q "$filter"; then
if [ "$os" = "windows" ]; then
TARGET="$target" ./ci/install-rust.sh
test_target "$target" 1
else
test_target "$target" 1
fi

test_target "$target" 1
test_run=1
fi
done
Expand Down
7 changes: 7 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4663,9 +4663,16 @@ fn test_linux_like_apis(target: &str) {
}

fn which_freebsd() -> Option<i32> {
if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") {
let vers = version.parse().unwrap();
println!("cargo:warning=setting FreeBSD version to {vers}");
return Some(vers);
}

let output = std::process::Command::new("freebsd-version")
.output()
.ok()?;

if !output.status.success() {
return None;
}
Expand Down
34 changes: 17 additions & 17 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ use crate::{c_long, off_t};
#[repr(C)]
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_atime: ::time_t,
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: ::time_t,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: ::time_t,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u32,
pub st_lspare: i32,
pub st_birthtime: ::time_t,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
__unused: [u8; 8],
}

impl Copy for ::stat {}
impl Clone for ::stat {
fn clone(&self) -> ::stat {
impl Copy for crate::stat {}
impl Clone for crate::stat {
fn clone(&self) -> crate::stat {
*self
}
}
34 changes: 17 additions & 17 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ use crate::{c_long, off_t};
#[repr(C)]
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_atime: ::time_t,
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_mode: crate::mode_t,
pub st_nlink: crate::nlink_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
pub st_rdev: crate::dev_t,
pub st_atime: crate::time_t,
pub st_atime_nsec: c_long,
pub st_mtime: ::time_t,
pub st_mtime: crate::time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: ::time_t,
pub st_ctime: crate::time_t,
pub st_ctime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: ::blkcnt_t,
pub st_blksize: ::blksize_t,
pub st_flags: ::fflags_t,
pub st_blocks: crate::blkcnt_t,
pub st_blksize: crate::blksize_t,
pub st_flags: crate::fflags_t,
pub st_gen: u32,
pub st_lspare: i32,
pub st_birthtime: ::time_t,
pub st_birthtime: crate::time_t,
pub st_birthtime_nsec: c_long,
}

impl Copy for ::stat {}
impl Clone for ::stat {
fn clone(&self) -> ::stat {
impl Copy for crate::stat {}
impl Clone for crate::stat {
fn clone(&self) -> crate::stat {
*self
}
}
Loading

0 comments on commit 8075133

Please sign in to comment.