Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Check various FreeBSD versions #4159

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will test 12 twice, once at line 69-70 and once at 82-83.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any idea how best to avoid this? It wouldn't be that bad if there isn't anything straightforward.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default version of "12" is set in build.rs. So you can simply leave 12 off of the list. But then it would have to be manually updated in case the default ever changes. So if object files are retained between runs, then running cargo check twice should be fast enough, I think.

Copy link
Contributor Author

@tgross35 tgross35 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's about the same conclusion I came to, it should be fast enough that it's better to not worry about forgetting to update the default.

I updated to only test on the Tier2 architectures. Thanks for taking a look at this!

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