Skip to content

Commit d66ba5c

Browse files
authored
Run the tests on Rust 1.48, and check compilation of tests and examples 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.
1 parent ce30bd9 commit d66ba5c

File tree

12 files changed

+340
-129
lines changed

12 files changed

+340
-129
lines changed

.github/workflows/main.yml

Lines changed: 134 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939

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

88-
- run: cargo check --workspace --release -vv
89-
- run: cargo check --workspace --release -vv --features=all-apis
90-
- run: cargo check --workspace --release -vv --features=use-libc,all-apis
91-
- run: cargo check --workspace --release -vv --target=aarch64-linux-android
92-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=all-apis
93-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=use-libc,all-apis
94-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-gnux32 --features=all-apis
95-
- run: cargo check --workspace --release -vv --target=x86_64-linux-android --features=all-apis
96-
- run: cargo check --workspace --release -vv --target=i686-linux-android --features=all-apis
97-
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --features=all-apis
98-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd --features=all-apis
99-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd --features=all-apis
100-
- run: cargo check --workspace --release -vv --target=x86_64-fuchsia --features=all-apis
101-
- run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos --features=all-apis
102-
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu --features=all-apis
103-
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis
104-
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis
105-
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis
106-
- run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis
107-
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis
108-
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis
109-
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis
110-
- run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis
111-
- run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis
112-
- run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
113-
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis
114-
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis
115-
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis
116-
- run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis
117-
- run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis
118-
- run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis
119-
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis
89+
- run: cargo check --workspace --release -vv --all-targets
90+
- run: cargo check --workspace --release -vv --features=all-apis --all-targets
91+
- run: cargo check --workspace --release -vv --features=use-libc,all-apis --all-targets
92+
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --all-targets
93+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=all-apis --all-targets
94+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=use-libc,all-apis --all-targets
95+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-gnux32 --features=all-apis --all-targets
96+
- run: cargo check --workspace --release -vv --target=x86_64-linux-android --features=all-apis --all-targets
97+
- run: cargo check --workspace --release -vv --target=i686-linux-android --features=all-apis --all-targets
98+
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --features=all-apis --all-targets
99+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd --features=all-apis --all-targets
100+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd --features=all-apis --all-targets
101+
- run: cargo check --workspace --release -vv --target=x86_64-fuchsia --features=all-apis --all-targets
102+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos --features=all-apis --all-targets
103+
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu --features=all-apis --all-targets
104+
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis --all-targets
105+
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis --all-targets
106+
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis --all-targets
107+
- run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis --all-targets
108+
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis --all-targets
109+
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis --all-targets
110+
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis --all-targets
111+
- run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis --all-targets
112+
- run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis --all-targets
113+
- run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis --all-targets
114+
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis --all-targets
115+
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis --all-targets
116+
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis --all-targets
117+
- run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis --all-targets
118+
- run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis --all-targets
119+
- run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis --all-targets
120+
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis --all-targets
120121

