Skip to content

build: Always build libobs-with-rust beside the C libobs; link and ship the C one (#1065) - #1086

Merged
zackees merged 11 commits into
masterfrom
infra/1065-always-build-rust
Oct 16, 2026
Merged

zackees merged 11 commits into
masterfrom
infra/1065-always-build-rust

Conversation

@zackees

@zackees zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Fixes #1065.

What

One configure, both libobs builds

  • libobs-objects (OBJECT) compiles every unported source once.
  • libobs = the objects + the ported C. Everything links, installs and packages it.
  • libobs-with-rust = the objects + the libobs-rust staticlib + the C variadic halves.
    • It takes libobs's final file name and SONAME (libobs.so.30), copied after set_target_properties_obs.
    • It lands in <build>/libobs-with-rust/ and is never installed or linked.
    • It is built whenever cargo exists. The Flatpak sandbox has no cargo, so there it is skipped with a warning.
  • obs-nvenc keeps cuda-load.c. obs-nvenc-with-rust is the never-installed twin with the Rust loader.
  • ENABLE_RUST_LIBOBS no longer picks a libobs. It only names the app OBS-Studio-Rust.
    • The release scripts that pass it keep their identity and now ship the C libobs.
    • The daily beta's release notes say so.

Tier 2: one build, the unchanged C tests against each libobs

  • Linux:
    • LD_LIBRARY_PATH loads the twin.
    • One tree goes to the CI shards (tier2-tree).
    • Checks: SONAME match, identical exports, ported objects (all in libobs, none in the twin), both nvenc loaders, and a loader probe that a test really loads the expected libobs.
  • macOS: DYLD_FRAMEWORK_PATH loads the twin, checked with DYLD_PRINT_LIBRARIES.
  • Windows: PATH loads the twin. An obs.dll beside a test would shadow it, so that fails the run.

Docker harness: emulates forge-ci/bosn#666 via ci/docker-task.sh

  • One ephemeral container per checkout, named <task>-<checkout id>. The name is the singleton lock.
  • The checkout is mounted read-only (or as an overlay) and built out of source. There is no rsync copy.
  • Named volumes are reattached on every run. --clean / --clean-all reset them.
  • Each volume has a size budget.
  • After every run, cargo targets are pruned to the newest artifacts (soldr cache prune-target --keep-latest, on target/ and each target/<triple>). Incremental compilation stays on.
  • Images are tagged by content hash, and only the newest 3 are kept.
  • gc reclaims volumes whose checkout is gone.

Other changes

  • cmake/cross/docker.sh runs the cross-compile check the same way. The host needs only Docker.
  • The Windows toolchain now names a resource compiler, which CMake 4.2 requires.
  • A root .dockerignore lets bosn run --task appimage build again. It was refused before: the whole checkout was over bosn's 64 MiB context cap.
  • Host (no Docker) Tier 2: shell.nix gains PipeWire, WirePlumber, pactl, xvfb-run and VLC, and OBS_TIER2_KEEP_PATH=1 keeps the Nix shell's PATH.

RED

295fdde4a. These tests fail against the old layout:

  • ffi.rs: the nvenc C loader plus a Rust twin.
  • test_tier2_fanout.py: one tier2 tree.
  • test_tier2_run.py: a read-only source with no rsync.

Verified locally

Linux Tier 2 in Docker, one build from the read-only mount

  • Both libraries have SONAME libobs.so.30, and their exports are IDENTICAL (1766).
  • 258/258 tests pass against libobs.
  • Against libobs-with-rust, every test passed up to test 246, when the Docker daemon restarted (an external restart).

Linux Tier 2 natively on NixOS

Full product built and launched on the host

  • The OBS frontend and all plugins started and loaded 17 modules.
  • A clean SIGINT shutdown reported Number of memory leaks: 0.

docker-task.sh against real Docker

  • Smoke test passes 11/11: removal, reattach, --clean, overlay, singleton, --wait, and gc.
  • Cargo prune on a two-feature cross build: 2 rlibs → 1, and the next build takes 0.04 s.

cmake/cross/docker.sh

  • A fresh container downloads soldr, provisions LLVM and the Apple SDK, and compiles libobs for mac-arm64 103/103.
  • A warm rerun takes 4–5 s.

@zackees
zackees enabled auto-merge October 16, 2026 13:11
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Fast Gate's lint lane failed only on rustfmt in rust/obs-nvenc/tests/ffi.rs:180. I pushed a8c8c52 with soldr cargo fmt -p obs-nvenc. No other change; cargo fmt --all --check passes.

)

- rust/obs-nvenc/tests/ffi.rs: obs-nvenc keeps cuda-load.c and an
  obs-nvenc-with-rust twin builds cuda-load-rust.c with the staticlib
  (fails: the plugin still swaps loaders on ENABLE_RUST_LIBOBS).
- ci/test_tier2_fanout.py: the Tier 2 build job uploads one tree
  (tier2-tree) and every mode x shard job tests it (fails: one tree per
  ENABLE_RUST_LIBOBS mode).
- ci/test_tier2_run.py: the Docker harness builds out of source from the
  read-only checkout, with no rsync copy, and keeps crate downloads on
  shared volumes (fails: it rsyncs into /src).

Refs #1065
…ip the C one (#1065)

One configure builds two libobs binaries from one compile of the shared
code: libobs-objects (OBJECT) holds every unported source and the usage
requirements; libobs adds the ported C (LIBOBS_PORTED_SOURCES and the
host's, libobs/cmake/sources.cmake) and is what everything links,
installs and packages; libobs-with-rust adds the Rust ports (the
libobs-rust staticlib, cmake/rust.cmake) and the C variadic halves, takes
libobs's final file name and SONAME after set_target_properties_obs, and
lands in <build>/libobs-with-rust, never installed or linked. It is built
whenever cargo is found (the Flatpak sandbox has none). libobs-version and
libobs-core-modules are linked into each shared library directly (CMake
does not carry object libraries' objects through another), and Windows'
OBS::obfuscate is link-only on the objects so its interface source is
compiled once. obs-nvenc keeps cuda-load.c; obs-nvenc-with-rust is the
never-installed twin with cuda-load-rust.c and the obs-nvenc-plugin
staticlib.

ENABLE_RUST_LIBOBS no longer picks a libobs: it only names the app
OBS-Studio-Rust (identity, paths, version), so the release scripts that
pass it keep their identity and now ship the C libobs. The daily beta's
release notes say so.

Tier 2 builds once and runs the unchanged C tests against each libobs:
- Linux (validate.sh): mode OFF as linked, mode ON with LD_LIBRARY_PATH
  pointing at libobs-with-rust; one tree is packed for the CI shards
  (tier2-tree); checks the SONAME match, identical exports, the ported
  objects (all in libobs, none in the twin), both nvenc loaders, and that
  a test binary really loads the expected libobs.
- macOS: DYLD_FRAMEWORK_PATH picks the framework, checked with
  DYLD_PRINT_LIBRARIES. Windows: PATH picks obs.dll; an obs.dll beside a
  test would shadow it, so that fails.
- The Docker harness builds out of source from the read-only checkout
  (no rsync copy; -DOBS_BUILD_NUMBER keeps CMake from writing the build
  number into it), keeps crate downloads on shared volumes, links with
  RUNPATH, and resets a build tree configured from another source path.
- sanitize.sh: RUST_LIBOBS=ON runs the tests and the app against the twin.

Local: Tier 2 Linux from the read-only mount, one build: SONAME
libobs.so.30 for both, exports IDENTICAL (1766), 258/258 against libobs;
against libobs-with-rust the run reached test 246 (all passing) when the
Docker daemon restarted, rerun pending.

Fixes #1065
bosn's manifest Dockerfile builds take the whole checkout as the build
context and refuse one over 64 MiB ("manifest Dockerfile context was
refused"); with no .dockerignore that included target/ (22 GB), .git and
build trees, so bosn run --task appimage never started. The root file
admits only what build-aux/appimage/Dockerfile and
build-aux/appimage/manylinux/Dockerfile COPY. Verified: bosn manifest
ensure succeeds for both stacks (appimage, appimage-228).
forge-ci/bosn#657 asks bosn for a default ignore set and a precise error.
… volumes (forge-ci/bosn#666)

ci/docker-task.sh emulates bosn#666 until bosn does it itself:
- run: an ephemeral container named <task>-<checkout id> (--rm), one at a
  time per checkout: a running one refuses the run (exit 75) or --wait
  waits on it (docker wait); a stopped leftover is removed. Per-checkout
  (stack) and shared (machine) named volumes, labelled with task, scope
  and checkout path, are reattached every run; --clean / --clean-all drop
  them first. The source is ro, rw or overlay (a read-only checkout under
  a throwaway upper layer). Images are tagged by content hash and capped
  at the newest three per task.
- gc: lists (with --apply removes) stack volumes whose labelled checkout
  is gone, stopped task containers and images beyond three; unlabelled
  legacy volumes only with --apply-legacy, never this checkout's or one in
  use.

rust/tools/linux-validate/run.sh runs Tier 2 through it (same volume names,
so warm builds carry over) and gains --clean, --clean-all and --wait.
cmake/cross/docker.sh runs the cross-compile check the same way: the
checkout as an overlay at /src; /build per checkout; soldr's root and the
prebuilt deps on shared volumes, so the host needs only Docker.

Host (no Docker) Tier 2: rust/tools/sanitize/shell.nix gains what the cmocka
tests start (xvfb-run, PipeWire, WirePlumber, pactl, VLC), and
OBS_TIER2_KEEP_PATH=1 keeps the Nix shell's PATH (NixOS's envfs /usr/bin
cmake can't find its modules).

Verified against Docker: the smoke test (container removed, volume
reattached, --clean, overlay writes discarded and the host untouched,
concurrent run refused, --wait) passes 11/11 and gc cleans up after it; a
cold cmake/cross mac-arm64 in a fresh container downloads soldr,
provisions LLVM and the Apple SDK, and compiles libobs 103/103; the warm
rerun takes 4 s (no downloads, ninja: no work to do), no container left.

Refs #1065
Volumes that only ever grow (cargo targets, compiler caches, soldr's
root) are now bounded two ways:
- docker-task.sh --budget VOL=SIZE: after every run (failed ones too), a
  volume over its budget is removed and the next run starts it cold. Tier 2:
  build 8G, ccache 3G, crates 2G each; cross: build 6G, soldr 12G, deps 2G.
- docker-task.sh --prune-cargo DIR: after every run, in the same container,
  soldr cache prune-target --keep-latest on DIR and each DIR/<triple>
  (soldr only scans the top-level profiles). Safe here because each target
  is built one way. soldr comes from a shared docker-task-soldr-<version>
  volume, fetched once at the version and SHA256 cmake/common/soldr.cmake
  pins. Tier 2 prunes Corrosion's /build/tree{,-debug}/cargo/build.
- CARGO_INCREMENTAL=0 in both tasks: no incremental caches in one-shot
  builds.

One image and one target dir serve every platform: cargo keeps each
target in target/<triple>/<profile>, sharing host build scripts and
proc-macros.

Verified against Docker: a crate built for x86_64-unknown-linux-gnu with
two feature sets leaves two rlibs; the pruned run keeps one (60.1 KB
reclaimed) and the next build finishes in 0.04 s, nothing rebuilt.

Refs #1065
Incremental rebuilds are the fast path for the crates being edited. The
keep-latest prune after every run keeps each crate's newest incremental
data and drops superseded copies, and the volume budget stays the hard
ceiling, so CARGO_INCREMENTAL=0 isn't needed to bound the volume.

Refs #1065
…ss aliases

- CMake 4.2's Windows-Clang platform requires CMAKE_RC_COMPILER; soldr's
  LLVM has no llvm-rc and the check compiles no .rc, so the generated
  toolchain names an existing program.
- cmake/cross regenerates its toolchain when soldr.cmake or the alias
  changes, so a fix reaches existing build trees.
- cmake/cross/docker.sh downloads soldr once per version into the shared
  soldr volume instead of into every alias's build tree.

Refs #1065
…ibobs-with-rust

- test_tier2_native: the source root is /ro; git's safe.directory is set
  unconditionally before the first git command.
- test_tier2_env: every ctest line runs with mode_env, built from
  test_env (mode ON adds LD_LIBRARY_PATH for the Rust twin).
- test_rust_macos_sdk: the fixture defines libobs-with-rust, the target
  rust.cmake now configures.
- cmake/cross: the alias also comes from OBS_CROSS_TARGET in the
  environment, because CMake drops -D options when a toolchain change
  resets the cache; docker.sh sets it per alias.

Refs #1065
…ustfmt

- docker-task.sh: volume budgets are measured at most once an hour per
  volume (DOCKER_TASK_BUDGET_SECS), concurrently when due, and the overlay
  cleanup runs in the background. A warm cmake/cross/docker.sh run goes
  from 8-11 s to 2-6 s (a bare docker run is 1.3-2.8 s on the same host).
- soldr.cmake writes the generated toolchain only when its content
  changes (COPY_FILE ONLY_IF_DIFFERENT): rewriting it unchanged kept CMake
  resetting an existing tree's cache, 263 reconfigures in a row. The old
  win-x64 tree now configures once and compiles libobs 105/105 in 16 s.
- rustfmt rust/obs-nvenc/tests/ffi.rs.

Local: ./lint (lane lint) ok; ci/ 516 tests ok.

Refs #1065
libobs has no OUTPUT_NAME on macOS (the file name is the target name), so
the property copy left the twin as libobs-with-rust.framework and Tier 2
could not find it.
@zackees
zackees force-pushed the infra/1065-always-build-rust branch from cd6c120 to c68ca2f Compare October 16, 2026 13:49
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit f91bb18 Oct 16, 2026
31 checks passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 17, 2026
… C libobs (obs-rust#1253)

* release-rust: Look for Rust code in libobs-with-rust, not the shipped C libobs

Since obs-rust#1086 (obs-rust#1065) the package ships the C libobs and the Rust ports are
linked into its never-installed twin. The beta still required Rust in the
packaged obs.dll / libobs.framework, so the 2026-10-17 daily beta
(run 39034168041) failed on Windows and macOS: 'no Rust code in ...'.
Check the twin the build made instead.

Refs obs-rust#926

* release-rust: Keep the collector's end marker for its test
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 17, 2026
…rust#1255)

* release-rust: Look for Rust code in libobs-with-rust, not the shipped C libobs

Since obs-rust#1086 (obs-rust#1065) the package ships the C libobs and the Rust ports are
linked into its never-installed twin. The beta still required Rust in the
packaged obs.dll / libobs.framework, so the 2026-10-17 daily beta
(run 39034168041) failed on Windows and macOS: 'no Rust code in ...'.
Check the twin the build made instead.

Refs obs-rust#926

* release-rust: Keep the collector's end marker for its test

* build: macOS OBS-Studio-Rust builds also build libobs-with-rust

xcodebuild -target obs-studio leaves out the never-installed Rust-linked
twin, so the beta's 'Rust is linked' check found no libobs-with-rust on
macOS (verify run 39042455015). Build it as a second target.
@zackees
zackees deleted the infra/1065-always-build-rust branch October 26, 2026 15:44
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.

build: Always compile the Rust ports; link them into a test-only libobs, package the C libobs

1 participant