Skip to content

build: Cross-compile libobs for Windows and macOS from any host via soldr - #1075

Merged
zackees merged 1 commit into
masterfrom
infra/cross-compile-targets
Oct 16, 2026
Merged

zackees merged 1 commit into
masterfrom
infra/cross-compile-targets

Conversation

@zackees

@zackees zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Refs #1051, #1065. Stacked on #1069: its two commits show here until it merges.

What

A CMake cross-compile check for libobs. It compiles libobs for Windows and macOS on any host, without a Windows or macOS runner.

Usage:

cmake -S cmake/cross -B build_cross_win-x64 -G Ninja -DOBS_CROSS_TARGET=win-x64 && cmake --build build_cross_win-x64
cmake --build build --target cross-mac-arm64    # cross-win-x64, cross-mac-x64, cross-all

What each part does:

  • cmake/cross/: a standalone project that compiles every libobs source the target OS builds, including the C build's ported files and the Rust build's C halves. It links nothing.
    • Toolchain: the LLVM and SDK soldr provisions for that OS.
    • Dependencies: the same prebuilt deps the real build uses (CMakePresets.json → .deps/).
    • Warnings: reported; -DOBS_CROSS_WERROR=ON makes them errors.
  • cmake/common/soldr.cmake:
    • Uses soldr from PATH, or downloads the version CI pins and checks its SHA256. ci/test_soldr_pin.py keeps that pin equal to the workflows'.
    • Runs soldr toolchain prepare, then finds LLVM and the SDK under soldr's root. A TODO says to switch to soldr cc --target <triple> once soldr exposes the Apple and MSVC targets.
  • libobs/cmake/sources.cmake: libobs's file lists move here, read by both the real build and the cross project. The per-OS lists are unchanged (checked file by file against the old lists).
  • validate.sh: derives the ported objects (still 46) from sources.cmake.
  • .deps/: now git-ignored.
  • No win-arm64: util/threading-windows.h, a public header, uses MSVC-only ARM64 intrinsics that clang lacks.

Verified locally

  • Cross checks:
    • win-x64: 0 errors, 56 warnings.
    • mac-arm64: 0 errors, 40 warnings.
    • mac-x64: 0 errors, 40 warnings.
    • Every warning is in code master already has.
  • soldr download path: with PATH lookup disabled, CMake fetched soldr 0.9.33, verified the SHA256, and the binary ran.
  • ci/ Python suite: 506 tests pass.
  • Linux Tier 2 (Rust OFF and ON) was still running when I pushed; I'll add the result here.

…oldr

cmake/cross/ is a standalone CMake project that compiles libobs for
another OS with the LLVM and SDK soldr provisions (Apple SDK, or the xwin
MSVC CRT + Windows SDK) and the same prebuilt dependencies the real
build uses (CMakePresets.json -> .deps/, via buildspec_common). It
compiles every source that OS builds, both the C build's ported files
and the Rust build's C halves, and links nothing. A configured OBS
build gets cross-win-x64, cross-mac-arm64, cross-mac-x64 and cross-all.

cmake/common/soldr.cmake finds soldr on PATH or downloads the version CI
pins (SHA256-checked; ci/test_soldr_pin.py keeps it equal to the
setup-soldr version: in the workflows). It runs soldr toolchain prepare
and finds LLVM and the SDK under soldr's root; that becomes
soldr cc --target <triple> once soldr exposes the Apple and MSVC
targets. No win-arm64: util/threading-windows.h (public) uses MSVC-only
ARM64 intrinsics clang lacks.

libobs's file lists move into libobs/cmake/sources.cmake (common,
ported, Rust-only, and per-host sources and obs-host no-ops), read by
libobs/CMakeLists.txt, cmake/os-<os>.cmake and the cross project, so
both compile the same files. Per-OS lists are unchanged. validate.sh
derives the ported objects (46) from it. .deps/ is git-ignored.

Local: win-x64, mac-arm64 and mac-x64 compile libobs with 0 errors;
their warnings are all in code master already has.

Refs #1051, #1065
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master (c4e9442). #1069 landed, so its two commits are dropped, and the branch now carries only the cross-compile commit. The rebase had no conflicts.

Checked after the rebase:

Not built locally.

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