Add Linux-to-Windows-MSVC CMake cross-build toolchain#1292
Draft
MarijnS95 wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fourWINDOWS_…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), theninja check-hlsl-d3d12workflow, and the gotchas I hit (-Xclang -nostdsystemincvs.-nostdinc,find_package(Vulkan)shadow, missing debug CRT, libpng_mm_*undefined symbols).What's not in scope
binfmt_miscregistered for.exeon the host (most distros'wine-binfmtpackage does this),ninja check-hlsl-d3d12from the cross-build directory works as-is —add_offloadtest_lit_suiteresolves%offloaderto$<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.CI.mdlater.Verification
hello.exeagainst the new toolchain (xwin layout); runs under Wine via binfmt.offloader.exevia 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.