121122
check_no_default_features:
122123
name: Check --no-default-features
@@ -189,7 +190,7 @@ jobs:
189190
toolchain: ${{ matrix.rust }}
190191
env:
191192
# See the comments in the libc crate
192-
RUSTFLAGS: -A improper_ctypes_definitions
193+
RUSTFLAGS: -A improper_ctypes_definitions --cfg criterion
193194
- run: rustup component add rust-src
194195
- run: cargo check -Z build-std --target x86_64-unknown-openbsd --all-targets --features=all-apis
195196
- run: cargo check -Z build-std --target mips64-openwrt-linux-musl --all-targets --features=all-apis
@@ -207,7 +208,7 @@ jobs:
207208
QEMU_BUILD_VERSION: 7.0.0
208209
strategy:
209210
matrix:
210-
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]
211+
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]
211212
include:
212213
- build: ubuntu
213214
os: ubuntu-latest
@@ -358,6 +359,79 @@ jobs:
358359
qemu: qemu-arm
359360
qemu_args: -L /usr/arm-linux-gnueabi
360361
qemu_target: arm-linux-user
362+
- build: ubuntu-1.48
363+
os: ubuntu-latest
364+
rust: 1.48
365+
- build: i686-linux-1.48
366+
os: ubuntu-latest
367+
rust: 1.48
368+
target: i686-unknown-linux-gnu
369+
gcc_package: gcc-i686-linux-gnu
370+
gcc: i686-linux-gnu-gcc
371+
libc_package: libc-dev-i386-cross
372+
- build: aarch64-linux-1.48
373+
os: ubuntu-latest
374+
rust: 1.48
375+
target: aarch64-unknown-linux-gnu
376+
gcc_package: gcc-aarch64-linux-gnu
377+
gcc: aarch64-linux-gnu-gcc
378+
qemu: qemu-aarch64
379+
qemu_args: -L /usr/aarch64-linux-gnu
380+
qemu_target: aarch64-linux-user
381+
- build: riscv64-linux-1.48
382+
os: ubuntu-latest
383+
rust: 1.48
384+
target: riscv64gc-unknown-linux-gnu
385+
gcc_package: gcc-riscv64-linux-gnu
386+
gcc: riscv64-linux-gnu-gcc
387+
qemu: qemu-riscv64
388+
qemu_args: -L /usr/riscv64-linux-gnu
389+
qemu_target: riscv64-linux-user
390+
- build: s390x-linux-1.48
391+
os: ubuntu-latest
392+
rust: 1.48
393+
target: s390x-unknown-linux-gnu
394+
gcc_package: gcc-s390x-linux-gnu
395+
gcc: s390x-linux-gnu-gcc
396+
qemu: qemu-s390x
397+
qemu_args: -L /usr/s390x-linux-gnu
398+
qemu_target: s390x-linux-user
399+
- build: powerpc64le-linux-1.48
400+
os: ubuntu-latest
401+
rust: 1.48
402+
target: powerpc64le-unknown-linux-gnu
403+
gcc_package: gcc-powerpc64le-linux-gnu
404+
gcc: powerpc64le-linux-gnu-gcc
405+
qemu: qemu-ppc64le
406+
qemu_args: -L /usr/powerpc64le-linux-gnu
407+
qemu_target: ppc64le-linux-user
408+
- build: mips64el-linux-1.48
409+
os: ubuntu-latest
410+
rust: 1.48
411+
target: mips64el-unknown-linux-gnuabi64
412+
gcc_package: gcc-mips64el-linux-gnuabi64
413+
gcc: mips64el-linux-gnuabi64-gcc
414+
qemu: qemu-mips64el
415+
qemu_args: -L /usr/mips64el-linux-gnuabi64
416+
qemu_target: mips64el-linux-user
417+
- build: mipsel-linux-1.48
418+
os: ubuntu-latest
419+
rust: 1.48
420+
target: mipsel-unknown-linux-gnu
421+
gcc_package: gcc-mipsel-linux-gnu
422+
gcc: mipsel-linux-gnu-gcc
423+
qemu: qemu-mipsel
424+
qemu_args: -L /usr/mipsel-linux-gnu
425+
qemu_target: mipsel-linux-user
426+
- build: arm-linux-1.48
427+
os: ubuntu-latest
428+
rust: 1.48
429+
target: armv5te-unknown-linux-gnueabi
430+
gcc_package: gcc-arm-linux-gnueabi
431+
gcc: arm-linux-gnueabi-gcc
432+
qemu: qemu-arm
433+
qemu_args: -L /usr/arm-linux-gnueabi
434+
qemu_target: arm-linux-user
361435
- build: macos-latest
362436
os: macos-latest
363437
rust: stable
@@ -432,15 +506,41 @@ jobs:
432506
ninja -C build install
433507
if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
434508

