Skip to content

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

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
JohnConnorNPC:docs/linux-clang-cl-wine-startup
Nov 24, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
JohnConnorNPC:docs/linux-clang-cl-wine-startup

Conversation

@JohnConnorNPC

Copy link
Copy Markdown
Contributor

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.

…r under Wine

Add two sections to the non-Windows host guide: a clang-cl, lld-link and
xwin toolchain file that builds the startup stand-ins on Linux, with the
four differences from an MSVC build (/EHa for the __try memory probes,
bracket depth, the OneCore.lib spelling, DXC), and what a startup run
under Wine with vkd3d-proton needed.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

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.

Review: an SDK or checkout directory with spaces split the /imsvc and
/libpath arguments. The paths are now quoted inside the flag strings.
@JohnConnorNPC

Copy link
Copy Markdown
Contributor Author

@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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@R0Y00
R0Y00 merged commit dde8afd into R0Y00:main Nov 24, 2026
5 checks passed
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.

4 participants