Skip to content

rust/obs-util: Declare the pipe-windows Win32 calls directly (fix Windows Rust-ON link) - #261

Merged
zackees merged 1 commit into
obs-rust:masterfrom
b7216309-jpg:fix/pipe-windows-link
Oct 11, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
b7216309-jpg:fix/pipe-windows-link

Conversation

@b7216309-jpg

Copy link
Copy Markdown
Contributor

Fixes the Windows ENABLE_RUST_LIBOBS=ON link on master since #259:

libobs_rust.lib(api-ms-win-core-synch-l1-2-0.dll) : error LNK2005: __IMPORT_DESCRIPTOR_api-ms-win-core-synch-l1-2-0 already defined in libobs_rust.lib(api-ms-win-core-synch-l1-2-0.dll)
obs.dll : fatal error LNK1169

#259 merged at 306ec7aba, which still took its Win32 calls from windows-sys 0.61. The fix below was pushed to that branch a few minutes after the merge, so it never reached master.

Change

This is option 1 from @zackees's diagnosis on #259. windows-sys links through windows-link's raw-dylib import records, and std imports api-ms-win-core-synch-l1-2-0 the same way. Because libobs links libobs_rust.lib with WHOLEARCHIVE, both records land in obs.dll.

obs_util::pipe::windows now declares its ten kernel32 functions (CreatePipe, SetHandleInformation, CreateProcessW, WaitForSingleObject, GetExitCodeProcess, ReadFile, WriteFile, CloseHandle, GetLastError, MultiByteToWideChar) and three structs (SECURITY_ATTRIBUTES, STARTUPINFOW, PROCESS_INFORMATION) itself, against kernel32.lib, like ffi::bmem declares malloc. Compile-time asserts check the struct sizes against the SDK for 64-bit and 32-bit targets. obs-util no longer depends on windows-sys, so Cargo.lock loses that edge. Behavior is unchanged.

Testing (Windows, MSVC)

  • Reproduced the CI failure by linking a DLL with /WHOLEARCHIVE:libobs_rust.lib: the windows-sys build gives the same LNK2005/LNK1169; this build links.
  • test_pipe.c against this libobs_rust.lib: 14/14.
  • Rust tests: pipe 18/18, pipe_parity 10/10, export_list 3/3.
  • Checks: clippy -D warnings and cargo fmt --check are clean.

Windows Tier 2 CI is the real check.

🤖 Generated with Claude Code

obs-rust#259 merged with the core taking its Win32 calls from windows-sys 0.61,
which links through windows-link's raw-dylib import records. std
imports api-ms-win-core-synch-l1-2-0 the same way, and libobs links
libobs_rust.lib with WHOLEARCHIVE, so obs.dll gets both records and the
Windows ENABLE_RUST_LIBOBS=ON build fails:

  libobs_rust.lib(api-ms-win-core-synch-l1-2-0.dll) : error LNK2005:
  __IMPORT_DESCRIPTOR_api-ms-win-core-synch-l1-2-0 already defined
  obs.dll : fatal error LNK1169

The module now declares its ten kernel32 functions and three structs
itself, against kernel32.lib like ffi::bmem declares malloc, with size
checks against the SDK, and obs-util no longer depends on windows-sys.
Behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@b7216309-jpg
b7216309-jpg requested a review from zackees as a code owner October 11, 2026 20:29
@zackees
zackees merged commit 17fc4fa into obs-rust:master Oct 11, 2026
20 checks passed
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Thanks, this is option 1, and the branch is already on current master.

  • RED: master since rust: Port util/pipe-windows.c to obs-util #259. Rust Tier 2 windows with ENABLE_RUST_LIBOBS=ON fails with LNK2005 __IMPORT_DESCRIPTOR_api-ms-win-core-synch-l1-2-0 and then LNK1169.
  • Here: cargo check and clippy -D warnings for obs-util --lib on x86_64-pc-windows-gnu are both clean, and the Linux local gate passed (lint, rust-test, tier2-linux).
  • GREEN is the Windows Tier 2 job on this head, which links obs.dll with WHOLEARCHIVE. Merging as soon as it's green.

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.

2 participants