docs: cross-compiling with clang-cl and xwin, and the startup debugger under Wine #1294

Merged
JohnConnorNPC merged 4 commits from upstream-pr/1301 into main 2026-11-24 08:37:54 +00:00
JohnConnorNPC commented 2026-11-24 07:20:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T07:20:32Z.


Refs #870.

What this adds

Two sections in docs/non-windows-hosts.md, next to the existing msvc-wine one. Docs only.

Cross-compile with clang-cl and an xwin SDK. A toolchain file and the commands that build the eight startup stand-ins on Linux with clang-cl, lld-link and an xwin splat, plus the four things that differ from an MSVC build:

  • /EHa is required and must come after CMake's default /EHsc. The stand-ins probe title memory inside __try (src/startup_stubs/local_log.h). With /EHsc, clang-cl does not catch the access violation of a load written directly in the __try body, and the first probe of an unreadable address ends the process inside d3d12_xs.dll. This one cost the most time to find.
  • -fbracket-depth, for the 512-argument fold expression in d3d12_xs_device.cpp.
  • OneCore.lib versus the splat's onecore.lib on a case-sensitive file system.
  • A Linux dxc to satisfy find_program.

It is presented the way the msvc-wine section is: a real compiler and the real SDK, usable as a compile check, with MSVC and Windows CI as the reference. It does not stub cl, MASM, D3D12 or WARP.

Startup debugger under Wine. What a debug_launch.py run on those stand-ins needed under Wine with vkd3d-proton: the Windows build of CPython (and why the embeddable package needs its ._pth file removed), which D3D12 DLLs go into the prefix, mapping a package drive letter, FXC under Wine, where a desktop xgameruntime.dll comes from, Wine's section backing on a small tmpfs, and two open differences (tagged descriptor handles, window order). It also records how slow one section per 64 KiB page is under Wine.

Evidence

Commit: the head of this branch, on main at 93cb6a2a.

  • The toolchain file in the doc is the one I tested: a fresh configure and build of the eight stand-in targets from this branch's checkout produced all eight DLLs, with /EHa as the only exception flag on the compile lines. Host: Debian 13, clang-cl 19.1.7, SDK 10.0.26100 from xwin splat.
  • The /EHa statement is measured both ways on that host: built with /EHsc, a startup run stopped at an unhandled access violation in the stand-in's readable-memory probe; rebuilt with /EHa last, the same run continued.
  • The Wine items are from startup runs with Proton Experimental's Wine 11.0, vkd3d-proton 2576c0b4 and NVIDIA driver 550.163.01, with one console executable, offline. Each bullet is something that stopped or changed a run there.
  • python -B tests/docs_links_check.py: pass (290 links). python -B tests/bidi_controls_check.py: pass. git diff --check: clean.

Not covered

  • The whole tree was not built with clang-cl: only the stand-ins and the device-free test executables. The MASM fixtures and the HLSL fixtures were not attempted.
  • Nothing here is a Windows result, and the doc says so where it matters.
  • The descriptor-handle and window-order items are described as open differences; this PR does not change code for them.

