Skip to content

build(cross): link libobs and the platform plugins on Linux (win-x64, mac-arm64, mac-x64) #3059

Closed

Description

@zackees

Follow-up to #697. The cross check (cmake/cross, #1075) compiles the whole C/C++ tree for win-x64, mac-arm64 and mac-x64 on Linux but links nothing, so link errors stay on the native runners. The reason it links nothing was soldr, not the platform: cmake/common/soldr.cmake located the cross compiler and SDK by hand "until soldr has soldr cc --target <triple> --print-cc / --print-sysroot" (soldr#2335). soldr 0.9.45 has that, and on this host a PE executable, a PE DLL, a Mach-O executable and a Mach-O dylib all link from Linux:

Probe x86_64-pc-windows-msvc aarch64-apple-darwin
--print-linker clang driver → lld-link clang driver → ld64.lld
--print-sysroot xwin MSVC CRT + Windows SDK (2026-06-22) Apple SDK 14.5
--print-ar / --print-rc llvm-lib / llvm-rc llvm-ar
C executable linked, 9.7 KB linked, 50 KB
shared library linked, 8 KB linked, 17 KB

What to build

  1. Switch cmake/common/soldr.cmake to the supported interface — soldr cc --target <triple> --print-cc/--print-cxx/--print-linker/--print-sysroot/--print-ar/--print-rc instead of _obs_soldr_locate()'s layout guessing, with a ci/test_*.py pinning that no layout path remains. The # TODO(soldr cc --target) comment goes with it.
  2. Link in the cross check: add an opt-in OBS_CROSS_LINK that links a shared libobs (and the platform plugins that are shared libraries, e.g. obs-ffmpeg, win-capture, mac-virtualcam) for each alias, against the prebuilt .deps import libraries the native build uses.
  3. Measure a cold Linux build (no zccache, no unity cache) per alias, and compare with the native Build OBS-Studio-Rust steps: Windows x64 12m25, macOS arm64 8m01, macOS x86_64 7m50 (release run 41007587429).

Acceptance

  • cmake -S cmake/cross -DOBS_CROSS_TARGET=win-x64 -DOBS_CROSS_LINK=ON produces a libobs DLL (and mac-arm64 / mac-x64 produce a dylib) with no native runner involved.
  • The alias list and its documented limits are unchanged: no win-arm64 (MSVC ARM64 __ldar*/__stlr* intrinsics in libobs/util/threading-windows.h, which clang does not provide).
  • A cold-build number per alias is recorded next to the native ones, so the per-job move issues (build: Investigate cross-compiling the full OBS C/C++ build for Windows and macOS from Linux #697's remaining work) can be sized from measurement.

Out of scope

Refs #697, #700, #1075, #695, #930.

Activity

  1. added
    infra
    on Oct 30, 2026
  2. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    /ready

    Triage: meets Ready. The prerequisite (soldr 0.9.45 with soldr cc --target --print-*) merged in #3042. Acceptance is concrete: a libobs DLL/dylib per alias with no native runner, the alias list unchanged, and cold-build numbers recorded. The failing-test sketch is the ci/test_*.py that pins no layout-guessing path. Scope excludes signing and packaging. P2 (moves link errors off the native runners; sizes #697), size:L.

  3. added
    ready
    P2
    size:L
    on Oct 30, 2026
  4. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Claiming: #3059

    1. RED: a ci/test_*.py pin that the cross toolchain comes from soldr cc --target <triple> --print-cc/--print-cxx/--print-linker/--print-sysroot/--print-ar/--print-rc and that no layout-guessing path (_obs_soldr_locate) remains in cmake/common/soldr.cmake.
    2. GREEN: rewrite obs_soldr_cross_toolchain() onto that interface; drop the stale # TODO(soldr cc --target) note.
    3. Then add opt-in OBS_CROSS_LINK to cmake/cross and link a shared libobs per alias against the prebuilt .deps import libraries; record a cold per-alias build number next to the native ones.

    First PR within a day. Refs #697.

  5. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Progress: PR #3091 (queued) replaces the layout-guessing toolchain discovery with soldr cc --target <triple> --print-*. Evidence in the PR: the real cross tree configured and built on this host for all three aliases (win-x64 200 objects, mac-arm64 171, mac-x64 241 targets), and ci/test_soldr_cross_toolchain.py pins the supported interface.

    Left on this issue: the opt-in OBS_CROSS_LINK (shared libobs plus the shared platform plugins per alias, against the prebuilt .deps import libraries) and the cold per-alias build numbers next to the native ones. That is the next PR, on top of #3091.

  6. moved this from Ready to In progress in obs-rust Multiviewon Oct 30, 2026
  7. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Tick progress (obs-studio5), branch infra/3059-cross-link (WIP, not a PR yet): the second half — an opt-in link — is started and hits three concrete blockers that are findings in their own right.

    What is on the branch

    OBS_CROSS_LINK in cmake/cross/CMakeLists.txt (default OFF, so the lane is unchanged): when ON it builds a shared libobs for the alias from the same object set the shipped Rust build links (LIBOBS_SOURCES + the host's _SOURCES + LIBOBS_RUST_SOURCES), against the prebuilt .deps import libraries and the alias's OS libraries. win-x64 first.

    Default-OFF regression check: a fresh default configure+build of build_cross_win-x64 is green with the same 991 warnings as before the change.

    Three blockers found by trying to link

    1. The cross tree compiles two source sets that collide at link time. It compiles the C-reference ported lists and the Rust halves (cmake/cross/CMakeLists.txt header comment says so), and libobs.ported-util+.h.c and libobs.rust-variadic+.h.c both define blogva, blog, dstr_printf, … Linking both gave lld-link: duplicate symbol: blogva. The link set has to be the Rust build's (LIBOBS_SOURCES + host sources + LIBOBS_RUST_SOURCES); the ported C set stays compiled but not linked.
    2. w32-pthreads is a separate DLL in the native build. deps/w32-pthreads/CMakeLists.txt:3 is add_library(w32-pthreads SHARED …), so compiling pthread.c into libobs duplicates its DllMain. As its own SHARED target it links cleanly: w32-pthreads.dll 55 KB + w32-pthreads.lib 30 KB from Linux.
    3. The Linux-side xwin SDK has no debug CRT. It ships msvcrt.lib but not msvcrtd.lib, while cmake/cross defaults to CMAKE_BUILD_TYPE=Debug, so the link died on could not open 'msvcrtd.lib'. The option now forces Release when the type is empty/Debug (before project()). The SDK's import libraries are also lower case on Linux (avrt.lib, not Avrt.lib), so libobs/cmake/os-windows.cmake's names have to be lower-cased in the cross link only.

    What is left

    The obs.dll link now fails only on ≥20 undefined Rust shims (bfree, bmalloc, bmemdup, obs_data_array_*, obs_hotkey_*, calldata_set_data, signal_handler_signal, obs_service_get_weak_service, …; lld-link hit its error limit). That is the expected shape: the ported halves are Rust in production (libobs/cmake/sources.cmake:10-13), so a real libobs DLL needs the libobs-rust staticlib. A cold soldr cargo build -p libobs-rust --release --target x86_64-pc-windows-msvc did not finish within this tick's ~9.5 min (every workspace crate MISSed the cache); wiring that archive into the link target and measuring it is the next slice. The claim stays with me for it.

    Refs #697.

  8. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Progress (obs-studio5, PR #3123): the opt-in link half is now green for all three aliases.

    • win-x64 → obs.dll (PE32+ AMD64, 1,171,968 B, 1,795 exports, all 824 Rust shims named via /EXPORT)
    • mac-arm64 → obs.dylib (Mach-O arm64, 3,994,096 B, 5,951 exports)
    • mac-x64 → obs.dylib (Mach-O x86_64, 4,013,528 B, 5,989 exports)
    • Default (OBS_CROSS_LINK=OFF) configure+build is unchanged: green, 991 warnings.
    • ci/test_soldr_cross_toolchain.py pins the lane as opt-in, the production libobs-rust staticlib per alias, and the Windows export list.

    The link set is the shipped hybrid's, plus libobs-rust, deps/libcaption, the generated version/core-module objects and OBS::obfuscate on Windows. The PR catalogs the RED failures it had to clear (duplicate blogva, undefined Rust shims, xwin MSVCRT.lib case, _mm_set_ps declared-extern).

    Left on this issue: the cold-build number per alias (no zccache, no unity cache) next to the native step times, plus the size comparison for #697. Claim stays with me for that slice.

  9. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Tick progress (obs-studio5): the last acceptance item — the cold per-alias number — is measured and recorded in #3126 (docs-only, unmerged; docs/ci-tooling.md gains one Cost, measured bullet beside the cross-check section).

    How it was measured: fresh build tree per sample, -DOBS_CROSS_LINK=ON (so the run builds that alias's libobs-rust staticlib and links the DLL/dylib), -j 4 to match the 4-vCPU runner class, and ZCCACHE_DISABLE=1. The bypass is confirmed rather than assumed: soldr logs no-cache preflight prepared …/target and the zccache directory stayed at 4 KB across all six builds.

    alias sample 1 sample 2 artifact
    win-x64 31.5 s 40.8 s obs.dll 1,646,080 B
    mac-arm64 117.0 s 31.8 s obs.dylib 3,994,096 B
    mac-x64 134.3 s 26.4 s obs.dylib 4,013,528 B

    What the spread is, and what it is not. The compile set is stable (189–262 Building C/CXX object edges per sample), so it is not a cache leaking through. The slower sample of each pair is the one whose cargo stage also rebuilt 14–18 workspace crates (4.9–10.1 s of cargo time); the rest tracks co-tenant load — four worker checkouts share this host, and a controlled win-x64 repeat with a fresh zccache directory on a busier box took 52.9 s. The number to plan with is therefore a 30–135 s range per alias, against the native steps in release run 41007587429 (Windows x64 12m25, macOS arm64 8m01, macOS x86_64 7m50): roughly 1/15 of the platform step, with signing and packaging staying native as the out-of-scope list says.

    State of #3059: all three acceptance items now have evidence — the toolchain comes from soldr cc --target … --print-* with ci/test_soldr_cross_toolchain.py pinning it (#3091), OBS_CROSS_LINK=ON produces obs.dll / obs.dylib per alias with no native runner (#3123), and the cold cost is the table above (#3126). What is left is the merge of #3126 and then closing this issue; I keep the claim until it lands.

    Refs #697

  10. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Closing: all three acceptance items are evidenced and merged.

    1. Toolchain from soldr cc — soldr cc --target <triple> --print-*> resolves the driver, lld-link/ld64.lld, the MSVC CRT + Windows SDK and the Apple SDK; ci/test_soldr_cross_toolchain.py pins it as opt-in (build(cross): resolve the cross toolchain through soldr cc --print-* (#3059) #3091).
    2. Link works with no native runner — OBS_CROSS_LINK=ON links obs.dll (PE32+ AMD64, 1,795 exports), and obs.dylib for mac-arm64 and mac-x64, from the same object set the shipped Rust build links; default OFF keeps the lane unchanged (build(cross): link a shared libobs per alias with OBS_CROSS_LINK (#3059) #3123).
    3. Cold per-alias cost, measured — fresh tree per sample, ZCCACHE_DISABLE=1 verified (soldr logged no-cache preflight, zccache dir stayed 4 KB): win-x64 31.5/40.8 s, mac-arm64 117.0/31.8 s, mac-x64 134.3/26.4 s; plan with a 30–135 s range per alias. Recorded in docs/ci-tooling.md (docs(ci): record the measured cold cross-build cost per alias (#3059) #3126, merged).

    Out of scope here and staying native: signing/notarization/hdiutil, and the win-arm64 alias (no cross alias exists — MSVC ARM64 __ldar*/__stlr* in libobs/util/threading-windows.h). cmake/cross still links no product app; this issue was the libobs + platform-plugin link, which is what landed.

    Refs #697

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

Metadata

Metadata

Assignees

Labels

P2infrareadysize:L

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions