fix(dev): the Tracy build links on Windows with llvm-mingw (secur32 for GetUserNameExA) #1765

Merged
llun merged 3 commits from Jiro113/Longshot:fix/tracy-windows into main 2026-11-19 17:59:46 +00:00
Contributor

Type: fix · Risk: low · Tested on: Windows 11, RTX 4090 · Needs: none

TL;DR

The profiling build of the game (LONGSHOT_TRACY=1, for developers only) did not link on Windows: one system
library the profiler's client needs was never named on the link line. This PR names it. The Tracy build now builds on
Windows with llvm-mingw, ran in Castle Town's market three times, and the Tracy viewer's capture tool saved a minute
of zones from both the host and the renderer each time. A game-free test fails on main and passes here.

Breakdown

  • Who it helps: developers profiling the game on Windows with Tracy; no player build changes.
  • What was wrong: Tracy's client asks for its Windows libraries with #pragma comment(lib, ...) lines that only
    MSVC reads, so under llvm-mingw secur32 (for GetUserNameExA) was missing and the executable did not link.
  • What changes: a LONGSHOT_TRACY=1 build on Windows also links secur32, and the Tracy page of the docs says how
    the Windows build was built, captured and exported.
  • What does not change: every build without LONGSHOT_TRACY (the players' builds, the Builder's, Linux's),
    third_party/, the game's behaviour.
  • How it was checked: a game-free test that fails on main (secur32 missing) and passes here; three Tracy builds of
    this fix on Windows ran 180 s in the south market each, with a 60-s capture of 159 to 164 MB saved each time.
  • What is still open: Windows sampling and context switches (Tracy's manual says they need an administrator; not
    tried here), named in the docs.
  • Risk: low: one more library on a link line that only a developer's Tracy build on Windows uses.

Why

docs/development/tracy.md said the Windows configuration of the Tracy build was "written and not yet built by
anyone". Built here with llvm-mingw, its link stopped on undefined symbol: GetUserNameExA, called by Tracy's
TracySystem.cpp for the user name the viewer shows. Tracy asks for secur32 (and ws2_32, advapi32, user32) by
#pragma comment(lib, ...) under _MSC_VER, which llvm-mingw's clang does not define; dbghelp's pragma is outside
it, and the others the game links anyway. See #1543 (merged: the Tracy build), #1546 and #1741 (merged: Tracy build
fixes, Linux), #1746 (merged: mise run tracy-tools).

How to reproduce

Seen on: Windows 11, llvm-mingw 20261104 (ucrt), any GPU
Settings and switches: LONGSHOT_TRACY=1 at the build
Steps: build a pack with LONGSHOT_TRACY=1 (dev_packs.py pack over a base, or make_game.py)
Expected: the executable links
Actual: on main the link fails with undefined symbol: GetUserNameExA

What changed

The Windows link of the executable names secur32 beside ws2_32 when LONGSHOT_TRACY is set, and a test checks that
every library Tracy's pragmas ask for is on that link.

  • build: nx2/build.py, the executable's link: -lsecur32 with -lws2_32 under TRACY, with a comment saying why.
  • tests: tests/test_tracy_win_libs.py reads every #pragma comment(lib, ...) in third_party/tracy/public and checks
    each library is in HOST_LIBS or in the LONGSHOT_TRACY libraries of nx2/build.py (text only, no compiler). On
    main it fails: "secur32 (asked for by third_party/tracy/public/common/TracySystem.cpp) is not on the Windows link of
    the executable".
  • docs: docs/development/tracy.md: the Windows build links and captures, why secur32 is named, tracy-csvexport
    (counts, and -u for every zone with its thread and text), and what was not tried on Windows (sampling and context
    switches need an administrator per Tracy's manual; no zones in the game's code, whose list is for ELF objects).

Measurements

Nothing to measure: the change adds one library to the link of the developers' Tracy build on Windows only, and a build without LONGSHOT_TRACY (every player's) has the same link line as on main.

Flags and settings

None.

Testing

Tested: Windows 11 Home 10.0.26300, RTX 4090 (NVIDIA 621.24), i9-13900K, llvm-mingw 20261104: three
LONGSHOT_TRACY=1 packs over a base (v3.0.0, 544229a2) built and linked with this fix (one from the fix before it was
committed, two from its commit over main 8b0ea786 with local zones added for a study, not in this PR); each ran 180 s
in Castle Town's south market (cap 60, DLSS on) through the PC's job queue, and tracy-capture 0.15.0 saved a 60-s
capture (159, 163 and 164 MB) with the host's waits and the renderer's zones; tracy-csvexport -u read them. Run as a
user with TRACY_NO_SAMPLING=1. The game-free test fails on main and passes here. tests/run_all.py (the venv's Python 3.13,
llvm-mingw on PATH, RX_CPM set) on the rebased tree: 755 passed, 49 failed, 53 skipped. None of the failures is
this PR's: before the rebase, main 8b0ea786 and this branch over it failed the same files (749 passed, 49 failed, 53
skipped each; test_longshot_ctl failed once in the branch's run and passes alone; byte_compile_tracked failed in
main's run only because that tree was an export without git), and the one file failing since the rebase,
test_high_fps_fixes (HOS_HEAP_BASE undeclared in its stand-ins), compiles host code this PR doesn't touch. The 48
files: test_auto_handheld, test_bug_report, test_bug_report_defaults, test_capture_read_once,
test_capture_readback_visibility, test_crash_dialog, test_crt_options, test_damage_debug_menu, test_dev_packs,
test_display_startup_failure, test_dlss_feature_size, test_draw_stream_visibility, test_failed_compile_keeps_objects,
test_fsr_image_retirement, test_fsr_uniform_ownership, test_game_menu_mouse_buttons, test_guest_imported,
test_high_fps_fixes, test_host_guest_writes, test_hud_layout_row, test_job_queue, test_libc_hooks, test_linux_preflight,
test_linux_pressure, test_missing_nup, test_pads_after_menu, test_parallel_init_order, test_pending_guest_import,
test_pipeline_play_cache, test_prepare_cache_save, test_present_source_crop, test_present_thread, test_profiling_mode,
test_psychov35_fsr3_fg, test_readback_timeout_source, test_recorder_sync, test_replay_write_order, test_sdiv_overflow,
test_slow_frames, test_song_note_cue, test_staging_burst, test_tested_configurations, test_texel_buffer_ownership,
test_upscaler_rows, test_vcore_escape, test_vk_occlusion_queries, test_walk_key, test_work_lock (test_work_lock fails
under the venv's launcher and passes under the uv Python itself).

Rebased onto main 819a5967 after those runs: the commits it brings change nx2/build.py only to copy RenHDrum beside
the game, not the executable's link, and the test passes on the rebased tree.

Not tested: Tracy's sampling and context switches on Windows (they need an administrator per Tracy's manual; this
PC has none). Linux is not touched (the line is in the Windows link).

Must be tested:

  • None.

Risks

What could break: a Windows Tracy build without libsecur32.a in its toolchain (llvm-mingw and MSYS2's MinGW both
ship it).

Turning it off: revert the commit.

Compatibility: Nothing changes.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Windows 11, RTX 4090 · **Needs:** none ## TL;DR The profiling build of the game (`LONGSHOT_TRACY=1`, for developers only) did not link on Windows: one system library the profiler's client needs was never named on the link line. This PR names it. The Tracy build now builds on Windows with llvm-mingw, ran in Castle Town's market three times, and the Tracy viewer's capture tool saved a minute of zones from both the host and the renderer each time. A game-free test fails on main and passes here. ## Breakdown - **Who it helps:** developers profiling the game on Windows with Tracy; no player build changes. - **What was wrong:** Tracy's client asks for its Windows libraries with `#pragma comment(lib, ...)` lines that only MSVC reads, so under llvm-mingw `secur32` (for `GetUserNameExA`) was missing and the executable did not link. - **What changes:** a `LONGSHOT_TRACY=1` build on Windows also links `secur32`, and the Tracy page of the docs says how the Windows build was built, captured and exported. - **What does not change:** every build without `LONGSHOT_TRACY` (the players' builds, the Builder's, Linux's), `third_party/`, the game's behaviour. - **How it was checked:** a game-free test that fails on main (`secur32` missing) and passes here; three Tracy builds of this fix on Windows ran 180 s in the south market each, with a 60-s capture of 159 to 164 MB saved each time. - **What is still open:** Windows sampling and context switches (Tracy's manual says they need an administrator; not tried here), named in the docs. - **Risk:** low: one more library on a link line that only a developer's Tracy build on Windows uses. ## Why `docs/development/tracy.md` said the Windows configuration of the Tracy build was "written and not yet built by anyone". Built here with llvm-mingw, its link stopped on `undefined symbol: GetUserNameExA`, called by Tracy's `TracySystem.cpp` for the user name the viewer shows. Tracy asks for `secur32` (and `ws2_32`, `advapi32`, `user32`) by `#pragma comment(lib, ...)` under `_MSC_VER`, which llvm-mingw's clang does not define; `dbghelp`'s pragma is outside it, and the others the game links anyway. See #1543 (merged: the Tracy build), #1546 and #1741 (merged: Tracy build fixes, Linux), #1746 (merged: `mise run tracy-tools`). ## How to reproduce **Seen on:** Windows 11, llvm-mingw 20261104 (ucrt), any GPU **Settings and switches:** `LONGSHOT_TRACY=1` at the build **Steps:** build a pack with `LONGSHOT_TRACY=1` (`dev_packs.py pack` over a base, or `make_game.py`) **Expected:** the executable links **Actual:** on main the link fails with `undefined symbol: GetUserNameExA` ## What changed The Windows link of the executable names `secur32` beside `ws2_32` when `LONGSHOT_TRACY` is set, and a test checks that every library Tracy's pragmas ask for is on that link. - build: `nx2/build.py`, the executable's link: `-lsecur32` with `-lws2_32` under `TRACY`, with a comment saying why. - tests: `tests/test_tracy_win_libs.py` reads every `#pragma comment(lib, ...)` in `third_party/tracy/public` and checks each library is in `HOST_LIBS` or in the `LONGSHOT_TRACY` libraries of `nx2/build.py` (text only, no compiler). On main it fails: "secur32 (asked for by third_party/tracy/public/common/TracySystem.cpp) is not on the Windows link of the executable". - docs: `docs/development/tracy.md`: the Windows build links and captures, why `secur32` is named, `tracy-csvexport` (counts, and `-u` for every zone with its thread and text), and what was not tried on Windows (sampling and context switches need an administrator per Tracy's manual; no zones in the game's code, whose list is for ELF objects). ## Measurements Nothing to measure: the change adds one library to the link of the developers' Tracy build on Windows only, and a build without `LONGSHOT_TRACY` (every player's) has the same link line as on main. ### Flags and settings None. ## Testing **Tested:** Windows 11 Home 10.0.26300, RTX 4090 (NVIDIA 621.24), i9-13900K, llvm-mingw 20261104: three `LONGSHOT_TRACY=1` packs over a base (v3.0.0, 544229a2) built and linked with this fix (one from the fix before it was committed, two from its commit over main 8b0ea786 with local zones added for a study, not in this PR); each ran 180 s in Castle Town's south market (cap 60, DLSS on) through the PC's job queue, and `tracy-capture` 0.15.0 saved a 60-s capture (159, 163 and 164 MB) with the host's waits and the renderer's zones; `tracy-csvexport -u` read them. Run as a user with `TRACY_NO_SAMPLING=1`. The game-free test fails on main and passes here. `tests/run_all.py` (the venv's Python 3.13, llvm-mingw on `PATH`, `RX_CPM` set) on the rebased tree: 755 passed, 49 failed, 53 skipped. None of the failures is this PR's: before the rebase, main 8b0ea786 and this branch over it failed the same files (749 passed, 49 failed, 53 skipped each; `test_longshot_ctl` failed once in the branch's run and passes alone; `byte_compile_tracked` failed in main's run only because that tree was an export without git), and the one file failing since the rebase, `test_high_fps_fixes` (`HOS_HEAP_BASE` undeclared in its stand-ins), compiles host code this PR doesn't touch. The 48 files: test_auto_handheld, test_bug_report, test_bug_report_defaults, test_capture_read_once, test_capture_readback_visibility, test_crash_dialog, test_crt_options, test_damage_debug_menu, test_dev_packs, test_display_startup_failure, test_dlss_feature_size, test_draw_stream_visibility, test_failed_compile_keeps_objects, test_fsr_image_retirement, test_fsr_uniform_ownership, test_game_menu_mouse_buttons, test_guest_imported, test_high_fps_fixes, test_host_guest_writes, test_hud_layout_row, test_job_queue, test_libc_hooks, test_linux_preflight, test_linux_pressure, test_missing_nup, test_pads_after_menu, test_parallel_init_order, test_pending_guest_import, test_pipeline_play_cache, test_prepare_cache_save, test_present_source_crop, test_present_thread, test_profiling_mode, test_psychov35_fsr3_fg, test_readback_timeout_source, test_recorder_sync, test_replay_write_order, test_sdiv_overflow, test_slow_frames, test_song_note_cue, test_staging_burst, test_tested_configurations, test_texel_buffer_ownership, test_upscaler_rows, test_vcore_escape, test_vk_occlusion_queries, test_walk_key, test_work_lock (`test_work_lock` fails under the venv's launcher and passes under the uv Python itself). Rebased onto main 819a5967 after those runs: the commits it brings change `nx2/build.py` only to copy RenHDrum beside the game, not the executable's link, and the test passes on the rebased tree. **Not tested:** Tracy's sampling and context switches on Windows (they need an administrator per Tracy's manual; this PC has none). Linux is not touched (the line is in the Windows link). **Must be tested:** - None. ## Risks **What could break:** a Windows Tracy build without `libsecur32.a` in its toolchain (llvm-mingw and MSYS2's MinGW both ship it). **Turning it off:** revert the commit. **Compatibility:** Nothing changes. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Tracy's client asks for ws2_32, advapi32, user32, secur32 and dbghelp with #pragma comment(lib, ...),
all but dbghelp's under _MSC_VER, which llvm-mingw's clang does not define. The check reads the
pragmas in third_party/tracy/public and the executable's Windows link in nx2/build.py (HOST_LIBS and
the LONGSHOT_TRACY libraries). Fails on main: secur32 (TracySystem.cpp's GetUserNameExA) is missing.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tracy's client asks secur32 for GetUserNameExA by a #pragma comment(lib) that only MSVC reads
(third_party/tracy/public/common/TracySystem.cpp, under _MSC_VER); llvm-mingw does not define it, and
the link of longshot.exe stopped on the undefined symbol. The Windows link now names -lsecur32 beside
-lws2_32 when LONGSHOT_TRACY=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Claude Code
docs(dev): the Tracy build on Windows is built and captures
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 19s
155b289046
The Windows configuration was written and never built: it now links (secur32), the renderer's zones reach the
capture through longshot_tracy.lib, and tracy-capture -s 60 saved its minute. Say what a user's run on Windows
lacks (sampling, context switches, game-code zones) and how tracy-csvexport -u gives each zone's text.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 4090, NVIDIA 621.24, llvm-mingw 20261104: three LONGSHOT_TRACY=1 packs with this fix built and linked; each ran 180 s in Castle Town's south market (cap 60, DLSS on) and tracy-capture 0.15.0 saved a 60-s capture with the host's and the renderer's zones; no error or hang. Ran before the rebase onto 819a5967, which does not change the executable's link.

Tested in game: Windows 11, RTX 4090, NVIDIA 621.24, llvm-mingw 20261104: three LONGSHOT_TRACY=1 packs with this fix built and linked; each ran 180 s in Castle Town's south market (cap 60, DLSS on) and tracy-capture 0.15.0 saved a 60-s capture with the host's and the renderer's zones; no error or hang. Ran before the rebase onto 819a5967, which does not change the executable's link.
Jiro113 changed title from WIP: fix(dev): the Tracy build links on Windows with llvm-mingw (secur32 for GetUserNameExA) to fix(dev): the Tracy build links on Windows with llvm-mingw (secur32 for GetUserNameExA) 2026-11-19 17:51:17 +00:00
llun approved these changes 2026-11-19 17:59:32 +00:00
llun merged commit a5fbd680f9 into main 2026-11-19 17:59:46 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 19s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1765
No description provided.