The page-mapping cost mentioned at the end is the subject of a separate code PR I am preparing. #1251 (mapping a package drive letter in the launcher) would replace the manual dosdevices step for hosts where it applies.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576741950 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1301). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-24T07:20:32Z. --- Refs #870. ## What this adds Two sections in `docs/non-windows-hosts.md`, next to the existing msvc-wine one. Docs only. **Cross-compile with clang-cl and an xwin SDK.** A toolchain file and the commands that build the eight startup stand-ins on Linux with clang-cl, lld-link and an `xwin splat`, plus the four things that differ from an MSVC build: - `/EHa` is required and must come after CMake's default `/EHsc`. The stand-ins probe title memory inside `__try` (`src/startup_stubs/local_log.h`). With `/EHsc`, clang-cl does not catch the access violation of a load written directly in the `__try` body, and the first probe of an unreadable address ends the process inside `d3d12_xs.dll`. This one cost the most time to find. - `-fbracket-depth`, for the 512-argument fold expression in `d3d12_xs_device.cpp`. - `OneCore.lib` versus the splat's `onecore.lib` on a case-sensitive file system. - A Linux `dxc` to satisfy `find_program`. It is presented the way the msvc-wine section is: a real compiler and the real SDK, usable as a compile check, with MSVC and Windows CI as the reference. It does not stub `cl`, MASM, D3D12 or WARP. **Startup debugger under Wine.** What a `debug_launch.py` run on those stand-ins needed under Wine with vkd3d-proton: the Windows build of CPython (and why the embeddable package needs its `._pth` file removed), which D3D12 DLLs go into the prefix, mapping a package drive letter, FXC under Wine, where a desktop `xgameruntime.dll` comes from, Wine's section backing on a small tmpfs, and two open differences (tagged descriptor handles, window order). It also records how slow one section per 64 KiB page is under Wine. ## Evidence Commit: the head of this branch, on `main` at `93cb6a2a`. - The toolchain file in the doc is the one I tested: a fresh configure and build of the eight stand-in targets from this branch's checkout produced all eight DLLs, with `/EHa` as the only exception flag on the compile lines. Host: Debian 13, clang-cl 19.1.7, SDK 10.0.26100 from `xwin splat`. - The `/EHa` statement is measured both ways on that host: built with `/EHsc`, a startup run stopped at an unhandled access violation in the stand-in's readable-memory probe; rebuilt with `/EHa` last, the same run continued. - The Wine items are from startup runs with Proton Experimental's Wine 11.0, vkd3d-proton 2576c0b4 and NVIDIA driver 550.163.01, with one console executable, offline. Each bullet is something that stopped or changed a run there. - `python -B tests/docs_links_check.py`: pass (290 links). `python -B tests/bidi_controls_check.py`: pass. `git diff --check`: clean. ## Not covered - The whole tree was not built with clang-cl: only the stand-ins and the device-free test executables. The MASM fixtures and the HLSL fixtures were not attempted. - Nothing here is a Windows result, and the doc says so where it matters. - The descriptor-handle and window-order items are described as open differences; this PR does not change code for them. ## Related The page-mapping cost mentioned at the end is the subject of a separate code PR I am preparing. #1251 (mapping a package drive letter in the launcher) would replace the manual `dosdevices` step for hosts where it applies.
tedin7 commented 2026-11-24 08:01:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:30:28Z.

Review: COMMENTED


Review at commit 932423c7f2d5489c1de75a5817bc1d8c4f5d1218:

Verification

  • Linux:
    • git diff --check origin/main...HEAD: clean (exit 0)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (16 Markdown files, 290 links)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (1086 tracked files)
  • Windows Server 2025: N/A (docs-only change in docs/non-windows-hosts.md; no C++/test target changes).

Review Notes

  • Clearly documents the clang-cl + xwin cross-compile toolchain (/EHa ordering after /EHsc, -fbracket-depth=2048, OneCore.lib case-sensitivity symlink, and dxc requirement) and explicitly scopes it as a compile check with MSVC/Windows CI remaining the reference.
  • Documents the Wine + vkd3d-proton startup debugger setup and known differences (python312._pth, d3d12/dxgi overrides, XDG_RUNTIME_DIR tmpfs note, descriptor handle tag bits, and section-per-page cost) while keeping title-neutral framing and explicitly noting it is not Windows verification.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035288446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1301#pullrequestreview-6035288446). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T07:30:28Z. **Review:** COMMENTED --- Review at commit `932423c7f2d5489c1de75a5817bc1d8c4f5d1218`: ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: clean (exit 0) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (16 Markdown files, 290 links) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (1086 tracked files) - **Windows Server 2025**: N/A (docs-only change in `docs/non-windows-hosts.md`; no C++/test target changes). ### Review Notes - Clearly documents the `clang-cl` + `xwin` cross-compile toolchain (`/EHa` ordering after `/EHsc`, `-fbracket-depth=2048`, `OneCore.lib` case-sensitivity symlink, and `dxc` requirement) and explicitly scopes it as a compile check with MSVC/Windows CI remaining the reference. - Documents the Wine + `vkd3d-proton` startup debugger setup and known differences (`python312._pth`, `d3d12`/`dxgi` overrides, `XDG_RUNTIME_DIR` tmpfs note, descriptor handle tag bits, and section-per-page cost) while keeping title-neutral framing and explicitly noting it is not Windows verification.
nanyoudegege commented 2026-11-24 08:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by nanyoudegege on 2026-11-24T07:40:11Z.


One small edge case in the cross-build example at 932423c7: the shell quotes -DXWIN="$XWIN" and -DLIBCASE="$PWD/out/libcase", but the toolchain snippet doesn't retain quotes around those paths inside its compiler/linker flag strings. A checkout or SDK directory with spaces can therefore split an argument. CMake documents this requirement for flag fragments.

