Skip to content

Build on Linux: cross-compile for MSVC, run under Wine - #195

Closed
Naitrate wants to merge 1 commit into
Marvisak:mainfrom
Naitrate:linux-wine-build
Closed

Naitrate wants to merge 1 commit into
Marvisak:mainfrom
Naitrate:linux-wine-build

Conversation

@Naitrate

Copy link
Copy Markdown

What

VIctory can now be built on Linux and run under Wine. It is still a Windows program: it is cross-compiled for x86_64-pc-windows-msvc with cargo-xwin and run with VKD3D-Proton and DXVK.

  • README: a "Building and running on Linux" section covering the toolchain (rustup, cargo-xwin, clang-cl, lld-link, llvm-lib), a Wine prefix with VKD3D-Proton and DXVK, running the title, and which tests fail under Wine.
  • shell.nix: the toolchain for Nix users, plus WINEPREFIX, DLL overrides, the test runner, and the VKD3D-Proton/DXVK shader caches kept in the prefix.
  • Asset policy: allows .nix files.
  • Wine's missing network functions: Wine's ws2_32.dll lacks WSAConnectByList and GetAddrInfoExA, and its winhttp.dll lacks WinHttpGetProxySettingsEx. Forwarding to them panicked (the host lacks ...).
    • WSAConnectByList now tries each vetted candidate in turn with connect. It blocks, and the timeout isn't honoured.
    • GetAddrInfoExA answers WSAHOST_NOT_FOUND, as it already does for a blocked name.
    • WinHttpGetProxySettingsEx never calls the host's function. The export test exempts all three, and a new test covers the connect fallback.
  • view_format is #[cfg(windows)], like host_resource, its only callee. Before this, cargo test --workspace failed on any non-Windows host with cannot find function host_resource.
  • .githooks/pre-commit is executable (100755). Git ignored it on Linux even after cargo xtask install-hooks reported it as installed.

Why

Wine's own D3D12 rejects the shader model 6.6 query (E_INVALIDARG), so the title shows only a white window. VKD3D-Proton reports SM 6.6–6.8 and runs the translated shaders.

Testing

Tested on NixOS with Wine 11.21 (Staging), VKD3D-Proton 3.0.1, DXVK 3.1.1 and an RTX 5060 Ti:

  • cargo xwin build --release --target x86_64-pc-windows-msvc builds.
  • cargo xwin test -p victory-hle under Wine passes all 87 tests, including only_loopback_is_reachable, which panicked before.
  • The full workspace under Wine passes 259 tests and fails 6:
    • Environment: load_probe and repository_passes_policy (they start cargo and git from inside Wine), and stub_pipeline_is_created (VKD3D-Proton doesn't check DXIL hashes).
    • Not yet explained: buffer_data_reaches_the_host_texture, argument_clamp_builds and a_rejected_blob_gives_an_empty_library fail under VKD3D-Proton. The README lists them.
  • cargo xtask policy and the xtask tests pass natively.
  • The title starts, plays its first screens at 30 fps, and stops after about a minute on one of its own assertions. I'm investigating that separately; this PR doesn't change it.

Not tested on Windows. Every Rust change is a no-op there except the WSAConnectByList and GetAddrInfoExA fallbacks, which only run when the host lacks those exports.

🤖 Generated with Claude Code

VIctory stays a Windows program; on Linux it is cross-compiled for
x86_64-pc-windows-msvc with cargo-xwin and run under Wine with
VKD3D-Proton and DXVK. The README gains the steps; shell.nix gives Nix
users the toolchain (rustup, cargo-xwin, clang-cl, lld-link, llvm-lib)
and a Wine prefix of VIctory's own. The asset policy allows .nix files.

Wine's ws2_32 lacks WSAConnectByList and GetAddrInfoExA, and its winhttp
WinHttpGetProxySettingsEx. Forwarding to them panicked; now
WSAConnectByList tries each vetted candidate with connect (blocking, the
timeout not kept) and GetAddrInfoExA answers WSAHOST_NOT_FOUND, as for a
blocked name. The export test exempts the three.

view_format is Windows-only like host_resource, its only callee, so the
workspace's host-side crates build natively again.

The pre-commit hook is executable: git skipped it on Linux, where
`cargo xtask install-hooks` said it was installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ligmaSec

Copy link
Copy Markdown

duplicate of #191

@DaviTostes

Copy link
Copy Markdown

Tested 4b38ecf under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build of victory-hle: 87 passed, 0 failed, 0 ignored.

No game data used.

@SkippySteve SkippySteve left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked this out on a second Linux host (Arch, UMU-Proton 11.0-2e, whose prefix ships vkd3d-proton and DXVK) and re-ran the tests. I did not launch the title; this covers the crate tests and the docs only. I could not test on Windows.

Results

Cross-build: cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-run builds all 13 test binaries cleanly at 4b38ecf.

victory-hle under Proton's wine, at 4b38ecf compared with main (d2a4bae):

main this PR
victory-hle unit tests 85 passed, 1 failed (only_loopback_is_reachable: ws2_32.dll lacks WSAConnectByList) 87 passed, 0 failed (including the new connect_by_list_falls_back_to_connect)
no_dll_planting 1/1 1/1

So the missing-export panic happens on Proton's Wine too, not only on Wine Staging 11.21, and this PR fixes it.

Full workspace under wine with WINEDLLOVERRIDES="d3d12,d3d12core,dxgi,d3d11=n,b": 259 passed and 6 failed. These are the same numbers and the same six tests as in the PR description:

  • Caused by the environment: load_probe (running cargo: Invalid handle), repository_passes_policy (running git) and stub_pipeline_is_created (digest [00 …] accepted).
  • Not yet explained, failing the same way here: buffer_data_reaches_the_host_texture (row 0 reads back all zeros), argument_clamp_builds (clamp().is_some() fails) and a_rejected_blob_gives_an_empty_library. Those three also fail on a second vendor/driver stack, so the cause is probably in vkd3d-proton, not this PR.

For contrast, without the overrides (Wine's builtin d3d12) those four GPU tests pass. Instead, 7 valu_tests fail with neither hardware nor WARP SM 6.6 device available. That supports the README's point that Wine's own D3D12 is not enough.

Native Linux:

  • The #[cfg(windows)] on view_format works. On main, cargo test -p victory-gpu stops at E0425 cannot find function host_resource. On this branch it builds and passes 23 tests.
  • cargo xtask policy passes (152 files). .githooks/pre-commit is now 100755 in the index.

Notes (none of them blocking)

  1. The vkd3d cache can break the policy check, and not only for Nix users. I ran the tests from the repository root without shell.nix, and vkd3d-proton left a vkd3d-proton.cache there. After that, cargo xtask policy failed with binary content (NUL bytes). shell.nix already handles this. The README's plain-Wine steps could add the same two lines (export VKD3D_SHADER_CACHE_PATH=… DXVK_STATE_CACHE_PATH=…) so that people who don't use Nix don't hit it.
  2. Wording of the "cargo test --workspace on non-Windows" claim. The gpu fix works. However, a native cargo test --workspace still stops in victory-hle (windows_sys, xmem, lifecycle, files are not gated; that is #90/#112). Saying "victory-gpu now builds on non-Windows hosts" would be more accurate.
  3. connect_each (minor, and only reachable with loopback candidates). If the socket is non-blocking, connect returns WSAEWOULDBLOCK, and the code then treats that candidate as failed. The real WSAConnectByList blocks regardless of the socket's mode. The doc comment already says "Blocking; the timeout is not kept". It could also mention that a non-blocking socket will report failure here. Retrying connect on the same socket after WSAECONNREFUSED is allowed by the Winsock docs, so trying the candidates in turn is fine.

Overlap with #149

#149 (docs/linux-proton.md plus a one-line README pointer) covers host tests, the umu-run/Proton flow, logging through cmd.exe /c, and the list of open Wine PRs. This PR covers the code fixes, shell.nix, and a plain-Wine section in the README. They mostly complement each other. My suggested merge order is #195 first. #149 would then be rebased on top of it to:

  • drop its "main does not build on Linux: host_resource" paragraph, which this PR fixes;
  • link to this README section for the plain-Wine and Nix setup instead of repeating it;
  • keep only the Proton/umu specifics.

If it's useful, this section could later link to docs/linux-proton.md for Proton users, but that can be done in #149.

Approving: the code changes are small, are gated so that they only take effect when the host lacks the export, and I reproduced every test number in the description.

@Naitrate

Copy link
Copy Markdown
Author

Closing as a duplicate of #191, which covers the Linux build. The parts #191 doesn't include (Wine fallbacks for missing ws2_32 exports, the view_format cfg fix and the pre-commit hook's executable bit) will follow in a separate, smaller PR that works with either toolchain.

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