Skip to content
Open
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +35,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
Expand All @@ -52,13 +67,15 @@ 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'
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 }}

Expand Down
7 changes: 7 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ inputs:
required: false
default: -D warnings -A unknown-lints

RUSTDOCFLAGS:
required: false
default: -D warnings

runs:
using: "composite"
steps:
- name: set up Rust env
shell: bash
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
Expand Down
98 changes: 56 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -32,7 +28,7 @@ jobs:
- name: setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: '${{ env.MSRV }}'
toolchain: stable
components: clippy

- name: build
Expand All @@ -59,7 +55,7 @@ jobs:
- name: setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: '${{ env.MSRV }}'
toolchain: stable
components: clippy

- name: build
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -132,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
Expand All @@ -156,7 +152,7 @@ jobs:
- name: setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: '${{ env.MSRV }}'
toolchain: stable
components: clippy

- name: install targets
Expand Down Expand Up @@ -193,7 +189,7 @@ jobs:
- name: setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: '${{ env.MSRV }}'
toolchain: stable
components: clippy

- name: install targets
Expand All @@ -212,38 +208,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:
Expand Down Expand Up @@ -282,8 +251,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
Expand All @@ -299,10 +267,56 @@ 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
TARGETS: ""
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 }}'
TARGETS: '${{ env.TARGETS }}'
BUILD: '${{ env.BUILD }}'
NOCLIPPY: '${{ env.NOCLIPPY }}'
NODOC: '${{ env.NODOC }}'
NOHACK: '${{ env.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
Expand Down
4 changes: 3 additions & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[build.env]
passthrough = [
"RUSTFLAGS",
"RUST_TEST_THREADS"
"RUSTDOCFLAGS",
"RUST_TEST_THREADS",
"RUST_BACKTRACE",
]

[target.loongarch64-unknown-linux-gnu]
Expand Down
1 change: 1 addition & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ pub unsafe trait Flockable: std::os::fd::AsRawFd {}
pub struct Flock<T: Flockable>(T);

#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
#[allow(clippy::unnecessary_unwrap)] // https://github.com/rust-lang/rust-clippy/issues/15744
impl<T: Flockable> Drop for Flock<T> {
fn drop(&mut self) {
let res = Errno::result(unsafe { libc::flock(self.0.as_raw_fd(), libc::LOCK_UN) });
Expand Down
26 changes: 24 additions & 2 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1141,7 +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
// 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};
Expand Down
9 changes: 5 additions & 4 deletions src/sys/personality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -78,10 +79,10 @@ pub fn get() -> Result<Persona> {
///
/// 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));
Expand Down
2 changes: 2 additions & 0 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: AsMut<[u8]>> {
len: socklen_t,
val: MaybeUninit<T>,
}

#[cfg(apple_targets)]
#[cfg(feature = "net")]
impl<T: AsMut<[u8]>> Get<CString> for GetCString<T> {
fn uninit() -> Self {
GetCString {
Expand Down
8 changes: 4 additions & 4 deletions test/test_sendfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading