Skip to content

Add Linux-to-Windows-MSVC CMake cross-build toolchain#1292

Draft
MarijnS95 wants to merge 1 commit into
llvm:mainfrom
Traverse-Research:windows-msvc-cross-toolchain
Draft

Add Linux-to-Windows-MSVC CMake cross-build toolchain#1292
MarijnS95 wants to merge 1 commit into
llvm:mainfrom
Traverse-Research:windows-msvc-cross-toolchain

Conversation

@MarijnS95

Copy link
Copy Markdown
Collaborator

Picking up the "easy yes" from #1280: an in-tree CMake toolchain file + docs for Linux→Windows-MSVC cross-compilation, no lit changes.

What's in scope

  • cmake/toolchains/windows-msvc.cmake — clang + lld-link cross-toolchain that's agnostic about how the Windows SDK / CRT are acquired. Callers point at their tree via four WINDOWS_… cache or environment variables; the file's header comment maps each variable to the corresponding subdirectory under xwin's, msvc-wine's, and EWDK's layouts.
  • docs/cross-build.md — two-stage configure recipe (host LLVM + cross OffloadTest), SDK acquisition options (xwin, msvc-wine, EWDK, hand-copy), the ninja check-hlsl-d3d12 workflow, and the gotchas I hit (-Xclang -nostdsysteminc vs. -nostdinc, find_package(Vulkan) shadow, missing debug CRT, libpng _mm_* undefined symbols).

What's not in scope

  • No lit changes. With binfmt_misc registered for .exe on the host (most distros' wine-binfmt package does this), ninja check-hlsl-d3d12 from the cross-build directory works as-is — add_offloadtest_lit_suite resolves %offloader to $<TARGET_FILE:offloader> which is the cross-built .exe, and Wine takes over transparently. Hosts that don't have binfmt registered need an in-tree launcher hook, which the docs flag but don't introduce here.
  • No CI. Per the issue, this lands as a contributor-iteration aid first; the support-tier discussion at wg-hlsl can decide if/where it slots into CI.md later.

Verification

  • Configured + built a minimal hello.exe against the new toolchain (xwin layout); runs under Wine via binfmt.
  • Existing local cross-build of offloader.exe via this toolchain runs against vkd3d-proton on an NVIDIA RTX 3060 — same setup I've been using to verify the inline-RT bring-up PRs this past week.

cc @llvm-beanz for the original issue thread.

Lets non-Windows hosts build offloader.exe (and any other target in the
project) against the x86_64 Windows MSVC ABI using clang + lld-link.
Combined with binfmt_misc + Wine + vkd3d-proton, contributors on Linux
can iterate on the D3D12 backend without dual-booting or a Windows VM:
once binfmt is registered for .exe, `ninja check-hlsl-d3d12` from the
cross-build directory invokes the cross-built offloader.exe through Wine
transparently — no in-tree lit changes needed.

The toolchain is agnostic about how the Windows SDK / CRT are acquired:
xwin, msvc-wine, EWDK, and a hand-copy from a Visual Studio install all
work. Callers point at their tree via four `WINDOWS_…` cache or
environment variables; the toolchain file's header comment maps each
variable to the corresponding subdirectory in the common SDK-source
layouts.

docs/cross-build.md captures the two-stage configure recipe, the SDK
acquisition options, the lit invocation flow, and the gotchas I hit
while bringing this up locally.

Refs: llvm#1280

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MarijnS95 MarijnS95 requested review from EmilioLaiso, llvm-beanz and manon-traverse and removed request for EmilioLaiso and manon-traverse June 5, 2026 11:52
@MarijnS95 MarijnS95 linked an issue Jun 5, 2026 that may be closed by this pull request
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.

RFC: Linux→Windows cross-build + Wine lit suite for offloader

1 participant