Skip to content

docs: the retail boot chain under Wine on Linux - #7232

Closed
kett1m wants to merge 1 commit into
ItsNotRexed:mainfrom
kett1m:wine-first-boot
Closed

kett1m wants to merge 1 commit into
ItsNotRexed:mainfrom
kett1m:wine-first-boot

Conversation

@kett1m

@kett1m kett1m commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as a new item.

Depends on: #7217, only for tests/test_docs_links.py to pass. That failure is the README fence on main, not a
link this page adds; with #7217 cherry-picked locally the test is OK.

What and why

docs/retail_boot_chain.md records the chain as measured on Windows. The runtime is meant to run under Wine too
(#217), and nobody had measured the retail executable there, so this adds the first pass on Linux as section 5: the
cross build, Wine 11.22, an RTX 3090 and the Vulkan device.

The section says plainly that nothing past stop 1 was observed on Wine, and it gives counts and error classes only:
no addresses, offsets, IID values or bytes from the executable.

Tested

AI-assisted: yes

@JoaoPauluu

Copy link
Copy Markdown

Reproduced on a second Linux machine, with the seven package DLLs in the folder. Two of the three passes match. --init differs. Counts and error classes only.

Setup: gta6rt from main 8575d36ed (this PR's base), a fresh cross build (clang-cl 23.1.5 + xwin 0.10.0, SDK 10.0.26100, RelWithDebInfo, -DLEONIDA_VULKAN_HEADERS_FETCH=ON). Wine 11.21 on CachyOS (KDE Wayland, through XWayland), RTX 3060, NVIDIA 620.70.06, LEONIDA_D3D12=vulkan, --overlay outside the game folder. The full 1.0.2.1 package from my own copy (make_game.py --check: all 108 files present).

Pass Here
--dry-run Exit 0, 5 modules mapped. The executable has 54 shim, 432 host, 72 bound to the four bundled modules, 29 unimplemented.
--init Exit 0. 4 dllmain events (the four bundled DLLs), 4 tls_callback events for the executable, and no exception event.
--run Exit 5, an unhandled access violation (read at null). The faulting frame is in gta6rt.exe host code, and the stack runs back through the title and ucrtbase into the title again, which fits "the title's first static initializer calls a shim". I didn't check by disassembly that it's the std::mutex lock.

What this adds to the section:

  • --dry-run: your 102 add up exactly. 29 unimplemented + 72 that bind to the bundled DLLs = 101, and the shim count is 54 here against your 53. The one-shim difference is probably the import that main served after your run. It might be worth one sentence with these numbers, so a reader who has the DLLs knows what to expect.
  • --init: I don't see the access violation in the second TLS callback. Either having the bundled DLLs mapped (and their dllmain run first) changes that path, or it's Wine 11.21 vs 11.22. A run without the DLLs on this machine would tell them apart; I can do that if it helps. As written, the row could say the access violation was seen without the package DLLs.
  • --run: the same stop and exit code as yours.

AI-assisted (Claude Code).

@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Thanks, that is exactly the run the section was missing. Updated in the head:

  • --dry-run: the row now carries both numbers. With the seven package DLLs present, 54 shim, 432 host, 72 bound to the four bundled modules and 29 unimplemented; 72 of my 102 bind once the package is there and 29 stay missing.
  • --init: the access violation is now stated as seen without the package DLLs, and the row says the run with them present had four dllmain events and no exception. I left it open whether the bundled DllMains running first or Wine 11.21 against 11.22 removes it.
  • --run: the same stop and exit 5 on both machines, as you found.

If you do run the no-DLLs case on that machine, the result would settle the --init question and I will fold it in.

@ruvenesh

Copy link
Copy Markdown

Data point for section 5 (Wine on Linux), going past stop 1; AI-assisted (Claude Code); counts, slot numbers and error classes only, no game data.

Setup: Ubuntu 24.04, Wine 9.0, RTX 3060 (driver 580), clang-cl + xwin cross build with -DLEONIDA_SDL3_FETCH=ON -DLEONIDA_VULKAN_HEADERS_FETCH=ON -DLEONIDA_REQUIRE_VULKAN=ON, LEONIDA_D3D12=vulkan, --game-dir <package>, own 1.0.2.1 copy. main e6be35ab plus #6582, #3390, #2490, #4313, #3410, #4531, #4348, #6995, #6964, #6954, #7076 merged locally (conflicts resolved by hand; no new code).

So Wine does reach stop 10, on the pinned PR stack, once the Vulkan headers are fetched. That configure flag might be worth a line in docs/testing.md section "The Windows runtime on Linux".

@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Folded ruvenesh's run into section 5, since it takes the Wine chain well past stop 1:

  • The section now records that the cross build does not find the Vulkan headers by itself, so without -DLEONIDA_VULKAN_HEADERS_FETCH=ON LEONIDA_D3D12=vulkan is ignored without a message, and what Wine 9 does in that state (E_INVALIDARG at 12_0, E_NOINTERFACE from the proxy's first QueryInterface at 11_0).
  • With the headers, the RTX 3060 / Wine 9.0 run reaches the Windows chain's stops in order and stop 10: 1,181 D3D12 calls, 5 queues, fences, allocators, 581 lists created and closed, XboxIDXGIDevice::GetAdapter, then the ~185 MiB XMemVirtualAlloc with type 0x42000 and attribute 7, with XMemAllocatePhysicalPages answered at 0x280 and 11,360 pages.
  • Wine 11.20 raising 0x80000101 after the third XMemVirtualAlloc where 9.0 does not is noted as the difference between the two.

The section still keeps my single-machine result, which was measured without that PR stack and stops at the TLS slot 0 crash.

The chain in this page is Windows-only. This adds the first pass on Linux: the cross build, Wine 11.22, an RTX 3090.

With a folder that holds only the executable, --dry-run maps it at its preferred base with 53 shim, 432 host and 102
unimplemented imports; --init exits 0 and the trace holds a handled access violation inside the second TLS callback;
--run stops in the runtime before the title's first static initializer finishes, in the runtime's own static TLS at
module index 0. That is RT-259's subject, and ItsNotRexed#4313 is its fix.

Counts and error classes only, no addresses, offsets or bytes from the executable.
@kett1m

kett1m commented Nov 23, 2026

Copy link
Copy Markdown
Author

Updated section 5: the --init access violation no longer reproduces. On main 47428cc2, with the same folder that holds only the executable, --init exits 0 with both TLS callbacks and no exception, twice in a row; the map now reports 94 unimplemented imports and none of them from xmem.dll. So the read at 0xf inside the second TLS callback was a missing shim, since merged, not a Wine difference. That also agrees with JoaoPauluu's full-package run.

The --run stop is unchanged: RT-259 / #4313.

@YordiLorenzo

Copy link
Copy Markdown

Tested bbb9396 on Linux, Python 3.14.4: pass (docs read, no game copy)

  • python -I tests/test_docs_*.py, 11 files: 8 OK. test_docs_cli_flags, test_docs_design_rows and test_docs_links fail on README.md, docs/dev-tools.md and docs/embedded_shaders.md only, the same on main, none from this page.
  • docs/retail_boot_chain.md:131: "Whether Wine then reaches stop 1 is not measured here ... everything above stop 1 in this page is the Windows chain", but line 121 says the Wine 9.0 run got to stop 10. The TLS stop is also row 4 in the table in section 1, not stop 1. Fix: call it stop 4, and say the Wine 9.0 run on the pinned stack got past it to stop 10.

@EdouardSence

Copy link
Copy Markdown
Contributor

A measurement for the sentence "Whether Wine then reaches stop 1 is not measured here" in §5.

Setup: Linux (CachyOS, kernel 7.3.5), Wine 11.22, AMD GPU on RADV, cross build per docs/testing.md (clang-cl 23.1.5, xwin 0.10.0, SDK 10.0.26100), package 1.0.2.1 with its bundled DLLs in the folder, LEONIDA_D3D12=vulkan, --run --trace.

Tree --run outcome
main at 867d922 Same stop as §5: unhandled access violation (read at 0x0) in the first static initializer that reaches a shim; the runtime's guarded function-local static (library_loader.cpp host_module_name) is skipped because the guard reads the index-0 block.
main + #8195 The next guarded static faults the same way (read at 0x8, xmem.cpp note_attributes).
main + #8195 + /Zc:threadSafeInit- (diagnostic only) The runtime gets through, then the title's own allocator faults: its /GA code reads the allocator pointer from slot 0, which is still gta6rt.exe's block (stop 4).
main + #8195 + the TLS part of #7524 (host_tls.h, the pe_loader index-0 mirror and pad, main.cpp; its xmem.cpp/d3d12_xs.cpp changes left out because they conflict with main) All static initializers pass. InitializeApiImplEx2 runs (offline), the loader installs 42 per-thread TLS blocks, and the run stops at a title int3 (exception 0x80000003) before the first D3D12 call; the title's crash handler then fails to write its crash log to t:\.

So under Wine the index-0 fix is enough to get past stop 4, as on Windows. I haven't yet matched the int3 to a numbered stop (the D3D12 trace is empty at that point, so it is ≤ stop 6). Note: that build had LEONIDA_VULKAN_HEADERS_FETCH=OFF (the runtime stage default), which matters only once the device is created.

Outcomes only; no game data. AI-assisted (Claude Code), run and checked by me.

@EdouardSence

Copy link
Copy Markdown
Contributor

Follow-up to my comment above: the same Wine machine taken further, one open PR at a time, on the retail executable.

Setup: Linux (CachyOS, kernel 7.3.5), Wine 11.22, AMD RX 9070 XT on RADV (GFX1201), cross build per docs/testing.md (clang-cl 23.1.5, xwin 0.10.0, SDK 10.0.26100), package 1.0.2.1 with its bundled DLLs, LEONIDA_D3D12=vulkan, --run --trace --trace-d3d12. Base: main at 867d922. Each row adds one PR to the row above (merged locally, conflicts resolved by keeping both sides; nothing else changed).

Added Stops at D3D12 calls (failed)
— (main) static init, runtime's guarded static (§5) 0
#8195 + TLS part of #7524 title int3: GameInputCreate fails (the cross build had no SDL3, so it bound to Wine's stub) 0
#7554, run with LEONIDA_SDL3_FETCH=1 stop 7: access violation in proxy_slot<26> device created
#8930 stop 8: CreateCommandQueue refused … type 2 (E_INVALIDARG) 5 (1)
#6954 stop 9: slot 73 asks for the console list IID → E_NOINTERFACE 13 (1)
#2490 (#7076's commits come with it) title int3 after the stop 10/11 allocations: the placeholder reserve and its five MEM_REPLACE_PLACEHOLDER windows all succeed on main, but XMemMapPhysicalPages fails with error 87 because the view protection keeps PAGE_WRITECOMBINE 1,181 (0)
#7492 access violation (a write) in Device::CreatePlacedResource1 right after device slot 70 is forwarded: the stop-14 area, which #7066 / #8304 / #9068 address 1,198 (0): adds the first SRV, UAV and CBV

So on Wine 11.22 + RADV the Windows chain reproduces stop for stop through stop 13, and the 1,181-call count at stop 10 matches the Wine 9 / RTX 3060 run in §5. Things specific to the Linux path that this run turned up:

  1. Without SDL3 the runtime stage's gta6rt.exe stops at GameInputCreate under Wine (the earliest title-side stop on Linux); make_game: the Linux cross-build passes LEONIDA_SDL3_FETCH on and warns when gta6rt.exe has no GameInput shim #7554 warns about it and LEONIDA_SDL3_FETCH=1 fixes it.
  2. xmem_test passes under Wine 11.22 (173 checks, including pages mapped into a window carved out of a placeholder), so Wine's placeholder support is enough; the only xmem failure was the cache modifier (xmem: map physical pages without a cache modifier in the view protection #7492).
  3. The TLS part of loader: hand static TLS index 0 to the mapped title #7524 is required on Wine just as on Windows; its xmem.cpp / d3d12_xs.cpp changes conflict with main and were left out without affecting this run.

Outcomes only; no game data. AI-assisted (Claude Code), every run done and checked by me on the machine above.

@EdouardSence

Copy link
Copy Markdown
Contributor

Update on the Wine 11.22 / RX 9070 XT (RADV) run above: four more rows, same method (one open PR added per row on top of the previous stack, conflicts resolved by keeping both sides).

Added Stops at D3D12 calls (failed)
#7066 (slot 70 in the proxy) stop 14 passes; next is an access violation in proxy_slot<25> (slot 25 forwarded in the PC form) 1,632 (0)
#7110 (slot 25 C-ABI form; its own slot 26 handler is shadowed by #8930's here) slot 25 passes; device slot 127 is "beyond the PC device vtable (80 slots)" → E_NOTIMPL → title int3 (stop 15) 1,632 (0)
#7052 (slot 127 → PC CreateCommittedResource3) stop 15 passes: the first 2D committed resources (xbox flags 0x300005 → PC flags 0x5) with their SRV/RTV/UAV; then a title int3 (the stop 16/17 area in #6982) 1,640 (0)

Merge notes for whoever lands these: #7066 moves the Xbox routes into route_xbox_device_slot(), whose queue_x branch still casts the 32-byte Xbox description to D3D12_COMMAND_QUEUE_DESC. With #6954 on main it has to call proxy_create_command_queue_xbox as well, or slot 48 regresses to stop 8 whenever a route override sends it through that function. #8072 and #9068 did not merge cleanly on this stack (60 and 23 conflict hunks), so they are not in these numbers.

Outcomes only; no game data. AI-assisted (Claude Code), every run done and checked by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants