Skip to content

ci: build and test the Cargo feature sets that CMake uses #2056

Closed

Description

@vpacher

Summary

Some Cargo features in the Rust workspace mirror C build options. CMake selects these features per platform. The Rust CI lanes build with --workspace, and Cargo unifies the features. The lanes therefore do not build the feature sets that CMake ships. This issue proposes a feature matrix lane and one workspace rule for third-party dependencies.

Related: #1873 (glob imports, fixed by #1956). This is the Cargo feature-matrix issue proposed there (comment 6368573706). It is a separate issue, because the tooling and the risk are different.

Problem

1. Feature sets that CMake ships are not built in CI

  • rust/libobs-rust/Cargo.toml: default = ["gio"], gio = ["obs-util/gio"].
  • obs-util/gio mirrors GIO_FOUND (obsconfig.h).
  • libobs/cmake/os-linux.cmake:82-84 and libobs/cmake/os-freebsd.cmake:77-79 set NO_DEFAULT_FEATURES and add gio only when find_package(Gio) finds it.
  • .github/workflows/build-project.yaml:1899 runs soldr cargo test --workspace --locked.
  • .github/workflows/build-project.yaml:1902 runs soldr cargo clippy --locked --workspace --all-targets -- -D warnings.
  • In both runs, cargo tree --workspace -e features -i obs-util shows obs-util feature "gio" enabled (from the libobs-rust default features). Checked on master 6891f69.

Result: the #[cfg(not(feature = "gio"))] code in rust/obs-util/src/ffi/platform_nix_inhibit.rs is not compiled, linted or tested by the Rust lanes. A libobs built without GIO ships this code.

The same risk applies in the other direction to opt-in features. They are off in the --workspace lanes:

Crate Feature In --workspace lanes Other check found
libobs-rust / obs-util gio always on none for "off" (CMake build without Gio only)
obs-studio-rust → obs-build libobs-integration off a few tests on macOS/Windows: rust-tests Qt SDK step (build-project.yaml:1952), Tier 2 (rust/tools/tier2-validate/validate.{sh,ps1}); no clippy
obs-studio-rust → obs-sys bundled-native / bundled off cargo check -p obs-sys --features bundled in Tier 2 macOS/Windows; no clippy (one-off clippy evidence: docs/ci-evidence/2026-10-18-test-binary-consolidation.json)

No lane passes --no-default-features. The opt-in features are built only for a few tests on macOS/Windows (Tier 2, Qt SDK step); no clippy run uses them.

2. Third-party dependencies are declared per crate

[workspace.dependencies] contains only libloading ("=0.8.9"). All other third-party dependencies are declared in each crate. Versions and features differ between crates:

Dependency Declarations
cc "1" (obs-c-oracle, obs-data, obs-util); "=1.6.0" + parallel (obs-build)
pkg-config "=0.3.34" (obs-build, obs-studio-rust); "0.3" (obs-c-oracle, obs-util)
serde "=1.0.229" (obs-build); "1.0.229" (obs-preflight)
serde_json "=1.0.151" (obs-build); "1.0.151" (obs-preflight, obs-studio-rust)
libc "0.2" (4 crates)
proptest "1", default features (9 crates)

Cargo.lock keeps the versions reproducible. The feature set of a dependency still depends on which crates are in the build. Some crates already disable default features (flate2, tungstenite, criterion). This is not a workspace rule.

Proposal

  1. Add a CI lane that builds the feature sets CMake uses:
    • Run cargo hack clippy --each-feature --all-targets (or --feature-powerset --depth 2) on the crates in the table above.
    • Or, as a minimum, on Linux:
      • cargo clippy -p libobs-rust --no-default-features --all-targets -- -D warnings
      • cargo test -p obs-util --no-default-features
      • cargo clippy -p obs-studio-rust --features libobs-integration,bundled-native --all-targets -- -D warnings
  2. Move all third-party dependencies to [workspace.dependencies]:
    • Set default-features = false in the workspace table.
    • In each crate, use dep = { workspace = true, features = [...] }.
    • Use one pin policy (= or caret) for the whole workspace. libloading already uses =.
    • The workspace already has [workspace.lints.clippy] (lint: deny glob imports in the Rust workspace (#1873) #1956), so the same workspace = true pattern applies.
  3. Optional: enforce rule 2 with cargo deny (bans, duplicates) or a ci_lint rule (candidate for zackees/ci.yml, next to the RUST-019 proposal in lint: ban glob imports (clippy::wildcard_imports) with explicit opt-out #1873).

Limitations

  • cargo hack --feature-powerset grows exponentially. Limit it to the crates with C-mirroring features.
  • Step 2 changes many Cargo.toml files. It does not change the resolved versions if the pins stay the same. Check with cargo tree before and after.
  • I did not build the gio-off path. I do not claim that it fails today. The issue is that CI does not check it.

Verification (for the RED/GREEN PR)

  1. RED: add the matrix lane. Show that -p libobs-rust --no-default-features is not in any current lane (lane log).
  2. GREEN: the lane passes on Linux and FreeBSD (or Linux only, with FreeBSD as a follow-up).
  3. For step 2: cargo tree --workspace -e features output is the same before and after, except for intended changes.

Activity

  1. vpacher commented on Oct 24, 2026

    @vpacher
    MemberAuthor

    Claiming: #2056

    Plan (two PRs, in this order):

    1. Feature matrix lane (proposal 1): RED first, which shows that -p libobs-rust --no-default-features and the opt-in feature sets are not built in any current lane. Then GREEN: the lane runs on Linux, with the minimum commands from the proposal (or cargo hack --each-feature on the crates in the table). FreeBSD can follow.
    2. [workspace.dependencies] (proposal 2): move the third-party dependencies, with default-features = false in the workspace table and one pin policy. cargo tree --workspace -e features before and after goes in the PR.

    Proposal 3 (cargo deny or a ci_lint rule) waits until 1 and 2 are merged.

  2. added
    claimed
    on Oct 24, 2026
  3. vpacher commented on Oct 24, 2026

    @vpacher
    MemberAuthor

    Correction: the opt-in features do run in CI, for a few tests: libobs-integration in the rust-tests Qt SDK step (build-project.yaml:1952) and in Tier 2 macOS/Windows (validate.sh/validate.ps1, with obs-sys --features bundled). No clippy run uses them, and nothing builds gio off. I updated the table in the description.

  4. vpacher commented on Oct 24, 2026

    @vpacher
    MemberAuthor

    Both parts are merged:

    Proposal 3 (cargo deny or a ci_lint rule in zackees/ci.yml) is not done; the repository test covers the rule for now. From my side this issue is complete.

  5. moved this from In progress to Triage in obs-rust Multiviewon Oct 25, 2026
  6. added
    ready
    and removed
    claimed
    on Oct 25, 2026
  7. moved this from Triage to In progress in obs-rust Multiviewon Oct 25, 2026
  8. vpacher commented on Oct 25, 2026

    @vpacher
    MemberAuthor

    Done: #2059 adds the lane that lints and tests the Cargo feature sets CMake uses (proposal 1), and #2061 moves every third-party dependency to [workspace.dependencies] (proposal 2). Both merged on 2026-10-24. The optional enforcement (proposal 3, cargo deny or a ci_lint rule) is not done; it can get its own issue if wanted.

  9. moved this from In progress to Done in obs-rust Multiviewon Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions