From d3697a962323668b66039f5a3e6ce67ed5ce5517 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:28:23 +0100 Subject: [PATCH 1/9] build: bump MSRV to 1.91 With 1.91 the strict arithmetic functions got stabilized, and we use them all over the place already. Update the documentation to reflect that. We also make use of a lot of const-fn in the new dbus modules, and those also require newer rustc. Lets settle on 1.91 for now, and ensure that CI verifies builds with it in a follow up. Signed-off-by: David Rheinsberg --- Cargo.toml | 2 +- README.md | 2 +- meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a2fc591..4d497b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ homepage = "https://www.bus1.eu" license = "MIT OR Apache-2.0 OR LGPL-2.1-or-later" readme = "README.md" repository = "https://github.com/bus1/sys" -rust-version = "1.84" +rust-version = "1.91" [workspace.dependencies] libc = { default-features = false, version = "0.2.175" } diff --git a/README.md b/README.md index 24858fc..523e19d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ system specific interfaces. The requirements for this project are: - * `rustc >= 1.83` + * `rustc >= 1.91` ### Repository: diff --git a/meson.build b/meson.build index 83ad27f..e7d8c69 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ project( add_languages('rust', native: false) rust_edition = '2021' -rust_msv = '1.74' +rust_msv = '1.91' mod_rust = import('rust') rust = meson.get_compiler('rust') From f0ac542828bbd5f1eedb29cf844f869d1a86e903 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:34:09 +0100 Subject: [PATCH 2/9] build: enable cfg-checks on meson builds Pass the new `--check-cfg` flag for all used cfg-options, so rustc can start checking all uses of `#[cfg]`. Signed-off-by: David Rheinsberg --- meson.build | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index e7d8c69..11dd45a 100644 --- a/meson.build +++ b/meson.build @@ -92,11 +92,20 @@ endif use_std = get_option('std') +# +# Global configuration +# + +rlib_rust_args = [ + '--check-cfg=cfg(feature, values("libc", "std"))', + '--check-cfg=cfg(test)', +] + # # Target: libosi # -libosi_rlib_rust_args = [] +libosi_rlib_rust_args = rlib_rust_args if use_std libosi_rlib_rust_args += ['--cfg=feature="std"'] @@ -120,7 +129,7 @@ meson.override_dependency('libosi-' + libosi_major, libosi_dep, static: true) # libsys_rlib_deps = [libosi_dep] -libsys_rlib_rust_args = [] +libsys_rlib_rust_args = rlib_rust_args if use_libc libsys_rlib_deps += [dep_libc] @@ -150,20 +159,18 @@ meson.override_dependency('libsys-' + libsys_major, libsys_dep, static: true) # Target: libtmp # +libtmp_rlib_deps = [libosi_dep, libsys_dep] +libtmp_rlib_rust_args = rlib_rust_args + libtmp_rlib = static_library( 'tmp', ['lib/tmp/src/lib.rs'], - dependencies: [ - libosi_dep, - libsys_dep, - ], + dependencies: libtmp_rlib_deps, + rust_args: libtmp_rlib_rust_args, ) libtmp_dep = declare_dependency( - dependencies: [ - libosi_dep, - libsys_dep, - ], + dependencies: libtmp_rlib_deps, link_with: libtmp_rlib, version: libtmp_version, ) From 5de903f9f3666a4f2bd77000dbf5383136b94805 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:35:22 +0100 Subject: [PATCH 3/9] sys: make `libc` an explicit feature Rather than relying on the obscure default feature for optional dependencies, provide `libc` as an explicit feature. Signed-off-by: David Rheinsberg --- lib/sys/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sys/Cargo.toml b/lib/sys/Cargo.toml index 401d0d1..5bcdd22 100644 --- a/lib/sys/Cargo.toml +++ b/lib/sys/Cargo.toml @@ -20,6 +20,7 @@ repository.workspace = true rust-version.workspace = true [features] +libc = ["dep:libc"] std = [] [dependencies] From fe6b718d88864c4ccc46f701638a222858b87ad3 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:36:30 +0100 Subject: [PATCH 4/9] build: inherit worspace lints Add a new lint section and ensure that all workspace projects inherit the lints properly. Signed-off-by: David Rheinsberg --- Cargo.toml | 3 +++ lib/osi/Cargo.toml | 3 +++ lib/sys/Cargo.toml | 3 +++ lib/tmp/Cargo.toml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 4d497b1..05e36b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,3 +29,6 @@ libc = { default-features = false, version = "0.2.175" } osi = { path = "./lib/osi", version = "1.0.0" } sys = { path = "./lib/sys", version = "1.0.0" } tmp = { path = "./lib/tmp", version = "1.0.0" } + +[workspace.lints.rust.unexpected_cfgs] +level = "warn" diff --git a/lib/osi/Cargo.toml b/lib/osi/Cargo.toml index b309f22..fa7d550 100644 --- a/lib/osi/Cargo.toml +++ b/lib/osi/Cargo.toml @@ -21,3 +21,6 @@ rust-version.workspace = true [features] std = [] + +[lints] +workspace = true diff --git a/lib/sys/Cargo.toml b/lib/sys/Cargo.toml index 5bcdd22..96d54c5 100644 --- a/lib/sys/Cargo.toml +++ b/lib/sys/Cargo.toml @@ -26,3 +26,6 @@ std = [] [dependencies] libc = { optional = true, workspace = true } osi = { workspace = true } + +[lints] +workspace = true diff --git a/lib/tmp/Cargo.toml b/lib/tmp/Cargo.toml index 0ac46f6..7bb642d 100644 --- a/lib/tmp/Cargo.toml +++ b/lib/tmp/Cargo.toml @@ -25,3 +25,6 @@ polonius = [] [dependencies] osi = { workspace = true } sys = { workspace = true } + +[lints] +workspace = true From 4fc4bc89010d31ce9db392ce2fb93d51b45ba143 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:37:11 +0100 Subject: [PATCH 5/9] tmp: replace "feature=polonius" with just "polonius" Rather than making the polonius verification a feature, use a plain configuration option. This is more cumbersome to use, but that is also the point. Users should not be required to make use of it. The advantage is that `--all-features` can now be used again, and does not require using nightly compilers and enabling polonius. Signed-off-by: David Rheinsberg --- Cargo.toml | 3 +++ lib/tmp/Cargo.toml | 3 --- lib/tmp/src/fmt/json/token.rs | 2 +- meson.build | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 05e36b0..344c95e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,3 +32,6 @@ tmp = { path = "./lib/tmp", version = "1.0.0" } [workspace.lints.rust.unexpected_cfgs] level = "warn" +check-cfg = [ + "cfg(polonius)" +] diff --git a/lib/tmp/Cargo.toml b/lib/tmp/Cargo.toml index 7bb642d..9991809 100644 --- a/lib/tmp/Cargo.toml +++ b/lib/tmp/Cargo.toml @@ -19,9 +19,6 @@ readme.workspace = true repository.workspace = true rust-version.workspace = true -[features] -polonius = [] - [dependencies] osi = { workspace = true } sys = { workspace = true } diff --git a/lib/tmp/src/fmt/json/token.rs b/lib/tmp/src/fmt/json/token.rs index d98d892..ea2e0c7 100644 --- a/lib/tmp/src/fmt/json/token.rs +++ b/lib/tmp/src/fmt/json/token.rs @@ -828,7 +828,7 @@ impl<'read> Dec<'read> { // correctness of Polonius. let fixed = { osi::cfg::cond! { - (feature = "polonius") { v }, + (polonius) { v }, { // SAFETY: Workaround for NLL, unneeded with Polonius. unsafe { core::mem::transmute(v) } diff --git a/meson.build b/meson.build index 11dd45a..bdfc644 100644 --- a/meson.build +++ b/meson.build @@ -98,6 +98,7 @@ use_std = get_option('std') rlib_rust_args = [ '--check-cfg=cfg(feature, values("libc", "std"))', + '--check-cfg=cfg(polonius)', '--check-cfg=cfg(test)', ] From f3b41176d38d5c4f1372adb9f95364f45af028a6 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:38:46 +0100 Subject: [PATCH 6/9] ci: run a polonius build Run one build using polonius and explicitly make use of it in our code-base to verify unsafe code that needs workarounds without polonius. Signed-off-by: David Rheinsberg --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 774265c..663fc13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,9 +163,26 @@ jobs: image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" toolchain: nightly + # Test a nightly build with polonius, verifying the code that works + # around deficiencies of non-polonius builds. + - id: "polonius" + name: "Ubuntu-x86_64-nightly-polonius" + + cargoargs: >- + --all-targets + --features libc + --profile=release + image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" + rustflags: >- + --cfg polonius + -Z polonius + toolchain: nightly + container: image: ${{ matrix.image }} options: "--user root" + env: + RUSTFLAGS: ${{ matrix.rustflags }} runs-on: "ubuntu-latest" steps: From 06db380e42d777d14c410113c84dbcdc39841f76 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:48:42 +0100 Subject: [PATCH 7/9] ci: enable all features again With `polonius` moved to a proper cfg, we can enable all features again. Signed-off-by: David Rheinsberg --- .github/workflows/ci.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663fc13..e797ff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,11 @@ defaults: env: CC: clang CC_LD: lld + CI_CARGO_ARGS: >- + --all-features + --all-targets + --verbose + --workspace CI_MESON_ARGS: >- --buildtype debugoptimized --warnlevel 2 @@ -68,7 +73,7 @@ jobs: uses: actions/checkout@v4 - name: "Run Analyzer" - run: cargo check --all-targets --features libc --verbose --workspace + run: cargo check ${CI_CARGO_ARGS} # # A complete but basic build of the project, running on common x86-64 ubuntu @@ -89,7 +94,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: cargo test --all-targets --features libc --verbose --workspace + run: cargo test ${CI_CARGO_ARGS} # # A simple no-op job that serves as guard. All extended jobs depend on this @@ -124,7 +129,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: cargo test --all-targets --features libc --verbose --workspace + run: cargo test ${CI_CARGO_ARGS} # # A matrix of project builds with different settings. All builds run the @@ -146,8 +151,8 @@ jobs: # Explicitly set all options here to document them. cargoargs: >- + --all-features --all-targets - --features libc --profile=release image: "ghcr.io/readaheadeu/rae-ci-archlinux:latest" toolchain: stable @@ -157,8 +162,8 @@ jobs: name: "Ubuntu-x86_64-nightly-release" cargoargs: >- + --all-features --all-targets - --features libc --profile=release image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" toolchain: nightly @@ -218,14 +223,7 @@ jobs: uses: actions/checkout@v4 - name: "Build and Test" - run: | - cargo \ - test \ - --all-targets \ - --features libc \ - --target i686-unknown-linux-gnu \ - --verbose \ - --workspace + run: cargo test ${CI_CARGO_ARGS} --target i686-unknown-linux-gnu # # A development build using the meson build system. From b80bebd23f91136be92fc3399eeafde30cf90fab Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:49:09 +0100 Subject: [PATCH 8/9] ci: use polonius=next for test builds The legacy polonius implementation is not updated anymore, and thus produces some ICEs with libc builds. Use polonius=next, which is what we want, anyway. Signed-off-by: David Rheinsberg --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e797ff3..37cc7b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -174,13 +174,13 @@ jobs: name: "Ubuntu-x86_64-nightly-polonius" cargoargs: >- + --all-features --all-targets - --features libc --profile=release image: "ghcr.io/readaheadeu/rae-ci-ubuntu:latest" rustflags: >- --cfg polonius - -Z polonius + -Z polonius=next toolchain: nightly container: From 0afa6ba30625564edbaa2d6d09193aa87bfcb917 Mon Sep 17 00:00:00 2001 From: David Rheinsberg Date: Mon, 12 Jan 2026 11:59:23 +0100 Subject: [PATCH 9/9] ci: add a verifying MSRV run Add another build that uses the MSRV to verify that we do not use newer features than announced. Signed-off-by: David Rheinsberg --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37cc7b8..7dd6147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -249,3 +249,27 @@ jobs: - name: "Run Tests" run: meson test -C "./build" + + # + # A development build using the MSRV. To avoid updating our own container + # images with that version all the time, use the official images for it. + # This means, we cannot rely on any other utilities to be present, so just + # run a straight cargo build. + # + ext_msrv: + name: "Ext: msrv @ rust:" + needs: ext_guard + + container: + image: "rust:1.91-alpine" + defaults: + run: + shell: "sh" + runs-on: "ubuntu-latest" + + steps: + - name: "Fetch Sources" + uses: actions/checkout@v4 + + - name: "Build and Test" + run: cargo test ${CI_CARGO_ARGS}