Skip to content

build(libobs): the Rust staticlib is a cached lib-module (#3265) - #3324

Merged
zackees merged 2 commits into
masterfrom
build/3265-rust-module-cache
Nov 1, 2026
Merged

zackees merged 2 commits into
masterfrom
build/3265-rust-module-cache

Conversation

@zackees

@zackees zackees commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Refs #3265. Stacked on #3321 (the module cache); this retargets to master once #3321 merges.

libobs-rust becomes one more cached module.

  • libobs/cmake/rust.cmake writes libobs-modcache-rust.json: the archive path, Corrosion's features, the triple, the profile and the C compiler.
  • On a hit, libobs links libobs_rust-cached, an IMPORTED archive that copies Corrosion's link libraries, options and directories, the macOS SDK path included. cargo-build_libobs_rust is excluded from the build, so cargo does not run. Corrosion still configures the crate, so the native link libraries stay correct.
  • ci/libobs_modules.py keys the staticlib on that json, Cargo.lock, root Cargo.toml, rust-toolchain.toml, rustc -vV, RUSTFLAGS and CFLAGS, and gio's pkg-config version. It also hashes every file of the 16 path crates libobs-rust builds with, found by walking their Cargo.toml normal and build dependencies (tests/ and benches/ left out), plus the files outside them that their build scripts read: libobs/obs-hotkeys.h and the vendored jansson headers. The walk is stdlib tomllib, because cargo metadata --offline fails in the linux-validate container.

RED: aa5fe95a4 adds 5 tests to ci/test_libobs_modules_cache.py. Without the change they fail with 4 errors and 1 failure.
GREEN: 967205e52. The 9 cache tests, the module tests, ci/test_rust_macos_sdk.py and ./lint pass.

End to end (Linux, linux-validate container, final commit):

case wall module compiles cargo
A: cold, then store 28 s 10 runs
B: fresh build dir, warm cache 15 s 0 (6 of 6 restored) does not run
B, after editing libobs/graphics/effect.c.h 9 s 1 (graphics) does not run

libobs.so exports are identical between A and B (1,767). Before this change, the same fresh-dir warm-cache case spent 11.6 s in _cargo-build_libobs_rust.

Not met: the acceptance criterion "warm rebuild 6.0 s → under 2 s". In this setup a no-op rebuild of libobs takes about 17 ms with or without the cache (3 runs each), because cargo isn't invoked at all, so the 6.0 s baseline doesn't reproduce here. Dropping the obs_serialize_cargo_build stalls is untouched as well.

Tiers 1-4 don't apply: this is build tooling, and a hit links the archive the same cargo build produced, and the export set is identical.

Base automatically changed from build/3262-module-cache to master November 1, 2026 04:02
@zackees
zackees force-pushed the build/3265-rust-module-cache branch from 967205e to 5370e9f Compare November 1, 2026 04:09
@zackees
zackees marked this pull request as ready for review November 1, 2026 04:09
@zackees
zackees enabled auto-merge November 1, 2026 04:09
@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into master with commit 0664d36 Nov 1, 2026
40 checks passed
@zackees
zackees deleted the build/3265-rust-module-cache branch November 1, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant