Linux: build the runtime in a container and run it under Wine (tools/linux) #52

Closed
github-bot wants to merge 1 commit from gh-pr/52/head into gh-pr/52/base
Owner

@⁠realkodr on GitHub · 2026-11-21 21:34 UTC · original
realkodr:linux/wine → main · +36 −1 · 2 files · 92 commits · closed without merging

Library / area: build tooling (new tools/linux/), xmem / xbthunk / compat-common (three imports looked up at run time), tombox-xshader (four Windows-only programs gated), xreplay test harness

Exports changed (exports.txt rows): none

Source of the behaviour: no console behaviour is added or changed. Which imports Wine lacks comes from Wine's own export lists (dlls/*/*.spec at tag wine-11.21).

What this is

A way to build the runtime and run its tests on Linux, without a Windows machine. A container cross-compiles for x86_64-pc-windows-msvc with LLVM's MSVC-compatible tools and runs the results under Wine, with vkd3d-proton translating Direct3D 12 to Vulkan.

docker build -t tombox-linux --build-arg UID=$(id -u) --build-arg GID=$(id -g) tools/linux
tools/linux/run.sh tools/linux/setup-sdk.sh --accept-license
tools/linux/run.sh cargo build -p xhost -p xmem -p d3d12_xs ...
tools/linux/run.sh cargo test -p tombox-xshader --lib --test opcodes --test synthetic

tools/linux/README.txt has the details. Four commits, each usable on its own:

  1. tools/linux/: the container, the SDK set-up script, the runner, and msvc-lib.py. The image holds no Microsoft files: the Windows SDK and CRT libraries are fetched by setup-sdk.sh with xwin, into a cache outside the repository, and only after --accept-license. The test harness (xreplay/src/d3d.rs) falls back from feature level 12_1 to lower levels, because vkd3d-proton reports less than 12_0 for Mesa's llvmpipe.
  2. tombox-xshader: xprecompile and the fma_bench / fma_gpu_diff / compile_bench examples import Windows-only modules (dxc, shader_cache, fma_probe) unconditionally, so cargo test -p tombox-xshader does not compile on a Linux or macOS host. They now follow xpso: cfg(windows) for the real program, a stub main elsewhere.
  3. Three imports Wine lacks: ntdll!NtOpenPartition, ntdll!NtManagePartition and iphlpapi!GetNetworkConnectivityHint. Wine loads a missing import as a stub that aborts the process when called, so xhost died in xmem right after loading the DLLs. They are now resolved with GetProcAddress on first use, and when absent the caller takes the failure path it already had (partition "not openable", no connectivity hint). On Windows the functions are found and called as before.
  4. NVIDIA (untested): run.sh passes an NVIDIA GPU into the container through the NVIDIA Container Toolkit (--gpus all, all driver capabilities) when the host has one. I have no NVIDIA machine, so this is written from the toolkit's documentation and has not been run. TOMBOX_LINUX_GPU=dri|nvidia|none overrides the detection. Hosts without nvidia-smi behave as before.

The lib.exe stand-in

Fourteen build scripts run lib.exe /DEF:x.def /OUT:x.lib and link the x.exp it leaves behind. llvm-lib writes no .exp. msvc-lib.py turns each row of the .def into an /EXPORT: directive and compiles them into an object file of that name, which lld-link reads like directives on the command line. No build script changes. The container puts it on PATH as lib.exe.

Results

Measured at 1159c96; rebased since onto 838f43f, where the build, the xhost run and the tombox-xshader unit tests were repeated with the same results (lib is now 25 under Wine and 15 natively) on an Intel i7-1165G7 (Iris Xe), Mesa 26.2.7, Wine 11.21, vkd3d-proton 3.1.

Check Result
Build the eight default runtime DLLs and xhost.exe from a clean checkout builds
xhost --no-epic under Wine, before commit 3 all eight DLLs load, then Wine aborts at NtOpenPartition
xhost --no-epic under Wine, with commit 3 runs to its summary: 10 pass, 2 fail, 2 skip
cargo test -p tombox-xshader --lib --test opcodes --test synthetic under Wine 17 / 22 / 9 pass, DXC compiling under Wine
The same natively on Linux (commit 2) 12 / 22 / 9 pass
cargo test -p xbthunk under Wine 23 pass
cargo test -p xmem -- --test-threads=1 under Wine 32 pass, 2 fail (was an abort after 20 tests)
tombox-xshader --test exec on the Iris Xe 51 pass, 19 fail

The two xhost failures are the built-in online backend, which needs the private backend_data at build time. The skips need Gaming Services.

What does not work

  • No title has been run this way. This gets the runtime built, loaded and tested, nothing more.
  • 64-bit floats. vkd3d-proton refuses shaders that use them on Intel (no shaderFloat64) and on llvmpipe. The translator's exact v_fma_f32 path and the f64 instructions use them. That is 13 of the 19 exec failures. Of the rest, 2 need a wider wave than the device has and 4 are wrong results (vop2_basic, vopc_f16, scalar_smem_loads, ds_gds_append_consume). I have no Windows baseline at this commit to say which of those four are Wine-specific.
  • xmem: the two failing tests (stats::tests::working_set_versions_fill_their_sizes, transfer_memory_follows_console_flow) read working set figures that Wine reports as zero. Run in parallel, the xmem tests hang under Wine; one at a time they finish.
  • Mesh shaders: Intel Xe-LP has none, and vkd3d-proton disables them on llvmpipe.
  • Commit 3 was not run on native Windows.

Overlap

Draft #12 mentions checking DLL loads under Wine but adds no Linux tooling. Its cfg gates for xscan and opcodes are already on main; commit 2 covers the four programs added since (compile_bench arrived with e843998 and broke the native build again).

  • cargo test -p <crate> results are in the table above, including the failures
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

**@⁠realkodr** on GitHub · 2026-11-21 21:34 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/52) `realkodr:linux/wine` → `main` · +36 −1 · 2 files · 92 commits · closed without merging **Library / area:** build tooling (new `tools/linux/`), xmem / xbthunk / compat-common (three imports looked up at run time), tombox-xshader (four Windows-only programs gated), xreplay test harness **Exports changed (exports.txt rows):** none **Source of the behaviour:** no console behaviour is added or changed. Which imports Wine lacks comes from Wine's own export lists (`dlls/*/*.spec` at tag `wine-11.21`). ### What this is A way to build the runtime and run its tests on Linux, without a Windows machine. A container cross-compiles for `x86_64-pc-windows-msvc` with LLVM's MSVC-compatible tools and runs the results under Wine, with vkd3d-proton translating Direct3D 12 to Vulkan. ``` docker build -t tombox-linux --build-arg UID=$(id -u) --build-arg GID=$(id -g) tools/linux tools/linux/run.sh tools/linux/setup-sdk.sh --accept-license tools/linux/run.sh cargo build -p xhost -p xmem -p d3d12_xs ... tools/linux/run.sh cargo test -p tombox-xshader --lib --test opcodes --test synthetic ``` `tools/linux/README.txt` has the details. Four commits, each usable on its own: 1. **`tools/linux/`**: the container, the SDK set-up script, the runner, and `msvc-lib.py`. The image holds no Microsoft files: the Windows SDK and CRT libraries are fetched by `setup-sdk.sh` with xwin, into a cache outside the repository, and only after `--accept-license`. The test harness (`xreplay/src/d3d.rs`) falls back from feature level 12_1 to lower levels, because vkd3d-proton reports less than 12_0 for Mesa's llvmpipe. 2. **tombox-xshader**: `xprecompile` and the `fma_bench` / `fma_gpu_diff` / `compile_bench` examples import Windows-only modules (`dxc`, `shader_cache`, `fma_probe`) unconditionally, so `cargo test -p tombox-xshader` does not compile on a Linux or macOS host. They now follow `xpso`: cfg(windows) for the real program, a stub `main` elsewhere. 3. **Three imports Wine lacks**: `ntdll!NtOpenPartition`, `ntdll!NtManagePartition` and `iphlpapi!GetNetworkConnectivityHint`. Wine loads a missing import as a stub that aborts the process when called, so xhost died in xmem right after loading the DLLs. They are now resolved with `GetProcAddress` on first use, and when absent the caller takes the failure path it already had (partition "not openable", no connectivity hint). On Windows the functions are found and called as before. 4. **NVIDIA (untested)**: `run.sh` passes an NVIDIA GPU into the container through the NVIDIA Container Toolkit (`--gpus all`, all driver capabilities) when the host has one. I have no NVIDIA machine, so this is written from the toolkit's documentation and has not been run. `TOMBOX_LINUX_GPU=dri|nvidia|none` overrides the detection. Hosts without `nvidia-smi` behave as before. ### The lib.exe stand-in Fourteen build scripts run `lib.exe /DEF:x.def /OUT:x.lib` and link the `x.exp` it leaves behind. `llvm-lib` writes no `.exp`. `msvc-lib.py` turns each row of the `.def` into an `/EXPORT:` directive and compiles them into an object file of that name, which `lld-link` reads like directives on the command line. No build script changes. The container puts it on PATH as `lib.exe`. ### Results Measured at `1159c96`; rebased since onto `838f43f`, where the build, the xhost run and the tombox-xshader unit tests were repeated with the same results (lib is now 25 under Wine and 15 natively) on an Intel i7-1165G7 (Iris Xe), Mesa 26.2.7, Wine 11.21, vkd3d-proton 3.1. | Check | Result | |---|---| | Build the eight default runtime DLLs and `xhost.exe` from a clean checkout | builds | | `xhost --no-epic` under Wine, before commit 3 | all eight DLLs load, then Wine aborts at `NtOpenPartition` | | `xhost --no-epic` under Wine, with commit 3 | runs to its summary: 10 pass, 2 fail, 2 skip | | `cargo test -p tombox-xshader --lib --test opcodes --test synthetic` under Wine | 17 / 22 / 9 pass, DXC compiling under Wine | | The same natively on Linux (commit 2) | 12 / 22 / 9 pass | | `cargo test -p xbthunk` under Wine | 23 pass | | `cargo test -p xmem -- --test-threads=1` under Wine | 32 pass, 2 fail (was an abort after 20 tests) | | `tombox-xshader --test exec` on the Iris Xe | 51 pass, 19 fail | The two xhost failures are the built-in online backend, which needs the private `backend_data` at build time. The skips need Gaming Services. ### What does not work - **No title has been run this way.** This gets the runtime built, loaded and tested, nothing more. - **64-bit floats.** vkd3d-proton refuses shaders that use them on Intel (no `shaderFloat64`) and on llvmpipe. The translator's exact `v_fma_f32` path and the f64 instructions use them. That is 13 of the 19 `exec` failures. Of the rest, 2 need a wider wave than the device has and 4 are wrong results (`vop2_basic`, `vopc_f16`, `scalar_smem_loads`, `ds_gds_append_consume`). I have no Windows baseline at this commit to say which of those four are Wine-specific. - **xmem**: the two failing tests (`stats::tests::working_set_versions_fill_their_sizes`, `transfer_memory_follows_console_flow`) read working set figures that Wine reports as zero. Run in parallel, the xmem tests hang under Wine; one at a time they finish. - **Mesh shaders**: Intel Xe-LP has none, and vkd3d-proton disables them on llvmpipe. - Commit 3 was not run on native Windows. ### Overlap Draft #12 mentions checking DLL loads under Wine but adds no Linux tooling. Its cfg gates for `xscan` and `opcodes` are already on `main`; commit 2 covers the four programs added since (`compile_bench` arrived with `e843998` and broke the native build again). - [x] `cargo test -p <crate>` results are in the table above, including the failures - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Mesa's drivers only need /dev/dri. NVIDIA's proprietary driver needs
the NVIDIA Container Toolkit to inject its libraries and Vulkan ICD.
When the host has nvidia-smi and the engine knows the nvidia runtime,
run.sh now adds `--gpus all` (podman: the CDI device) and asks for all
driver capabilities. TOMBOX_LINUX_GPU=dri|nvidia|none overrides the
detection.

Not run on an NVIDIA machine: written from the toolkit's
documentation. Checked here: hosts without nvidia-smi behave as before
(three Vulkan devices visible), `none` passes no device, a bad value
is rejected, and the nvidia branch produces the intended arguments.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:08:33 +00:00
github-bot closed this pull request 2026-11-26 06:08:33 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:12 UTC · original

Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please split this: the Rust part (runtime lookup of GetNetworkConnectivityHint/NtOpenPartition/NtManagePartition, non-Windows example stubs) as its own PR. The container tooling that downloads SDKs needs a separate licence/policy decision. Remove the absolute /home paths and comment lines. To resubmit: git fetch this repo, branch from the current main, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/52#issuecomment-7079648038) Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please split this: the Rust part (runtime lookup of GetNetworkConnectivityHint/NtOpenPartition/NtManagePartition, non-Windows example stubs) as its own PR. The container tooling that downloads SDKs needs a separate licence/policy decision. Remove the absolute /home paths and comment lines. To resubmit: `git fetch` this repo, branch from the current `main`, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.