I checked the resulting flag fragments with a POSIX shell on cloud Linux and synthetic paths: /imsvc /tmp/SDK Files/crt/include /libpath:/tmp/repo with space/out/libcase split into six arguments; quoting the two path operands kept the intended three. I did not run the actual CMake/clang-cl cross-build. Could the sample retain literal quotes inside the CMake strings (e.g. /imsvc \"${XWIN}/crt/include\" and /libpath:\"${LIBCASE}\"), or document the no-spaces constraint if that's the supported route?

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125240754 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1301#issuecomment-7125240754). Originally posted by [nanyoudegege](https://github.com/nanyoudegege) on 2026-11-24T07:40:11Z. --- One small edge case in the cross-build example at `932423c7`: the shell quotes `-DXWIN="$XWIN"` and `-DLIBCASE="$PWD/out/libcase"`, but [the toolchain snippet](https://github.com/JohnConnorNPC/Xbox2Windows/blob/932423c7f2d5489c1de75a5817bc1d8c4f5d1218/docs/non-windows-hosts.md#L252-L258) doesn't retain quotes around those paths inside its compiler/linker flag strings. A checkout or SDK directory with spaces can therefore split an argument. [CMake documents this requirement for flag fragments](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html). I checked the resulting flag fragments with a POSIX shell on cloud Linux and synthetic paths: `/imsvc /tmp/SDK Files/crt/include /libpath:/tmp/repo with space/out/libcase` split into six arguments; quoting the two path operands kept the intended three. I did not run the actual CMake/clang-cl cross-build. Could the sample retain literal quotes inside the CMake strings (e.g. `/imsvc \"${XWIN}/crt/include\"` and `/libpath:\"${LIBCASE}\"`), or document the no-spaces constraint if that's the supported route? AI-assisted.
JohnConnorNPC commented 2026-11-24 08:01:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T07:49:45Z.


@nanyoudegege you're right, thanks. Fixed in 429fb8f7: the toolchain file in the doc now keeps literal quotes around the five /imsvc paths and the four /libpath: arguments inside its flag strings, as the CMake documentation asks for flag fragments.

Checked with the actual cross-build rather than the shell split: I configured and built xmem_shim, startup_stub_chad and d3d12_xs_shim with the quoted file, with the SDK splat, the LIBCASE directory and the build directory each under a directory whose name contains a space (symlinks to the real ones). All three DLLs were produced. Host as in the PR: Debian 13, clang-cl 19.1.7, SDK 10.0.26100.

Not checked: a checkout (source directory) path with spaces, and a path containing a double quote, which the quoting would not survive.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125416893 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1301#issuecomment-7125416893). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-24T07:49:45Z. --- @nanyoudegege you're right, thanks. Fixed in `429fb8f7`: the toolchain file in the doc now keeps literal quotes around the five `/imsvc` paths and the four `/libpath:` arguments inside its flag strings, as the CMake documentation asks for flag fragments. Checked with the actual cross-build rather than the shell split: I configured and built `xmem_shim`, `startup_stub_chad` and `d3d12_xs_shim` with the quoted file, with the SDK splat, the `LIBCASE` directory and the build directory each under a directory whose name contains a space (symlinks to the real ones). All three DLLs were produced. Host as in the PR: Debian 13, clang-cl 19.1.7, SDK 10.0.26100. Not checked: a checkout (source directory) path with spaces, and a path containing a double quote, which the quoting would not survive.
upstream-sync closed this pull request 2026-11-24 09:04:25 +00:00
tedin7 commented 2026-11-24 09:04:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:17:15Z.

Review: COMMENTED


Re-reviewed at commit 3185186ec1f82737af56f1f5e457116be9c12e30 (delta since 932423c7f2d5489c1de75a5817bc1d8c4f5d1218).

Delta Review (docs/non-windows-hosts.md)

  • 429fb8f7 + 3185186e: quotes XWIN and LIBCASE paths inside the clang-cl /imsvc and /libpath: flag strings and explicitly documents which directories with spaces were tested (XWIN, LIBCASE, build directory) versus not tried (source directory). Looks clean and accurate.

Verification (Linux, docs-only)

  • git diff --check origin/main...HEAD: clean
  • python -B tests/docs_links_check.py: passed (16 Markdown files, 291 links)
  • python -B tests/bidi_controls_check.py: passed (1093 files)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035786878 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1301#pullrequestreview-6035786878). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:17:15Z. **Review:** COMMENTED --- Re-reviewed at commit `3185186ec1f82737af56f1f5e457116be9c12e30` (delta since `932423c7f2d5489c1de75a5817bc1d8c4f5d1218`). ### Delta Review (`docs/non-windows-hosts.md`) - `429fb8f7` + `3185186e`: quotes `XWIN` and `LIBCASE` paths inside the `clang-cl` `/imsvc` and `/libpath:` flag strings and explicitly documents which directories with spaces were tested (`XWIN`, `LIBCASE`, build directory) versus not tried (source directory). Looks clean and accurate. ### Verification (Linux, docs-only) - `git diff --check origin/main...HEAD`: clean - `python -B tests/docs_links_check.py`: passed (16 Markdown files, 291 links) - `python -B tests/bidi_controls_check.py`: passed (1093 files)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1294
No description provided.