From e389b875776019c3c39e9f8cafe4d6b99f5885be Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 10:16:39 -0600 Subject: [PATCH 01/17] Fix CI by relaxing our MSRV constraint Recently a transitive dev-dependency published a new version that is incompatible with Nix's MSRV, causing CI to break. That's annoying, because there's really no reason why a crate's dev-dependencies ought to respect the MSRV. Fix Nix's CI by: * Running all tests with stable Rust (or nightly, for certain targets) * Adding an additional set of CI checks to ensure that the crate will compile with MSRV, on all of the major operating systems, but don't try to compile its tests. * Eliminate the now-redundant "rust-stable" CI task. --- .cirrus.yml | 2 +- .github/actions/build/action.yml | 12 ++++ .github/workflows/ci.yml | 95 ++++++++++++++++++-------------- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 4fb70d7b3b..c16590f98f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -50,7 +50,7 @@ task: setup_script: - kldload mqueuefs - fetch https://sh.rustup.rs -o rustup.sh - - sh rustup.sh -y --profile=minimal --default-toolchain $MSRV + - sh rustup.sh -y --profile=minimal --default-toolchain stable - . $HOME/.cargo/env - rustup target add i686-unknown-freebsd - rustup component add clippy diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 9cf2fbff5d..9f81c29273 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -30,6 +30,16 @@ inputs: required: false default: + NOCLIPPY: + description: "whether to run cargo clippy" + required: false + default: false + + NODOC: + description: "whether to run cargo doc" + required: false + default: false + NOHACK: description: "whether to run cargo hack" required: false @@ -55,10 +65,12 @@ runs: run: ${{ inputs.TOOL }} ${{ inputs.BUILD }} ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} --all-targets --all-features - name: doc + if: inputs.NODOC == 'false' shell: bash run: ${{ inputs.TOOL }} doc ${{ inputs.ZFLAGS }} --no-deps --target ${{ inputs.TARGET }} --all-features - name: clippy + if: inputs.NOCLIPPY == 'false' shell: bash run: ${{ inputs.TOOL}} clippy ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} --all-targets --all-features -- ${{ inputs.CLIPPYFLAGS }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc7fa1324d..15abd09b26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,10 +14,6 @@ permissions: env: MSRV: 1.69.0 - # Rust's Loongarch support merged in 1.71.0 - MSRV_LOONGARCH: 1.71.0 - # Minimal Rust version to support all 3 official OpenHarmony targets as tier2 - MSRV_OHOS: 1.78.0 RUSTFLAGS: -Dwarnings jobs: @@ -32,7 +28,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.MSRV }}' + toolchain: stable components: clippy - name: build @@ -59,7 +55,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.MSRV }}' + toolchain: stable components: clippy - name: build @@ -79,7 +75,7 @@ jobs: # cross needs to execute Docker, GitHub Action already has it installed cross: runs-on: ubuntu-24.04 - needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable] + needs: [rustfmt, minver, macos, x86_64_linux_native_builds] strategy: fail-fast: false matrix: @@ -108,8 +104,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - # Use a newer version rustc if the target is Loongarch, remove this workaround after MSRV is newer than 1.71.0 - toolchain: "${{ matrix.target == 'loongarch64-unknown-linux-gnu' && env.MSRV_LOONGARCH || env.MSRV }}" + toolchain: stable components: clippy # cross relies on docker or podman, GitHub Acton already has it installed. @@ -156,7 +151,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.MSRV }}' + toolchain: stable components: clippy - name: install targets @@ -193,7 +188,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.MSRV }}' + toolchain: stable components: clippy - name: install targets @@ -212,38 +207,11 @@ jobs: - name: before_cache_script run: sudo rm -rf $CARGO_HOME/registry/index; - rust_stable: - runs-on: ubuntu-latest - env: - TARGET: x86_64-unknown-linux-gnu - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: setup Rust - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - - name: build - uses: ./.github/actions/build - with: - TARGET: '${{ env.TARGET }}' - - - name: test - uses: ./.github/actions/test - with: - TARGET: '${{ env.TARGET }}' - - - name: before_cache_script - run: sudo rm -rf $CARGO_HOME/registry/index - - # Tasks for cross-compiling, but no testing cross_compiling: runs-on: ubuntu-latest - needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable] + needs: [rustfmt, minver, macos, x86_64_linux_native_builds] env: BUILD: check strategy: @@ -282,8 +250,7 @@ jobs: - name: setup Rust uses: dtolnay/rust-toolchain@master with: - # Use a newer version rustc if it is OpenHarmony, remove this workaround after MSRV is newer than 1.78.0 - toolchain: "${{ contains(matrix.target, 'ohos') && env.MSRV_OHOS || env.MSRV }}" + toolchain: stable components: clippy - name: install targets @@ -299,10 +266,54 @@ jobs: - name: before_cache_script run: rm -rf $CARGO_HOME/registry/index + # Check that Nix will build on the MSRV, on a variety of operating systems. + # But don't check the tests. Those are not required to build on MSRV. + msrv: + runs-on: ubuntu-latest + needs: [rustfmt, minver, macos, x86_64_linux_native_builds] + env: + BUILD: check + NOCLIPPY: true + NODOC: true + NOHACK: true + strategy: + fail-fast: false + matrix: + include: + - target: aarch64-linux-android + - target: x86_64-unknown-linux-gnu + - target: x86_64-unknown-linux-musl + - target: aarch64-apple-darwin + - target: x86_64-unknown-freebsd + - target: x86_64-unknown-netbsd + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: setup Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: $MSRV + + - name: install targets + run: rustup target add ${{ matrix.target }} + + - name: build + uses: ./.github/actions/build + with: + TARGET: '${{ matrix.target }}' + BUILD: '${{ env.BUILD }}' + NOCLIPPY: '${{ matrix.NOCLIPPY }}' + NODOC: '${{ matrix.NODOC }}' + NOHACK: '${{ matrix.NOHACK }}' + + - name: before_cache_script + run: rm -rf $CARGO_HOME/registry/index + redox: runs-on: ubuntu-latest - needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable] + needs: [rustfmt, minver, macos, x86_64_linux_native_builds] env: TARGET: x86_64-unknown-redox CLIPPYFLAGS: -D warnings From 49453802ea930af96bf2bef1bdf15cccb9d14594 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 10:46:23 -0600 Subject: [PATCH 02/17] Fix some Clippy warnings on apple I think these never showed up in CI before, because we've never run clippy on Rust stable on apple until now. --- test/test_sendfile.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_sendfile.rs b/test/test_sendfile.rs index ab50a1d040..0e8eff9031 100644 --- a/test/test_sendfile.rs +++ b/test/test_sendfile.rs @@ -159,10 +159,10 @@ fn test_sendfile_dragonfly() { fn test_sendfile_darwin() { // Declare the content let header_strings = - vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; + ["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"]; let body = "Xabcdef123456"; let body_offset = 1; - let trailer_strings = vec!["\n", "Served by Make Believe\n"]; + let trailer_strings = ["\n", "Served by Make Believe\n"]; // Write the body to a file let mut tmp = tempfile().unwrap(); @@ -195,7 +195,7 @@ fn test_sendfile_darwin() { + &trailer_strings.concat(); // Verify the message that was sent - assert_eq!(bytes_written as usize, expected_string.as_bytes().len()); + assert_eq!(bytes_written as usize, expected_string.len()); let mut read_string = String::new(); let bytes_read = rd.read_to_string(&mut read_string).unwrap(); From 1b002385cfbd9e440824819afe7bcd8f6a68309d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 1 Oct 2025 15:16:05 -0600 Subject: [PATCH 03/17] Suppress a Clippy false positive --- src/fcntl.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fcntl.rs b/src/fcntl.rs index 6504c1dcf2..4b439d03ed 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -1038,6 +1038,7 @@ pub unsafe trait Flockable: std::os::fd::AsRawFd {} pub struct Flock(T); #[cfg(not(any(target_os = "redox", target_os = "solaris")))] +#[allow(clippy::unnecessary_unwrap)] // https://github.com/rust-lang/rust-clippy/issues/15744 impl Drop for Flock { fn drop(&mut self) { let res = Errno::result(unsafe { libc::flock(self.0.as_raw_fd(), libc::LOCK_UN) }); From 312f4604d7476e80a270b2a21e3469f239d052bb Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 11:01:42 -0600 Subject: [PATCH 04/17] GetCString only needs to be build with features=net --- src/sys/socket/sockopt.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 49b305920f..e06dded5bb 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -1972,12 +1972,14 @@ impl<'a> Set<'a, OsString> for SetOsString<'a> { /// Getter for a `CString` value. #[cfg(apple_targets)] +#[cfg(feature = "net")] struct GetCString> { len: socklen_t, val: MaybeUninit, } #[cfg(apple_targets)] +#[cfg(feature = "net")] impl> Get for GetCString { fn uninit() -> Self { GetCString { From 44a0faed12e620ff0764a64cdb7809e510bdd789 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 11:09:29 -0600 Subject: [PATCH 05/17] Fix Clippy on Solarish, with Rust stable --- test/test_sendfile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_sendfile.rs b/test/test_sendfile.rs index 0e8eff9031..c59edb2a9e 100644 --- a/test/test_sendfile.rs +++ b/test/test_sendfile.rs @@ -258,7 +258,7 @@ fn test_sendfilev() { + &trailer_strings.concat(); // Verify the message that was sent - assert_eq!(bytes_written, expected_string.as_bytes().len()); + assert_eq!(bytes_written, expected_string.len()); let mut read_string = String::new(); let bytes_read = rd.read_to_string(&mut read_string).unwrap(); From 646fe75a3e1e71f1b16356e7af8af03585e4d98e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 11:11:37 -0600 Subject: [PATCH 06/17] Don't use --all-targets when testing MSRV --- .github/actions/build/action.yml | 7 ++++++- .github/workflows/ci.yml | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 9f81c29273..c44b8e10f7 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -21,6 +21,11 @@ inputs: required: false default: -D warnings + TARGETS: + description: 'Build all targets or only default?' + required: false + default: "--all-targets" + TOOL: description: 'Tool used to involve the BUILD command, can be cargo or cross' required: false @@ -62,7 +67,7 @@ runs: - name: build shell: bash - run: ${{ inputs.TOOL }} ${{ inputs.BUILD }} ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} --all-targets --all-features + run: ${{ inputs.TOOL }} ${{ inputs.BUILD }} ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} ${{ inputs.TARGETS }} --all-features - name: doc if: inputs.NODOC == 'false' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15abd09b26..8f9888663c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -276,6 +276,7 @@ jobs: NOCLIPPY: true NODOC: true NOHACK: true + TARGETS: "" strategy: fail-fast: false matrix: @@ -302,10 +303,11 @@ jobs: uses: ./.github/actions/build with: TARGET: '${{ matrix.target }}' + TARGETS: '${{ env.TARGETS }}' BUILD: '${{ env.BUILD }}' - NOCLIPPY: '${{ matrix.NOCLIPPY }}' - NODOC: '${{ matrix.NODOC }}' - NOHACK: '${{ matrix.NOHACK }}' + NOCLIPPY: '${{ env.NOCLIPPY }}' + NODOC: '${{ env.NODOC }}' + NOHACK: '${{ env.NOHACK }}' - name: before_cache_script run: rm -rf $CARGO_HOME/registry/index From a957d162e35d3f3a877a94bd2b5964dd5250659b Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 11:13:05 -0600 Subject: [PATCH 07/17] Disable the libc::personality doc test on QEMU It's failing there with EPERM. It's probably seccomp's fault --- .github/actions/test/action.yml | 5 +++++ .github/workflows/ci.yml | 1 + src/sys/personality.rs | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 31a6fd7aa6..6aa2bfe5ae 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -19,6 +19,10 @@ inputs: required: false default: -D warnings -A unknown-lints + RUSTDOCFLAGS: + required: false + default: -D warnings + runs: using: "composite" steps: @@ -26,6 +30,7 @@ runs: shell: bash run: | echo "RUSTFLAGS=${{ inputs.RUSTFLAGS }}" >> $GITHUB_ENV + echo "RUSTDOCFLAGS=${{ inputs.RUSTDOCFLAGS }}" >> $GITHUB_ENV - name: test shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f9888663c..2da4220637 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,7 @@ jobs: SUDO: "" TOOL: cross RUSTFLAGS: --cfg qemu -D warnings + RUSTDOCFLAGS: --cfg qemu - name: before_cache_script run: rm -rf $CARGO_HOME/registry/index diff --git a/src/sys/personality.rs b/src/sys/personality.rs index 9623fb8663..f77f36b681 100644 --- a/src/sys/personality.rs +++ b/src/sys/personality.rs @@ -78,10 +78,10 @@ pub fn get() -> Result { /// /// Example: /// -// Disable test on aarch64 until we know why it fails. +// Disable test on aarch64 and with QEMU. seccomp interference is suspected. // https://github.com/nix-rust/nix/issues/2060 -#[cfg_attr(target_arch = "aarch64", doc = " ```no_run")] -#[cfg_attr(not(target_arch = "aarch64"), doc = " ```")] +#[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")] +#[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")] /// # use nix::sys::personality::{self, Persona}; /// let mut pers = personality::get().unwrap(); /// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE)); From 4583d6d46ad889843cf5581d4b2cde9586ebf7f7 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 12 Oct 2025 17:34:55 -0600 Subject: [PATCH 08/17] Adjust atomics in the lio_listio doc test Since changing the compiler version, this test has begun to occasionally hang in CI. And it's not just in QEMU. It's probably due to an atomic ordering problem. --- src/sys/aio.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index a5f368637a..ad23356dba 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -1154,12 +1154,12 @@ pub fn aio_suspend( /// pub static SIGNALED: AtomicBool = AtomicBool::new(false); /// /// extern fn sigfunc(_: c_int) { -/// SIGNALED.store(true, Ordering::Relaxed); +/// SIGNALED.store(true, Ordering::Release); /// } /// let sa = SigAction::new(SigHandler::Handler(sigfunc), /// SaFlags::SA_RESETHAND, /// SigSet::empty()); -/// SIGNALED.store(false, Ordering::Relaxed); +/// SIGNALED.store(false, Ordering::Release); /// unsafe { sigaction(Signal::SIGUSR2, &sa) }.unwrap(); /// /// const WBUF: &[u8] = b"abcdef123456"; @@ -1173,7 +1173,7 @@ pub fn aio_suspend( /// )); /// let sev = SigevNotify::SigevSignal { signal: Signal::SIGUSR2, si_value: 0 }; /// lio_listio(LioMode::LIO_NOWAIT, &mut[aiow.as_mut()], sev).unwrap(); -/// while !SIGNALED.load(Ordering::Relaxed) { +/// while !SIGNALED.load(Ordering::Acquire) { /// thread::sleep(time::Duration::from_millis(10)); /// } /// // At this point, since `lio_listio` returned success and delivered its From 3931b02d1693093739f8e03f5a178d0ebbde477e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 19 Oct 2025 10:45:00 -0600 Subject: [PATCH 09/17] fixup to Disable the libc::personality doc test on QEMU --- src/sys/personality.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sys/personality.rs b/src/sys/personality.rs index f77f36b681..cee1f12ece 100644 --- a/src/sys/personality.rs +++ b/src/sys/personality.rs @@ -54,7 +54,8 @@ libc_bitflags! { /// /// Example: /// -/// ``` +#[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")] +#[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")] /// # use nix::sys::personality::{self, Persona}; /// let pers = personality::get().unwrap(); /// assert!(!pers.contains(Persona::WHOLE_SECONDS)); From fd8acb7085e0466a3deeb36660e1e059827a514b Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Tue, 4 Nov 2025 16:20:13 +0800 Subject: [PATCH 10/17] Run tests sequentially: cargo test -j 1 I think it is possible that our signal handler set in the test can be overwritten by integration tests (under dir 'test'), which means the `SIGNALED` variable would never be set. We have a lock to prevent this issue in integration tests, but since this is a doc test, we cannot employ it here. ```rust /// Any test that alters signal handling must grab this mutex. pub static SIGNAL_MTX: Mutex<()> = Mutex::new(()); ``` So let's run tests sequentially and see if it will work. --- .github/actions/test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 6aa2bfe5ae..fda6c00b9a 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -34,4 +34,4 @@ runs: - name: test shell: bash - run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} + run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} -j 1 From de07a509193a94e58c02238c85ef3bd98ce84b43 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Tue, 4 Nov 2025 16:37:15 +0800 Subject: [PATCH 11/17] Revert "Run tests sequentially: cargo test -j 1" It does not work: * https://github.com/nix-rust/nix/actions/runs/19062321851/job/54444625438?pr=2689 * https://github.com/nix-rust/nix/actions/runs/19062321851/job/54444910017?pr=2689 --- .github/actions/test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index fda6c00b9a..6aa2bfe5ae 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -34,4 +34,4 @@ runs: - name: test shell: bash - run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} -j 1 + run: ${{ inputs.SUDO }} $(which ${{ inputs.TOOL }}) test --target ${{ inputs.TARGET }} From a6b4af77f9a291eb19adef136daec3a2c78e4d15 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Wed, 5 Nov 2025 11:10:13 +0800 Subject: [PATCH 12/17] Skip lio_listio doc test on musl/aarch64/i686 as it hangs Do not run this doc test on: * aarch64-unknown-linux-musl * i686-unknown-linux-musl because it hangs on these targets. After further debugging, we think this is likely a bug of musl. Since we only test our bindings and do not intend to fix the underlying libc bug, we skip this test here. See this thread [1] for the discussion of this issue [1]: https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159 --- src/sys/aio.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index ad23356dba..cc9c9662f2 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -1141,7 +1141,17 @@ pub fn aio_suspend( /// `EINTR`, in which case some but not all operations may have been submitted. /// In that case, you must check the status of each individual operation, and /// possibly resubmit some. -/// ``` +/// +// Do not run this doc test on: +// * aarch64-unknown-linux-musl +// * i686-unknown-linux-musl +// because it hangs on these targets. After further debugging, we think this is +// likely a bug of musl. Since we only test our bindings and do not intend to +// fix the underlying libc bug, we skip this test here. +// See this thread for the discussion of this issue: +// https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159 +#[cfg_attr(all(target_env = "musl", any(target_arch = "aarch64", target_arch = "x86")), doc = " ```no_run")] +#[cfg_attr(not(all(target_env = "musl", any(target_arch = "aarch64", target_arch = "x86"))), doc = " ```")] /// # use libc::c_int; /// # use std::os::unix::io::AsFd; /// # use std::sync::atomic::{AtomicBool, Ordering}; From 8ae7893a6601e95911d8a3208fac4743d591b183 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Wed, 5 Nov 2025 11:13:43 +0800 Subject: [PATCH 13/17] Run rusfmt on src/sys/aio.rs --- src/sys/aio.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index cc9c9662f2..71b734c68b 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -456,7 +456,7 @@ impl<'a> AioFsync<'a> { /// * `fd`: File descriptor to sync. /// * `mode`: Whether to sync file metadata too, or just data. /// * `prio`: If POSIX Prioritized IO is supported, then the - /// operation will be prioritized at the process's priority level minus + /// operation will be prioritized at the process's priority level minus /// `prio`. /// * `sigev_notify`: Determines how you will be notified of event completion. pub fn new( @@ -1141,17 +1141,29 @@ pub fn aio_suspend( /// `EINTR`, in which case some but not all operations may have been submitted. /// In that case, you must check the status of each individual operation, and /// possibly resubmit some. -/// +/// // Do not run this doc test on: // * aarch64-unknown-linux-musl // * i686-unknown-linux-musl // because it hangs on these targets. After further debugging, we think this is -// likely a bug of musl. Since we only test our bindings and do not intend to +// likely a bug of musl. Since we only test our bindings and do not intend to // fix the underlying libc bug, we skip this test here. // See this thread for the discussion of this issue: // https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159 -#[cfg_attr(all(target_env = "musl", any(target_arch = "aarch64", target_arch = "x86")), doc = " ```no_run")] -#[cfg_attr(not(all(target_env = "musl", any(target_arch = "aarch64", target_arch = "x86"))), doc = " ```")] +#[cfg_attr( + all( + target_env = "musl", + any(target_arch = "aarch64", target_arch = "x86") + ), + doc = " ```no_run" +)] +#[cfg_attr( + not(all( + target_env = "musl", + any(target_arch = "aarch64", target_arch = "x86") + )), + doc = " ```" +)] /// # use libc::c_int; /// # use std::os::unix::io::AsFd; /// # use std::sync::atomic::{AtomicBool, Ordering}; From ab5c4ef7ad8db97aa9001b36e0d222020ab861e3 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Wed, 5 Nov 2025 11:34:10 +0800 Subject: [PATCH 14/17] Set RUST_BACKTRACE=1 when running tests Set this to enable the backtrace to make debugging easier --- .github/actions/test/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 6aa2bfe5ae..df6a18bed5 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -31,6 +31,8 @@ runs: run: | echo "RUSTFLAGS=${{ inputs.RUSTFLAGS }}" >> $GITHUB_ENV echo "RUSTDOCFLAGS=${{ inputs.RUSTDOCFLAGS }}" >> $GITHUB_ENV + # Enable backtrace to make debugging easier + echo "RUST_BACKTRACE=1" >> $GITHUB_ENV - name: test shell: bash From 7d2dabd21d78b0483fa40c6a8a4e836893db4612 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Wed, 5 Nov 2025 11:56:54 +0800 Subject: [PATCH 15/17] Cross env var passthrough: RUSTDOCFLAGS and RUST_BACKTRACE I don't know if "RUSTDOCFLAGS" will be passed automatically, but from their doc [1]: > In the instances that you do want to pass through additional environment > variables, this can be done via build.env.passthrough in your Cross.toml: > > ```toml > [build.env] > passthrough = [ > "RUST_BACKTRACE" > ] > ``` We do need to specify "RUST_BACKTRACE" here. Anyway, let's pass both in case Cross won't do this for us. [1]: https://github.com/cross-rs/cross/blob/49cd054de9b832dfc11a4895c72b0aef533b5c6a/docs/environment_variables.md#environment-variable-passthrough --- Cross.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cross.toml b/Cross.toml index 0fc503c6de..b806cd9180 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,7 +1,9 @@ [build.env] passthrough = [ "RUSTFLAGS", + "RUSTDOCFLAGS" "RUST_TEST_THREADS" + "RUST_BACKTRACE" ] [target.loongarch64-unknown-linux-gnu] From ece6909fd4d7a40162ad4f9f47ddd23ae142ab39 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Wed, 5 Nov 2025 13:56:18 +0800 Subject: [PATCH 16/17] Correct Cross.toml syntax: missing comma --- Cross.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cross.toml b/Cross.toml index b806cd9180..0f4c44b953 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,9 +1,9 @@ [build.env] passthrough = [ "RUSTFLAGS", - "RUSTDOCFLAGS" - "RUST_TEST_THREADS" - "RUST_BACKTRACE" + "RUSTDOCFLAGS", + "RUST_TEST_THREADS", + "RUST_BACKTRACE", ] [target.loongarch64-unknown-linux-gnu] From aadefd85347cb56dd6223b738fb436f451f6dc31 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Thu, 6 Nov 2025 07:13:05 +0800 Subject: [PATCH 17/17] Revert "Adjust atomics in the lio_listio doc test" As these changes are not necessary --- src/sys/aio.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index 71b734c68b..7f873be0c1 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -1176,12 +1176,12 @@ pub fn aio_suspend( /// pub static SIGNALED: AtomicBool = AtomicBool::new(false); /// /// extern fn sigfunc(_: c_int) { -/// SIGNALED.store(true, Ordering::Release); +/// SIGNALED.store(true, Ordering::Relaxed); /// } /// let sa = SigAction::new(SigHandler::Handler(sigfunc), /// SaFlags::SA_RESETHAND, /// SigSet::empty()); -/// SIGNALED.store(false, Ordering::Release); +/// SIGNALED.store(false, Ordering::Relaxed); /// unsafe { sigaction(Signal::SIGUSR2, &sa) }.unwrap(); /// /// const WBUF: &[u8] = b"abcdef123456"; @@ -1195,7 +1195,7 @@ pub fn aio_suspend( /// )); /// let sev = SigevNotify::SigevSignal { signal: Signal::SIGUSR2, si_value: 0 }; /// lio_listio(LioMode::LIO_NOWAIT, &mut[aiow.as_mut()], sev).unwrap(); -/// while !SIGNALED.load(Ordering::Acquire) { +/// while !SIGNALED.load(Ordering::Relaxed) { /// thread::sleep(time::Duration::from_millis(10)); /// } /// // At this point, since `lio_listio` returned success and delivered its