From 9697f27c87046fb1251a66a1fd3ba3805c3d1d6d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 22:40:08 -0500 Subject: [PATCH 1/5] Remove the `libc_ctest` feature This was a workaround for the old ctest not being able to parse something related to the `addr_of!` macros in statics referencing statics. This is not needed with the new ctest; thus, remove the config. --- build.rs | 1 - libc-test/build.rs | 5 ----- src/wasi/mod.rs | 31 +++++++++++-------------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/build.rs b/build.rs index dab64847b2b6c..d6a941611ed22 100644 --- a/build.rs +++ b/build.rs @@ -20,7 +20,6 @@ const ALLOWED_CFGS: &[&str] = &[ // FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn` "libc_const_extern_fn", "libc_deny_warnings", - "libc_ctest", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", diff --git a/libc-test/build.rs b/libc-test/build.rs index 3146ce669b843..6d2a1da0c248b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1694,11 +1694,6 @@ fn test_wasi(target: &str) { "wchar.h", } - // Currently `ctest` doesn't support macros-in-static-expressions and will - // panic on them. That affects `CLOCK_*` defines in wasi to set this here - // to omit them. - cfg.cfg("libc_ctest", None); - cfg.rename_struct_ty(move |ty| match ty { "FILE" | "fd_set" | "DIR" => Some(ty.to_string()), t if t.ends_with("_t") => Some(t.to_string()), diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 4700ca54a05dd..64459c2095c9d 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -361,26 +361,17 @@ pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; -cfg_if! { - if #[cfg(libc_ctest)] { - // skip these constants when this is active because `ctest` currently - // panics on parsing the constants below - } else { - // unsafe code here is required in the stable, but not in nightly - #[allow(unused_unsafe)] - pub static CLOCK_MONOTONIC: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; - #[allow(unused_unsafe)] - pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; - #[allow(unused_unsafe)] - pub static CLOCK_REALTIME: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; - #[allow(unused_unsafe)] - pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; - } -} +// unsafe code here is required in the stable, but not in nightly +#[allow(unused_unsafe)] +pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; +#[allow(unused_unsafe)] +pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +#[allow(unused_unsafe)] +pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; +#[allow(unused_unsafe)] +pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; pub const ABDAY_1: crate::nl_item = 0x20000; pub const ABDAY_2: crate::nl_item = 0x20001; From f5a04a1c9471bc65c36d363f0679c9688b60e3f3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 22:47:46 -0500 Subject: [PATCH 2/5] Resolve a ctest FIXME regarding use of `size_of` in array lengths --- src/unix/linux_like/linux/musl/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 0505e56aa0d1a..80d8003e21724 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -422,11 +422,7 @@ s_no_extra_traits! { pub aio_offset: off_t, __next: *mut c_void, __prev: *mut c_void, - // FIXME(ctest): length should be `32 - 2 * size_of::<*const ()>()` - #[cfg(target_pointer_width = "32")] - __dummy4: [c_char; 24], - #[cfg(target_pointer_width = "64")] - __dummy4: [c_char; 16], + __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], } pub struct sysinfo { From 86fe6e589ad7d884757685a9b524b9213918790c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 22:49:48 -0500 Subject: [PATCH 3/5] doc: Remove an unneeded link to the old ctest repo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 74f49f3e7bb04..0cdfaeadf9059 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,7 +89,7 @@ standard, it's just a list shared among all OSs that declare `#[cfg(unix)]`. We have two automated tests running on [GitHub Actions](https://github.com/rust-lang/libc/actions): -1. [`libc-test`](https://github.com/gnzlbg/ctest) +1. `libc-test` - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker From bd291acd0b6e631cbe107d9434dcf1d28a59445e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 22:53:44 -0500 Subject: [PATCH 4/5] cleanup: Use `target_vendor = "apple"` The old ctest couldn't handle `target_vendor`, but this is no longer an issue. Simplify the config here. --- src/primitives.rs | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/primitives.rs b/src/primitives.rs index 630b03a911230..57c218a654d5a 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -20,14 +20,7 @@ pub type c_double = f64; cfg_if! { if #[cfg(all( not(windows), - // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it - not(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", - )), + not(target_vendor = "apple"), not(target_os = "vita"), any( target_arch = "aarch64", @@ -91,13 +84,7 @@ pub type uint64_t = u64; cfg_if! { if #[cfg(all( target_arch = "aarch64", - not(any( - target_os = "windows", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos" - )) + not(any(target_os = "windows", target_vendor = "apple")) ))] { /// C `__int128` (a GCC extension that's part of many ABIs) pub type __int128 = i128; @@ -107,15 +94,7 @@ cfg_if! { pub type __int128_t = i128; /// C __uint128_t (alternate name for [__uint128][]) pub type __uint128_t = u128; - } else if #[cfg(all( - target_arch = "aarch64", - any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos" - ) - ))] { + } else if #[cfg(all(target_arch = "aarch64", target_vendor = "apple"))] { /// C `__int128_t` pub type __int128_t = i128; /// C `__uint128_t` From b0559aebc8ea87160f783fa8668c97c41e14ceb5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 23 Sep 2025 00:04:43 -0500 Subject: [PATCH 5/5] ci: Update a comment about skipping wasm We still need to skip testing ctest on wasm, but no longer because of ctest itself. --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index c396d720cb655..5ccd6d74160b5 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -23,7 +23,7 @@ case "$target" in esac case "$target" in - # garando_errors only compiles on `cfg(any(unix, windows))` + # crash in std::env::tmp_dir (no filesystem on wasm). *wasm*) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;; # https://github.com/bytecodealliance/rustix/issues/1496 *loongarch*) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;;