Skip to content

Commit

Permalink
Run the tests on Rust 1.48, and check compilation of tests and exampl…
Browse files Browse the repository at this point in the history
…es on more targets (#465)

* Fix the tests to run on 1.48.

This puts the benchmarks behind a `criterion` cfg, so add
`--cfg=criterion` to RUSTFLAGS when running cargo bench.

An MSRV of 1.48 enables us to support users such as async-io, which also
has an MSRV of 1.48.

* Add a rust-version field.

This prints a warning under Rust 1.48, but only when rustix is the
top-level build; when rustix is a dependency, it doesn't warn, so this
seems ok.
  • Loading branch information
sunfishcode committed Dec 5, 2022
1 parent 99a903e commit 980b147
Show file tree
Hide file tree
Showing 10 changed files with 330 additions and 127 deletions.
168 changes: 134 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:

env:
# -D warnings is commented out in our install-rust action; re-add it here.
# In theory we should add --cfg criterion here, but criterion doesn't compile under Rust 1.48.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -85,38 +86,38 @@ jobs:
if: matrix.rust == '1.48'
run: cargo update --package=once_cell --precise 1.14.0

- run: cargo check --workspace --release -vv
- run: cargo check --workspace --release -vv --features=all-apis
- run: cargo check --workspace --release -vv --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=aarch64-linux-android
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-gnux32 --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-linux-android --features=all-apis
- run: cargo check --workspace --release -vv --target=i686-linux-android --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-fuchsia --features=all-apis
- run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos --features=all-apis
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis
- run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis
- run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis
- run: cargo check --workspace --release -vv --all-targets
- run: cargo check --workspace --release -vv --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --features=use-libc,all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=use-libc,all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-gnux32 --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-linux-android --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=i686-linux-android --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-fuchsia --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis --all-targets
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis --all-targets
- run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis --all-targets
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis --all-targets

check_no_default_features:
name: Check --no-default-features
Expand Down Expand Up @@ -189,7 +190,7 @@ jobs:
toolchain: ${{ matrix.rust }}
env:
# See the comments in the libc crate
RUSTFLAGS: -A improper_ctypes_definitions
RUSTFLAGS: -A improper_ctypes_definitions --cfg criterion
- run: rustup component add rust-src
- run: cargo check -Z build-std --target x86_64-unknown-openbsd --all-targets --features=all-apis
- run: cargo check -Z build-std --target mips64-openwrt-linux-musl --all-targets --features=all-apis
Expand All @@ -207,7 +208,7 @@ jobs:
QEMU_BUILD_VERSION: 7.0.0
strategy:
matrix:
build: [ubuntu, ubuntu-18.04, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, mipsel-linux-stable, mips64el-linux-stable, powerpc64le-linux-stable, arm-linux-stable, macos-latest, macos-10.15, windows, windows-2019]
build: [ubuntu, ubuntu-18.04, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, ubuntu-1.48, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, mipsel-linux-stable, mips64el-linux-stable, powerpc64le-linux-stable, arm-linux-stable, ubuntu-1.48, i686-linux-1.48, aarch64-linux-1.48, riscv64-linux-1.48, s390x-linux-1.48, mipsel-linux-1.48, mips64el-linux-1.48, powerpc64le-linux-1.48, arm-linux-1.48, macos-latest, macos-10.15, windows, windows-2019]
include:
- build: ubuntu
os: ubuntu-latest
Expand Down Expand Up @@ -358,6 +359,79 @@ jobs:
qemu: qemu-arm
qemu_args: -L /usr/arm-linux-gnueabi
qemu_target: arm-linux-user
- build: ubuntu-1.48
os: ubuntu-latest
rust: 1.48
- build: i686-linux-1.48
os: ubuntu-latest
rust: 1.48
target: i686-unknown-linux-gnu
gcc_package: gcc-i686-linux-gnu
gcc: i686-linux-gnu-gcc
libc_package: libc-dev-i386-cross
- build: aarch64-linux-1.48
os: ubuntu-latest
rust: 1.48
target: aarch64-unknown-linux-gnu
gcc_package: gcc-aarch64-linux-gnu
gcc: aarch64-linux-gnu-gcc
qemu: qemu-aarch64
qemu_args: -L /usr/aarch64-linux-gnu
qemu_target: aarch64-linux-user
- build: riscv64-linux-1.48
os: ubuntu-latest
rust: 1.48
target: riscv64gc-unknown-linux-gnu
gcc_package: gcc-riscv64-linux-gnu
gcc: riscv64-linux-gnu-gcc
qemu: qemu-riscv64
qemu_args: -L /usr/riscv64-linux-gnu
qemu_target: riscv64-linux-user
- build: s390x-linux-1.48
os: ubuntu-latest
rust: 1.48
target: s390x-unknown-linux-gnu
gcc_package: gcc-s390x-linux-gnu
gcc: s390x-linux-gnu-gcc
qemu: qemu-s390x
qemu_args: -L /usr/s390x-linux-gnu
qemu_target: s390x-linux-user
- build: powerpc64le-linux-1.48
os: ubuntu-latest
rust: 1.48
target: powerpc64le-unknown-linux-gnu
gcc_package: gcc-powerpc64le-linux-gnu
gcc: powerpc64le-linux-gnu-gcc
qemu: qemu-ppc64le
qemu_args: -L /usr/powerpc64le-linux-gnu
qemu_target: ppc64le-linux-user
- build: mips64el-linux-1.48
os: ubuntu-latest
rust: 1.48
target: mips64el-unknown-linux-gnuabi64
gcc_package: gcc-mips64el-linux-gnuabi64
gcc: mips64el-linux-gnuabi64-gcc
qemu: qemu-mips64el
qemu_args: -L /usr/mips64el-linux-gnuabi64
qemu_target: mips64el-linux-user
- build: mipsel-linux-1.48
os: ubuntu-latest
rust: 1.48
target: mipsel-unknown-linux-gnu
gcc_package: gcc-mipsel-linux-gnu
gcc: mipsel-linux-gnu-gcc
qemu: qemu-mipsel
qemu_args: -L /usr/mipsel-linux-gnu
qemu_target: mipsel-linux-user
- build: arm-linux-1.48
os: ubuntu-latest
rust: 1.48
target: armv5te-unknown-linux-gnueabi
gcc_package: gcc-arm-linux-gnueabi
gcc: arm-linux-gnueabi-gcc
qemu: qemu-arm
qemu_args: -L /usr/arm-linux-gnueabi
qemu_target: arm-linux-user
- build: macos-latest
os: macos-latest
rust: stable
Expand Down Expand Up @@ -432,15 +506,41 @@ jobs:
ninja -C build install
if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'

- name: Use specific dependency versions for Rust 1.48 compatibility.
if: matrix.rust == '1.48'
run: cargo update --package=once_cell --precise 1.14.0

- run: |
# Run the tests, and check the prebuilt release libraries.
cargo test --verbose --features=all-impls,all-apis,cc --release --workspace -- --nocapture
env:
RUST_BACKTRACE: full
if: matrix.rust != '1.48'
- run: |
# Run the tests with Rust 1.48, and check the prebuilt release libraries.
# Don't use all-impls because some of the impls have dependencies that
# don't support Rust 1.48.
cargo test --verbose --features=fs-err,all-apis,cc --release --workspace -- --nocapture
env:
RUST_BACKTRACE: full
if: matrix.rust == '1.48'
- run: |
# Check the prebuilt debug libraries too.
cargo check --features=all-impls,all-apis,cc
env:
RUST_BACKTRACE: full
if: matrix.rust != '1.48'
- run: |
# Check the prebuilt debug libraries with Rust 1.48 too.
# Don't use all-impls because some of the impls have dependencies that
# don't support Rust 1.48.
cargo check --features=fs-err,all-apis,cc
env:
RUST_BACKTRACE: full
if: matrix.rust == '1.48'
test_use_libc:
name: Test use-libc
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ edition = "2018"
keywords = ["api", "file", "network", "safe", "syscall"]
categories = ["os::unix-apis", "date-and-time", "filesystem", "network-programming"]
include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md", "benches"]
rust-version = "1.48"

[build-dependencies]
cc = { version = "1.0.68", optional = true }
Expand Down Expand Up @@ -78,7 +79,7 @@ serial_test = "0.6"
memoffset = "0.7.1"
flate2 = "1.0"

[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi")))'.dev-dependencies]
[target.'cfg(all(criterion, not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies]
criterion = "0.4"

[target.'cfg(windows)'.dev-dependencies]
Expand Down
25 changes: 25 additions & 0 deletions benches/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/// Benchmarks for rustix.
///
/// To enable these benchmarks, add `--cfg=criterion` to RUSTFLAGS and enable
/// the "fs", "time", and "process" cargo features.

#[cfg(any(
not(criterion),
not(feature = "fs"),
not(feature = "process"),
not(feature = "time"),
windows,
target_os = "emscripten",
target_os = "redox",
Expand All @@ -9,6 +18,10 @@ fn main() {
}

#[cfg(not(any(
not(criterion),
not(feature = "fs"),
not(feature = "process"),
not(feature = "time"),
windows,
target_os = "emscripten",
target_os = "redox",
Expand All @@ -17,6 +30,10 @@ fn main() {
use criterion::{criterion_group, criterion_main};

#[cfg(not(any(
not(criterion),
not(feature = "fs"),
not(feature = "process"),
not(feature = "time"),
windows,
target_os = "emscripten",
target_os = "redox",
Expand Down Expand Up @@ -132,6 +149,10 @@ mod suite {
}

#[cfg(not(any(
not(criterion),
not(feature = "fs"),
not(feature = "process"),
not(feature = "time"),
windows,
target_os = "emscripten",
target_os = "redox",
Expand All @@ -149,6 +170,10 @@ criterion_group!(
suite::simple_getpid_libc
);
#[cfg(not(any(
not(criterion),
not(feature = "fs"),
not(feature = "process"),
not(feature = "time"),
windows,
target_os = "emscripten",
target_os = "redox",
Expand Down

0 comments on commit 980b147

Please sign in to comment.