Skip to content

rust: Enforce a platform boundary with a pre-expansion Dylint - #326

Merged
zackees merged 5 commits into
masterfrom
feat/platform-boundary
Oct 12, 2026
Merged

zackees merged 5 commits into
masterfrom
feat/platform-boundary

Conversation

@zackees

@zackees zackees commented Oct 12, 2026

Copy link
Copy Markdown
Member

Closes #323. Part of #297.

Ports the soldr/zccache/fbuild platform-boundary pattern:

  • RED dylints/ban_platform_cfg_outside_boundary (adapted from soldr) runs in the ./lint lane before cfg expansion. Outside each crate's src/platform/ and src/ffi/, it rejects host #[cfg]/cfg!() and std::os::*/libc::/Win32 paths. Code compiled out on Linux is checked too, so the Linux lint lane covers every OS (deny(unsafe_code) and clippy could not see #[cfg(windows)] code).
  • GREEN obs-util: the pipe halves, the Windows utf8 converter, CLong, byte paths, the config BOM, the Sem choice and the MSVC mul_div64 flag move into src/platform/{mod.rs,unix/,windows/}. threading::Sem now also exists on Windows (the condvar stand-in task.rs already used). Tests now import obs_util::platform::windows::utf8.
  • GREEN obs-media-io: the recursive pthread mutex becomes platform::RecursiveMutex. The Unix-only audio-io.c port moves to audio_io/port.rs behind platform::with_audio_thread_port!. Its remaining unsafe is still rust/obs-media-io: move audio_io.rs unsafe out of the safe core into src/ffi #294.
  • Docs: a "Platform boundary" rule in testing-policy.md and AGENTS.md.

Local: ./lint, rust-test and tier2-linux all pass (stamped). clippy --lib is clean for x86_64-pc-windows-msvc and aarch64-apple-darwin.

Adapted from soldr's ban_platform_cfg_outside_boundary. It runs
pre-expansion in the lint lane and fails on the host cfgs and native
OS paths still in the obs-util and obs-media-io safe cores.

Refs #323
The pipe halves, the Windows utf8 converter, the C long width, byte
paths, the config BOM, the semaphore choice and the MSVC mul_div64 flag
now live under src/platform, the crate's only host-selection site.
threading::Sem now exists on Windows too (the condvar stand-in task.rs
used privately).

Refs #323
…(GREEN)

audio_io's recursive pthread mutex becomes platform::RecursiveMutex, and
the Unix-only audio-io.c port moves to audio_io/port.rs behind
platform::with_audio_thread_port!, so audio_io.rs has no host cfg or
libc path left. The port's remaining unsafe is still #294.

Closes #323
Refs #323

Local-Gate: v1 tree=ef667340e41b91cc5fb2d97b781b25f98134b6ee secs=110 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791784150,"gate":"rust/all/fmt","host":"linux-x86_64","key":"317498caa319f844c383de782b0dc9d43088f1db278ecbd2846f005c298cdbcd","lane":"lint","parents":["f0d4e4851348907fcbbd0731243215230c4c0c42"],"secs":14,"stamp":"f84de5c26bf5aa2db6b7db28bb91f330","tree":"ef667340e41b91cc5fb2d97b781b25f98134b6ee","v":1,"via":"run"}
Ci-Attestation: {"at":1791784150,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"317498caa319f844c383de782b0dc9d43088f1db278ecbd2846f005c298cdbcd","lane":"lint","parents":["f0d4e4851348907fcbbd0731243215230c4c0c42"],"secs":14,"stamp":"b77de7b88de75f10fd79bae5ad664875","tree":"ef667340e41b91cc5fb2d97b781b25f98134b6ee","v":1,"via":"run"}
Ci-Attestation: {"at":1791784150,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"485f75dd7520844008281b6430a1dd56b3af522807821b2429a12dfd12a21eb3","lane":"rust-test","parents":["f0d4e4851348907fcbbd0731243215230c4c0c42"],"secs":41,"stamp":"63fce29ecfba8786cce599ae61a809c1","tree":"ef667340e41b91cc5fb2d97b781b25f98134b6ee","v":1,"via":"run"}
Ci-Attestation: {"at":1791784150,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"d7c0a64000b411e1e0a7ce946adfce646ffa2fc331f6b4843c026ef183eb85b5","lane":"tier2-linux","parents":["f0d4e4851348907fcbbd0731243215230c4c0c42"],"secs":54,"stamp":"12728efe758c2c3bc8e0af89a330253b","tree":"ef667340e41b91cc5fb2d97b781b25f98134b6ee","v":1,"via":"run"}
--all-targets type-checks obs-stream-rust's integration test, which
needs CARGO_BIN_EXE_obs-stream-rust from a real build. The lint scans
whole src/ files, inline test modules included, so lib + bins is its
full scope.

Refs #323

Local-Gate: v1 tree=61aee07a90c30426e583cb2cc965ed80a124ef0f secs=126 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791784732,"gate":"rust/all/fmt","host":"linux-x86_64","key":"8c9cffba4aebed81f5a67007d18c051a49826f73a37cd7099e14e00abb1f979d","lane":"lint","parents":["bc324ec755c232937b80cbf2387520c7c407b656"],"secs":27,"stamp":"d7705ac7e033156e3de4d6e688328593","tree":"61aee07a90c30426e583cb2cc965ed80a124ef0f","v":1,"via":"run"}
Ci-Attestation: {"at":1791784732,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"8c9cffba4aebed81f5a67007d18c051a49826f73a37cd7099e14e00abb1f979d","lane":"lint","parents":["bc324ec755c232937b80cbf2387520c7c407b656"],"secs":27,"stamp":"912c064824e6cf2d6ba7a905918810c5","tree":"61aee07a90c30426e583cb2cc965ed80a124ef0f","v":1,"via":"run"}
Ci-Attestation: {"at":1791784732,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"0b190216e17b440c901f7652f3adfc37e642c8119ff7228e33681e3392396ecb","lane":"rust-test","parents":["bc324ec755c232937b80cbf2387520c7c407b656"],"secs":44,"stamp":"ef266402b2647ac8816e5d688f029e9f","tree":"61aee07a90c30426e583cb2cc965ed80a124ef0f","v":1,"via":"run"}
Ci-Attestation: {"at":1791784732,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5fc2dd63be6ea75927095cf4814ac17dd7249aae08b5b3968ff2545964ffb46d","lane":"tier2-linux","parents":["bc324ec755c232937b80cbf2387520c7c407b656"],"secs":55,"stamp":"a7cc93e27ed66fe05ed63c0e5ddaebfd","tree":"61aee07a90c30426e583cb2cc965ed80a124ef0f","v":1,"via":"run"}
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.

rust: Enforce a platform boundary with a pre-expansion Dylint

1 participant