Skip to content

bug: obs-c-oracle: no test binary links on a Windows GNU/gnullvm host (pthread comes from the compiler branch, not the target) #291

Closed

Description

@MCPVOT

What happens

On a Windows host whose Rust toolchain targets x86_64-pc-windows-gnu or
x86_64-pc-windows-gnullvm, no test binary links:

ld.lld: error: undefined symbol: pthread_mutex_lock
>>> referenced by libobs/util/profiler.c:238
>>>               libobs_c_oracle-<hash>.rlib(profiler.o):(oracle_profiler_start)
ld.lld: error: undefined symbol: pthread_mutex_unlock
ld.lld: error: undefined symbol: pthread_mutex_init
ld.lld: error: undefined symbol: pthread_mutex_destroy

So cargo test --workspace cannot run at all on that host. CI is unaffected:
windows-2025-vs2026 is MSVC, where the branch below is taken.

Why

rust/obs-c-oracle/build.rs:58 chooses the C threading implementation by
compiler, not by target:

if oracle.get_compiler().is_like_msvc() {
    // deps/w32-pthreads/pthread.c + util/threading-windows.c
} else {
    oracle.file(libobs.join("util/threading-posix.c"));
}

is_like_msvc() is false for clang, including LLVM-MinGW targeting Windows, so
the oracle compiles threading-posix.c and expects a system pthread that a GNU
Windows toolchain does not provide. profiler.c calls pthread_mutex_*
directly (and, per the same comment in build.rs, so does task.c), so the
link fails. The target is already known two lines up: let windows = std::env::var_os("CARGO_CFG_WINDOWS").is_some(); (line 31).

Proposed fix

Branch on the target instead of the compiler, i.e. use the deps/w32-pthreads
plus util/threading-windows.c path whenever windows is true. The single-file
pthread build does compile with LLVM-MinGW clang; verified locally:

$ clang --target=x86_64-pc-windows-gnu -std=c11 -O1 -DPTW32_STATIC_LIB     -I deps/w32-pthreads -c deps/w32-pthreads/pthread.c -o pthread.o
$ nm -g --defined-only pthread.o | grep -E 'pthread_mutex_lock|pthread_create'
00000e00 T pthread_mutex_lock
00003130 T pthread_create

Two further gaps on that host are outside this repo, listed for anyone
reproducing (I shimmed all three locally, nothing of it is in a PR):

  • LLVM-MinGW's <intrin.h> does not declare __iso_volatile_load32,
    __iso_volatile_load8 or _InterlockedExchange8, which
    libobs/util/threading-windows.h uses on x86/x64.
  • its <pthread.h> declares pthread_cond_timedwait as an inline wrapper over
    winpthreads' pthread_cond_timedwait64 alias, which w32-pthreads does not
    export.

How it was reached

Building #143's branch on a Windows 11 host with rustc 1.97.1
(x86_64-pc-windows-gnullvm, LLVM-MinGW 22.1.8). With the shims in place,
cargo test --workspace runs: 70 of 71 test binaries pass. The one failure,
buffered_file_serializer_parity (STATUS_ACCESS_VIOLATION in
defaults_match_oracle), reproduces on unmodified master, so it is separate
from this and may be worth its own issue.

Activity

  1. zackees commented on Oct 13, 2026

    @zackees
    Member

    Reproduced from Linux with soldr's mingw-w64 cross toolchain: soldr cargo test --no-run -p obs-util --target x86_64-pc-windows-gnu (GCC 15.3 mingw-w64). The build fails earlier than the link, in libobs/util/threading-windows.h: implicit declaration of function '__iso_volatile_load32', '_InterlockedExchange8', '__iso_volatile_load8'. So the build.rs branch fix alone doesn't make a GNU Windows host build. It also needs those MSVC intrinsics guarded in threading-windows.h, which is a public libobs header and needs an explicit decision first (AGENTS.md: no public header edits as part of a port). Leaving this unclaimed until that call is made; the build.rs half is ready as proposed.

  2. zackees commented on Oct 13, 2026

    @zackees
    Member

    Claiming: #291. The maintainer approved guarding the MSVC-only intrinsics in libobs/util/threading-windows.h. Plan: 1) RED: the oracle's build.rs picks the Windows threading by target, and a x86_64-pc-windows-gnu cross build of the tests fails; 2) GREEN: give threading-windows.h GCC/Clang fallbacks for the MSVC intrinsics, and close any remaining link gaps.

  3. added
    claimed
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions