Skip to content

test/cmocka: Run test_graphics_state_stacks_rust on Windows again (#2533) - #2537

Merged
zackees merged 6 commits into
masterfrom
fix/2533-msvc-link-order-w5
Oct 27, 2026
Merged

zackees merged 6 commits into
masterfrom
fix/2533-msvc-link-order-w5

Conversation

@zackees

@zackees zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member

Fixes #2533.

#2534 skipped test_graphics_state_stacks_rust on MSVC because link.exe failed with LNK2005 on matrix4_* (run 40401995234): the staticlib codegen unit that holds the gs_*_stack_* shims also defines matrix4_*, and obs.lib's copies were pulled first.

  • RED (2f68b64): drop the NOT MSVC guard; this is the configuration that failed in run 40401995234. There's no MSVC here for a local reproduction, so RED and GREEN are pushed together, per the CI/configuration rule in AGENTS.md.
  • GREEN (2766aa5): list libobs_rust-static ahead of OBS::libobs. link.exe resolves in command-line order, so the test's matrix4_* calls bind to the staticlib unit it pulls anyway, and obs.lib's members stay out. EXPORT is dllexport (no dllimport on the consumer side), so the test references plain matrix4_*, not __imp_.

No C test or public header changes. If the Windows lane still reports LNK2005, the fallback is moving the shims to their own codegen unit.

@zackees
zackees enabled auto-merge October 26, 2026 22:52
@vpacher

vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member

The new link order breaks the test on Linux. I built this head (2766aa5) on Linux x86_64 (Debian 13):

liblibobs_rust.a(obs_util-…-cgu.00.rcgu.o): undefined reference to symbol 'uuid_unparse_lower@@UUID_1.0'
/lib/x86_64-linux-gnu/libuuid.so.1: error adding symbols: DSO missing from command line

With the staticlib first, GNU ld also takes the test's own bmalloc/bfree (from the da_* macros) from obs-util in the staticlib, and obs-util needs libuuid. This is the same error as on #2528's first run. The Linux Tier 2 build of this PR will report it too.

Putting the staticlib first only on MSVC works on Linux: build OK and test_graphics_state_stacks_rust passes; test_cmocka_rust_static_guard.py and gersemi pass:

  if(MSVC)
    target_link_libraries(
      test_graphics_state_stacks_rust
      PRIVATE libobs_rust-static OBS::libobs OBS::caption ${CMOCKA_LIBRARIES}
    )
  else()
    target_link_libraries(
      test_graphics_state_stacks_rust
      PRIVATE OBS::libobs OBS::caption ${CMOCKA_LIBRARIES} libobs_rust-static
    )
  endif()

On MSVC the static-first order is still not tested. The same obs-util pull happens there, so the link can need more Windows system libraries, or show the clash that the note in rust/obs-graphics/src/ffi/image_file.rs describes. If ci_scope again selects only Linux for this path, a Windows Tier 2 run by hand is the only check before the merge. Also, this branch still names libobs.nsgif+.h.c, so it conflicts with #2514 in this block.

@zackees
zackees force-pushed the fix/2533-msvc-link-order-w5 branch 2 times, most recently from 7a08a42 to 3e9f3ed Compare October 26, 2026 23:02
@zackees
zackees disabled auto-merge October 26, 2026 23:02
@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Status:

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Reviewed. Putting the staticlib first on MSVC is a sound fix for the LNK2005, and Linux keeps its order (which avoids the libuuid problem). One coordination note: this re-adds libobs.nsgif+.h.c (and its MSVC warning block) to the target, and #2514 deletes that group. Whichever of the two lands second has to drop it from this file. I'll handle the rebase. Queuing once the Windows lane is green, since that's the GREEN.

@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Correction: this PR's CI doesn't run Rust Tier 2 on Windows, because ci_scope selects only Linux for test/cmocka/tests.d/. So a green run here won't prove the fix. I'll queue it after #2514 lands, and #2514's re-run (it does select the Windows lane) will be the check. If it reports LNK2005, revert the guard.

@zackees
zackees force-pushed the fix/2533-msvc-link-order-w5 branch from 3e9f3ed to 4ba0586 Compare October 26, 2026 23:32
@zackees

zackees commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

Windows result from run 40416968486: listing the staticlib first removed the LNK2005, but it made link.exe take obs_util objects from the staticlib instead of obs.dll, and those fail with LNK2019 (UuidCreate, timeBeginPeriod/timeEndPeriod, base_default_log_handler, base_log_literal). So the order is back to the original. On MSVC, this test now links with /FORCE:MULTIPLE /IGNORE:4006 /IGNORE:4088 (/WX is on for links): the duplicate matrix4_* is the same function in both places. On Linux, the test already gets its matrix4 from the staticlib's copy. New full run: https://github.com/obs-rust/obs-studio/actions/runs/40420479363

@vpacher

vpacher commented Oct 26, 2026

Copy link
Copy Markdown
Member

The new full run (40420479363) still fails Windows Tier 2, now on a warning:

LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
LINK : error LNK1218: warning treated as error; no output file generated

/FORCE turns off incremental linking, and /WX makes that warning an error. Two ways to fix it: add /INCREMENTAL:NO to this target's MSVC link options (then the warning does not occur), or add /IGNORE:4075 next to the other two.

@zackees
zackees force-pushed the fix/2533-msvc-link-order-w5 branch from 4ba0586 to faca5a1 Compare October 27, 2026 00:02
…#2533)

Drops the NOT MSVC guard from #2534. windows-2025-vs2026 fails to link
with LNK2005 on matrix4_* (run 40401995234).
…_state_stacks_rust (GREEN, #2533)

link.exe resolves references library by library in command-line order.
The staticlib's codegen unit with the gs_*_stack_* shims also defines
matrix4_*, so listing it first resolves the test's matrix4 calls there
and keeps obs.lib's copies out (LNK2005).
…rust (#2533)

GNU ld failed with 'libuuid.so.1: DSO missing from command line' when the
staticlib came before libobs; only link.exe needs the staticlib first.
…cks_rust on MSVC (#2533)

Linking the staticlib first (run 40416968486) removed the LNK2005 but pulled
obs_util objects that need rpcrt4, winmm and libobs' unexported base_log
functions (LNK2019). Keep the original order and let link.exe take the first
of the duplicate matrix4_* definitions instead.
…L on MSVC (#2533)

/FORCE makes link.exe drop /INCREMENTAL with LNK4075, which /WX turns into
LNK1218 (run 40420479363).
…#2533)

LNK4088 from /FORCE cannot be ignored, so /WX turned it into LNK1218
(run 40423760010).
@zackees
zackees force-pushed the fix/2533-msvc-link-order-w5 branch from faca5a1 to ff4e613 Compare October 27, 2026 00:32
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit a934484 Oct 27, 2026
74 of 76 checks passed
@zackees
zackees deleted the fix/2533-msvc-link-order-w5 branch October 27, 2026 01:02
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Done in obs-rust Multiview Oct 27, 2026
vpacher added a commit that referenced this pull request Oct 27, 2026
…group

#2528 added test_graphics_state_stacks_rust on master with
libobs.nsgif+.h.c, which this PR moves into the Rust staticlib; #2537 then
gave that file MSVC warning options. Drop the file and its MSVC block. Also
drop the two MSVC set_source_files_properties blocks that no longer name a
file (test_sprite_geometry_steps_rust, test_effect_parser_lifecycle_rust).

Co-Authored-By: Zach Vorhies <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
…t#2510) (obs-rust#2514)

* test: Characterize the libnsgif state machine and public API through nsgif.h (obs-rust#2510)

Ten cases for gif.c before its port, on GIFs that a small writer in the
test builds (header, screen descriptor, colour tables, graphic control
and loop count extensions, images of one colour from the LZW emitter):
the error and disposal strings; the nine bitmap formats and their byte
orders, and the default black and white table; a whole scan (info, frame
info, the default delay of a frame without a graphic control extension,
local palettes, a second scan, a scan after nsgif_data_complete); scans
in two parts and byte by byte; the screen size quirk with the first
frame setting or growing the size; a GIF without frames, a cut one and
not a GIF; nsgif_data_complete for a frame cut in its image data (also
frame 0, which gets transparency); the frame order of
nsgif_frame_prepare with the redraw area, the delay rules, play once,
loop forever, data not complete and one frame; the disposal across
frames (restore background with and without transparency, restore
previous), a restart, a cached frame and a bad frame number; the bitmap
callbacks and a row span wider than the image. 39/39 on the C.

Kept, characterized, not endorsed:
- When a scan stops at the end of the data inside a frame,
  nsgif_data_scan keeps the position where the frame's parse stopped,
  not the frame's start. The next scan reads image data or an
  extension's terminator as the next block: a bad frame from then on,
  also with all the data. A split inside the image data or on an
  extension's last byte breaks a scan in parts; OBS scans whole files.
- With play once (no loop extension), one more nsgif_frame_prepare after
  the last frame (infinite delay) shows frame 0 again before
  NSGIF_ERR_ANIMATION_END.

Refs obs-rust#2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* obs-graphics: RED for the libnsgif state machine and public API (todo!)

The safe core of libobs/graphics/libnsgif/gif.c.h as obs_graphics::gif,
with todo!() bodies: Gif<B: Bitmaps> with new, set_frame_delay_behaviour,
data_scan, data_complete, reset, frame_prepare, frame_decode, info,
frame_info, global_palette and local_palette, and strerror and
str_disposal. Info and FrameInfo have the C layout of nsgif_info_t and
nsgif_frame_info_t, which the API returns pointers to. Bitmaps is the
client's nsgif_bitmap_cb_vt, with default methods for the optional
callbacks. Every call that reads the GIF data takes it. gif_blocks'
disposal constants get UNSPECIFIED and NONE.

Tier 1 (render::gif in obs-tests-graphics): the ten cmocka cases one to
one with the same GIF writer, edge cases (dropping a Gif destroys its
bitmap; a bitmap that cannot be created is out of memory) and a proptest
(random and mutated GIFs, scanned in parts, then random calls: no panic,
the frame count never shrinks).

RED: 0 of 13 pass.

Refs obs-rust#2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* obs-graphics: Port the libnsgif state machine and public API (obs-rust#2510)

GREEN for obs_graphics::gif: the safe core (the frame table and the scan
positions of nsgif_data_scan with its frame parse on the gif_blocks
parsers, nsgif_data_complete, the frame order, loop count and delay
rules of nsgif_frame_prepare, nsgif_frame_decode with the disposal
across frames, the saved frame and the bitmap callbacks on the gif_frame
decode, the palettes and the strings; the C's uint32_t arithmetic as
wrapping operations) and a thin hidden #[no_mangle] shim for the
fourteen functions of nsgif.h. nsgif_t is NsgifCtx: the safe Gif plus the
buffer of the last scan; Info and FrameInfo have the C layout, as the API
returns pointers to them; nsgif_bitmap_cb_vt is BitmapCbVt, which
implements the Bitmaps trait over the client's function pointers.

gif.c.h, the last C file of libnsgif, moves from libobs.nsgif to the
ported group libobs.ported-nsgif-gif (its PCH renamed with it), so the
hybrid libobs has no libnsgif C left. The C oracle no longer builds
libnsgif as a library: image-file.c.h in the oracle calls the Rust shims,
as libobs does, and oracle/gif.c is gif.c.h renamed, calling the C
oracles of the other three files, for the parity test. The _rust test
executables (test_effect_parser_lifecycle_rust,
test_sprite_geometry_steps_rust, test_nsgif_decode_rust) take libnsgif
from the staticlib instead of compiling the group.

Tier 1: 13/13. Tier 3 (render::gif_parity): the strings, and 3 000 random
cases of generated GIFs (one to four frames, every disposal, delays,
transparency, rectangles inside and past the screen, interlace, local
tables, loop counts, the screen size quirk), mutated or cut, and random
bytes; scanned whole or in two to four parts, with or without
nsgif_data_complete, in all nine bitmap formats, with or without a row
span wider than the image and the optional callbacks; then random
prepares, decodes, resets and delay rules. After every call the result,
the info, every frame info, both palettes, the prepare outputs, the
decoded bitmap and the callback counts match the whole of libnsgif in C.
3/3 with the shim-only null pointer test. test_nsgif_decode_rust runs the
thirty-nine cmocka cases against the shims without any libnsgif C.

port_comparison (M1 Max, five 1920x1080 frames scanned and decoded through
the API, Rust on Rust, C on C, three runs): 49.3 to 50.6 ms, C 53.0 to
54.4 ms.

Refs obs-rust#2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* obs-build: Drop the Windows warning options of the ported libnsgif group

The Windows Rust build of libobs (rust/obs-build) gave the C group
libobs.nsgif /wd4244 /wd4267. obs-rust#2510 moves gif.c.h to the ported group
libobs.ported-nsgif-gif, which is not in that build target (the hybrid
takes libnsgif from Rust), and the build refuses options for sources
outside its target ("compiler options refer to sources outside this
target", native_libobs::windows_tests::core_builds_from_the_canonical_manifest
in Rust Tier 2 windows). The other three ported libnsgif groups have no
entry either.

Refs obs-rust#2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fixup: the _rust cmocka tests no longer compile the removed libnsgif group

obs-rust#2528 added test_graphics_state_stacks_rust on master with
libobs.nsgif+.h.c, which this PR moves into the Rust staticlib; obs-rust#2537 then
gave that file MSVC warning options. Drop the file and its MSVC block. Also
drop the two MSVC set_source_files_properties blocks that no longer name a
file (test_sprite_geometry_steps_rust, test_effect_parser_lifecycle_rust).

Co-Authored-By: Zach Vorhies <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* obs-graphics: Bound the gif_parity bitmaps; exclude a C read past the data

Two defects in render::gif_parity::api (obs-rust#2510), both from random seeds:

- A mutated logical screen descriptor can ask the bitmap callback for up
  to 65535 x 65535 pixels. cb_create allocated and filled that (17 GB),
  for the C and the Rust decoder. This starved the 16 GB CI runners:
  all three Fast Gate exit-143 runner losses of this PR (runs
  40380261405 attempts 1 and 2, merge queue run 40478704942). With a
  6 GB limit, 3 of 10 runs were OOM-killed. cb_create now returns NULL
  above 4 M pixels (16 MiB), as an out-of-memory host does; both sides
  get the same callback.

- After a scan that stops inside a frame's local colour table,
  nsgif_local_palette in C decodes the table from past the end of the
  data (buf_len); the Rust decodes only the bytes in the data. This is
  an intentional difference (OBS does not call nsgif_local_palette).
  The views now compare, for frames at or after frame_count, only
  whether there is a local palette and its size. The shrunk case is
  kept in proptest-regressions/gif_parity.txt; rust/README.md lists the
  difference.

Verified: the saved case passes; 50 runs (150 000 random cases) pass,
maximum resident size 154 MB; obs-tests-graphics 420/420; clippy clean.

Refs obs-rust#2510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Zach Vorhies <[email protected]>
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.

test/cmocka: Run test_graphics_state_stacks_rust on Windows again (LNK2005 on matrix4_*)

2 participants