Repository navigation
Description
Summary
Proposal: an obs-rust/obs-studio-libs cache of prebuilt native libraries, modelled on zackees/soldr-toolchain, to fix CUDA/NVENC breakage across glibc versions and CUDA link layouts.
Recommendation: modified yes.
- Do not put CUDA or NVIDIA libraries in the cache. OBS never links or ships the CUDA runtime.
plugins/obs-nvenc/cuda-helpers.c:19-21dlopens only the driver API (libcuda.so.1/nvcuda.dll) and resolves_v2symbols by name.plugins/obs-nvenc/nvenc-helpers.c:105-109andplugins/obs-ffmpeg/obs-ffmpeg.c:262-268do the same forlibnvidia-encode.so.1/nvEncodeAPI64.dll. These are user-mode driver libraries. They have to match the host kernel module, and NVIDIA's license does not allow redistributing them.libcudartis not involved. The one real breakage, bug: build-aux: NVENC can't load from the Linux AppImage, so NVIDIA users get no GPU encoding #498, was the AppImage's bundled glibc 2.43 meeting a hostlibcudathat needed glibc private symbols. That is a glibc-closure problem, and it is now handled by bundling all of glibc (build-aux/appimage/assemble-appdir.sh:111-130). - Do build the Rust CUDA/NVENC loader (crate
obs-nvenc, below). It replaces the hard-coded single soname with an ordered candidate search, returns typed and diagnosable errors (includingGLIBC_x.y not found), and is unit-testable without a GPU. - Create
obs-studio-libslater, and only for build-time third-party dependencies that the Linux packages build or install today (FFmpeg built with nv-codec-headers, x264, libvpl, librist, srt, libdatachannel, and so on; see theaptlist in.github/workflows/appimage.yaml:122). Each is built once against a manylinux_2_28 (glibc 2.28) baseline and described with zackees/manifest.json. The goal is reproducible packages that stop depending on the build host's glibc. It also opens a later path where the AppImage no longer bundles glibc at all (which bug: build-aux: NVENC can't load from the Linux AppImage, so NVIDIA users get no GPU encoding #498 shows is fragile). Start this only after a measurement shows it pays off in CI time (see infra: CI: PR runs spend most of their time on per-run setup #427). It is not the CUDA fix.
Prior art studied
- zackees/soldr-toolchain. Code is on
main. Data lives on an orphanassetsbranch: a top-levelmanifest.jsonindex, a per-tool<tool>/manifest.json, and LFS blobs at<tool>/<version>/<platform>/<file>, with ABI variants as sibling files. A nightly job onmainrefreshes the catalogue, and consumers read it fromraw.githubusercontent.com(CDN, no API rate limit). Immutablesha256/<digest>/...copies stop a CDN from pairing a new catalogue with a stale blob. Catalogue schemas areschemas/catalogue.v{1,2}.schema.json. - zackees/manifest.json. The data model is Index → Catalog → Release → EmbeddedSlice. Every cross-document link is an OCI descriptor
{url, sha256, size_bytes}. Consumers askresolve(tool, platform, channel, variant?), wherePlatform{os, arch, os_version, libc, abi, features[]}matches field by field and a missing field is a wildcard. An asset has eitherurls[]or multipartparts[]. The project also provides amanifest-resolveCLI, and anEmbeddedSlicecan be pulled in withinclude_str!so resolving needs no network. The glibc baseline maps tolibc: "glibc"plusos_version: "2.28", read as the minimum. - zackees/transcribe-anything. It does not use a prebuilt-libs cache or a dlopen abstraction. It relies on vendor-built manylinux wheels (PyTorch cu128 plus the
nvidia-*wheels, which bundle cudart, cublas and cudnn) in an isolated uv env, and takes only the driver (libcuda.so.1) from the host. On top of that it adds diagnostics:cuda_available.pycompares the driver's CUDA version with the wheel's (driver too old leads to an error, and host CUDA libraries onLD_LIBRARY_PATHleads to a warning).check_linux_shared_libraries.pyprobes sonames withctypes.CDLL, andutil.pycaches GPU detection. The lesson for OBS: bundle the runtime libraries, never the driver, and give clear diagnostics when the driver does not match. OBS has no runtime libraries to bundle, so only the diagnostics part carries over. - cudarc (
dynamic-loadingfeature) is not adopted. It uses libloading over a candidate list, but it covers the CUDA runtime and math libraries and much more API than the 15 or so driver functions OBS needs. In the versions checked it panics or lazily aborts when the library is missing, while OBS must degrade to "NVENC not supported".libloadingis used directly.
Design: crate obs-nvenc
Name per docs/rust-port/naming.md: an obs-<area> port named after the directory it ports (plugins/obs-nvenc). Path: rust/obs-nvenc/. It is an rlib re-exported through libobs-rust only when a C shim is added, which is out of scope here (see below).
// src/lib.rs (safe; #![deny(unsafe_code)])
pub enum Library { CudaDriver, NvEncode, Nvml }
pub struct Candidate { pub name: std::ffi::OsString, pub source: CandidateSource }
pub enum CandidateSource { EnvOverride, SonameDefault, SonameUnversioned, DistroPath, WslPath }
pub fn candidates(lib: Library, env: &dyn Env) -> Vec<Candidate>; // pure, host-neutral data from platform::
pub struct CudaDriver { /* fn table */ }
impl CudaDriver {
pub fn load() -> Result<Self, LoadError>; // walks candidates, first success wins
pub fn load_from(cands: &[Candidate], dl: &dyn DynLoader) -> Result<Self, LoadError>; // test seam
pub fn driver_version(&self) -> Result<CudaVersion, CudaError>; // cuDriverGetVersion
}
#[non_exhaustive]
pub enum LoadError {
NotFound { tried: Vec<(Candidate, String /*dlerror*/)> },
GlibcMismatch { candidate: Candidate, required: String }, // parsed from "version `GLIBC_2.44' not found"
MissingSymbol { library: Library, symbol: &'static str }, // e.g. cuCtxCreate_v2
DriverTooOld { found: CudaVersion, need: CudaVersion },
}
pub trait DynLoader { fn open(&self, c: &Candidate) -> Result<Box<dyn DynLib>, String>; }Fallback order (Linux): OBS_CUDA_LIBRARY / OBS_NVENC_LIBRARY env override, then libcuda.so.1, then libcuda.so (dev symlink, last resort), then the multiarch distro paths (/usr/lib/x86_64-linux-gnu, /usr/lib64, /usr/lib/nvidia, /run/opengl-driver/lib on NixOS), then WSL /usr/lib/wsl/lib. libnvidia-encode.so.1 follows the same pattern. Windows: nvcuda.dll, then nvEncodeAPI64.dll / nvEncodeAPI.dll, loaded only from System32 (LOAD_LIBRARY_SEARCH_SYSTEM32, no CWD hijack). macOS: an empty list, returning NotFound immediately.
Symbol resolution: the _v2 names exactly as in cuda-helpers.c. A missing required symbol returns MissingSymbol, while a missing optional symbol leaves None.
Platform boundary: soname lists, search paths, the WSL/NixOS probes and the Windows LoadLibraryExW flags live in src/platform/{unix,windows,macos}.rs, chosen by a single cfg_select! in src/platform/mod.rs that re-exports fn default_candidates(Library) -> Vec<Candidate> and struct SystemLoader: DynLoader. unsafe (the libloading open and symbol transmute) is allowed only in src/platform/ (with a module-level allow and a reason, as in obs_util::platform::windows) and in src/ffi/. Each block has a // SAFETY: comment. dylints/ban_platform_cfg_outside_boundary must pass with no allowlist.
Errors map onto today's C log strings so users and log scrapers see the same text: NotFound produces [NVENC] Test process failed: cuda_lib, plus the list of what was tried and why.
obs-studio-libs design (phase 2, after the measurement)
-
Repo
obs-rust/obs-studio-libs, laid out like soldr-toolchain: build recipes and tests onmain, catalogue plus blobs on an orphanassetsbranch, with<lib>/<version>/<os>-<arch>/<lib>-<version>-<os>-<arch>-<libc><ver>.tar.zst. Large blobs are GitHub Release assets withparts[]multipart where they exceed 2 GB; the catalogue is served from raw.githubusercontent.com. -
Manifest: zackees/manifest.json
Catalogper library, with no new schema. The platform keys are:{os:"linux", arch:"x86_64"|"aarch64", libc:"glibc", os_version:"2.28"}(manylinux_2_28, built inquay.io/pypa/manylinux_2_28_*){os:"windows", arch:"x86_64", libc:"msvc"}{os:"darwin", arch:"arm64"|"x86_64", os_version:"11.0"}
The variant
flavorholds build options, for exampleffmpeg flavor:"nvenc". Channel islatest-stableplus exact versions. -
Contents: only redistributable third-party build dependencies with SBOM and licence files. Never the NVIDIA driver libraries, the CUDA runtime or the Qt commercial bits.
-
Consumers: CMake
FetchContentor a pre-configure script resolves through a checked-inEmbeddedSliceper lane (sha-pinned, so no network resolution), verifies sha256, and extracts into.deps/. CI uses existing workflows only (no new workflow file in obs-studio). The producer workflow lives in the new repo and needs separate sign-off when that repo is created.
Test plan (testing-policy tiers)
- Tier 1 (Rust,
rust/obs-nvenc/tests/):candidates()order for eachLibrarywith and without the env override, using a fakeEnv.load_fromwith a fakeDynLoader: the first candidate fails and the second succeeds; all fail givesNotFoundlisting every dlerror; dlerrorversion 'GLIBC_2.44' not foundgivesGlibcMismatch{required:"GLIBC_2.44"}; a missingcuCtxCreate_v2givesMissingSymbol;cuDriverGetVersion11080 against a need of 12000 givesDriverTooOld. These run on every OS with no GPU. - Tier 2: none yet, because no C symbol is replaced in this issue. When a later issue ports
load_cuda_lib/init_cudabehindENABLE_RUST_LIBOBS, the unchanged C test and plugin load must pass with the option ON and OFF. - Tier 3: a differential test of the candidate outcome against the original C.
cuda-helpers.cis compiled intoobs-c-oraclewith theoracle_prefix andos_dlopenstubbed to record names, which asserts that the Rust search order starts with the exact name C tries (libcuda.so.1/nvcuda.dll), so there is no regression on the default path. The mutation check is required and must be stated in the PR. - Tier 4: not applicable (no network surface).
- Packaging (AGENTS.md rule): phase 2 changes what ships.
build-aux/appimage/test-appimage.shmust gain a lane that runs the AppImage on a container with a newer glibc than the bundle and asserts thatobs-nvenceither loads or logs the typedGlibcMismatch/NotFoundreason, with a saved profile that uses NVENC. Show it failing without the change.
Acceptance criteria
-
rust/obs-nvencexists, is named per naming.md, passesci/test_naming.py, and./lint(clippy, fmt, dylints) is clean with no platform-boundary allowlist. - RED commit (Tier 1 against
todo!()stubs,soldr cargo testfailing), then GREEN. - Tier 1 covers every
LoadErrorvariant and the fallback order on Linux, Windows and macOS lists. It runs in the existingrust-testsjob on all three OSes. - Tier 3 parity with
cuda-helpers.c/nvenc-helpers.cdefault names, with the mutation check recorded in the PR. - No C header, C test or plugin C file is changed. No new workflow file is added.
- A decision comment on this issue records whether phase 2 (
obs-studio-libs) goes ahead, based on measured CI minutes spent on dependency setup (infra: CI: PR runs spend most of their time on per-run setup #427 data).
Implementation checklist
- Claim per coordination.md and branch
port/obs-nvenc-loader. - Add
rust/obs-nvenc/{Cargo.toml,src/lib.rs,src/error.rs,src/candidates.rs,src/platform/{mod.rs,unix.rs,windows.rs,macos.rs}}, add it to the workspace, and addlibloadingas a workspace dependency (exact pin). - RED:
tests/loader.rswith the fakeEnv/DynLoadercases listed above, againsttodo!(). - GREEN: candidate lists (platform),
load_fromwalk, dlerror parsing forGLIBC_(pure function in the safe core, which only parses strings), and the symbol table that mirrorscuda_functions[]incuda-helpers.c(same_v2names). -
SystemLoaderinplatform/unix.rsandplatform/windows.rsvia libloading (Windows withLOAD_LIBRARY_SEARCH_SYSTEM32), with// SAFETY:comments. - Tier 3:
rust/obs-c-oracle/oracle/cuda_helpers.cwrapper plus a recordingos_dlopenstub, andtests/loader_parity.rs. - Opt-in smoke test
#[ignore]real_gpu_loadsthat callsCudaDriver::load()and prints the driver version, for maintainers with NVIDIA hardware. - Run
./lint,./unittestand the local-gate stamp, then open a PR withRefs #<this>. - Follow-up issues (file them, don't do them here): (a) C shim plus
ENABLE_RUST_LIBOBSswap forload_cuda_lib/init_cuda; (b) phase 2obs-studio-libsonce the measurement supports it, which also needs sign-off for the producer workflow in the new repo.
Refs #498 (the original glibc/libcuda breakage), #427 (CI setup time).
Written with Claude Code (Claude Opus 5.5).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Oct 13, 2026
Claiming: phase 1 (the
rust/obs-nvencloader crate).port/obs-nvenc-loaderfrom master; addrust/obs-nvenc(candidates, error types, platform loaders via libloading).tests/loader.rsagainsttodo!()stubs.load_fromwalk, GLIBC dlerror parsing,cuda_functions[]symbol table.obs-c-oracle/oracle/cuda_helpers.c+ nvenc name parity, with mutation check in the PR.Phase 2 (obs-studio-libs) and the C shim are not part of this claim. First PR expected today.
Merge pull request #529 from obs-rust/port/obs-nvenc-loader
zackees commentedon Oct 13, 2026
Phase 2 go/no-go recorded on #525: no-go for now. Windows and macOS already use prebuilt obs-deps (~10–18 s), and every Flatpak dependency module is already cached. Ubuntu spends ~52 s in apt, of which an FFmpeg/x264 cache would save at most ~20–30 s. Measurements and the revisit trigger are in #525.
rust: obs-nvenc loader RED: Tier 1 tests against todo!() stubs (obs-r…
rust: obs-nvenc loader GREEN: candidate search, typed errors, cuda_fu…
rust: obs-nvenc Tier 3 parity with cuda-helpers.c / nvenc-helpers.c (o…
github-actions commentedon Oct 15, 2026
Claim bot: claim expired: no progress from @zackees in 48 h. Anyone may claim it now.
vpacher commentedon Oct 16, 2026
Not claiming: phase 1 is complete as far as I can see. #529 (loader, RED/GREEN, Tier 3 with mutation check), #592 (C shim swap, fixes #524) and #646 (Tier 2 coverage) are merged, and the phase 2 decision is recorded on #525 (no-go for now). The claim bot expiry above refers to finished work.
One more data point for
real_gpu_loads, which so far ran only on NixOS (DistroPath):soldr cargo test -p obs-nvenc --release --test loader -- --ignored real_gpu_loads --nocaptureloaded Candidate { name: "libcuda.so.1", source: SonameDefault },driver version 13.2, test passes.So the default soname path works on a standard FHS distribution too. On the same host, NVENC h264 recording worked with the fork build of 2026-10-15 (aaed86f,
ENABLE_RUST_LIBOBS=ON); not yet re-checked on 4f270ee.If nothing else is pending, this issue can perhaps be closed.
zackees commentedon Oct 16, 2026
@vpacher thank you, and for the Debian 13 / RTX 3060
real_gpu_loadsresult.I checked it against the merged work: phase 1 is done. #529 (loader crate, RED then GREEN, Tier 3 parity with the mutation check), #592 (C shim swap, closed #524) and #646 (Tier 2 harness with
ENABLE_RUST_LIBOBSOFF and ON) are merged. Phase 2 (obs-studio-libs) was decided no-go for now, with the measurements and the trigger to revisit recorded on #525, which stays open for that. Closing this issue as complete.