509+
- name: Use specific dependency versions for Rust 1.48 compatibility.
510+
if: matrix.rust == '1.48'
511+
run: cargo update --package=once_cell --precise 1.14.0
512+
435513
- run: |
436514
# Run the tests, and check the prebuilt release libraries.
437515
cargo test --verbose --features=all-impls,all-apis,cc --release --workspace -- --nocapture
438516
env:
439517
RUST_BACKTRACE: full
518+
if: matrix.rust != '1.48'
519+
520+
- run: |
521+
# Run the tests with Rust 1.48, and check the prebuilt release libraries.
522+
# Don't use all-impls because some of the impls have dependencies that
523+
# don't support Rust 1.48.
524+
cargo test --verbose --features=fs-err,all-apis,cc --release --workspace -- --nocapture
525+
env:
526+
RUST_BACKTRACE: full
527+
if: matrix.rust == '1.48'
440528
441529
- run: |
442530
# Check the prebuilt debug libraries too.
443531
cargo check --features=all-impls,all-apis,cc
532+
env:
533+
RUST_BACKTRACE: full
534+
if: matrix.rust != '1.48'
535+
536+
- run: |
537+
# Check the prebuilt debug libraries with Rust 1.48 too.
538+
# Don't use all-impls because some of the impls have dependencies that
539+
# don't support Rust 1.48.
540+
cargo check --features=fs-err,all-apis,cc
541+
env:
542+
RUST_BACKTRACE: full
543+
if: matrix.rust == '1.48'
444544
445545
test_use_libc:
446546
name: Test use-libc

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ edition = "2018"
1313
keywords = ["api", "file", "network", "safe", "syscall"]
1414
categories = ["os::unix-apis", "date-and-time", "filesystem", "network-programming"]
1515
include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md", "benches"]
16+
rust-version = "1.48"
1617

1718
[build-dependencies]
1819
cc = { version = "1.0.68", optional = true }
@@ -78,7 +79,7 @@ serial_test = "0.6"
7879
memoffset = "0.7.1"
7980
flate2 = "1.0"
8081

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

8485
[target.'cfg(windows)'.dev-dependencies]

benches/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
/// Benchmarks for rustix.
2+
///
3+
/// To enable these benchmarks, add `--cfg=criterion` to RUSTFLAGS and enable
4+
/// the "fs", "time", and "process" cargo features.
5+
16
#[cfg(any(
7+
not(criterion),
8+
not(feature = "fs"),
9+
not(feature = "process"),
10+
not(feature = "time"),
211
windows,
312
target_os = "emscripten",
413
target_os = "redox",
@@ -9,6 +18,10 @@ fn main() {
918
}
1019

1120
#[cfg(not(any(
21+
not(criterion),
22+
not(feature = "fs"),
23+
not(feature = "process"),
24+
not(feature = "time"),
1225
windows,
1326
target_os = "emscripten",
1427
target_os = "redox",
@@ -17,6 +30,10 @@ fn main() {
1730
use criterion::{criterion_group, criterion_main};
1831

1932
#[cfg(not(any(
33+
not(criterion),
34+
not(feature = "fs"),
35+
not(feature = "process"),
36+
not(feature = "time"),
2037
windows,
2138
target_os = "emscripten",
2239
target_os = "redox",
@@ -132,6 +149,10 @@ mod suite {
132149
}
133150

134151
#[cfg(not(any(
152+
not(criterion),
153+
not(feature = "fs"),
154+
not(feature = "process"),
155+
not(feature = "time"),
135156
windows,
136157
target_os = "emscripten",
137158
target_os = "redox",
@@ -149,6 +170,10 @@ criterion_group!(
149170
suite::simple_getpid_libc
150171
);
151172
#[cfg(not(any(
173+
not(criterion),
174+
not(feature = "fs"),
175+
not(feature = "process"),
176+
not(feature = "time"),
152177
windows,
153178
target_os = "emscripten",
154179
target_os = "redox",

0 commit comments

Comments
 (0)