Support Linux-to-Windows MSVC cross-compilation
Description
I'm trying to cross-compile a Tauri application from Linux (Debian Trixie / Docker) to Windows MSVC using cargo-xwin, with LuaJIT enabled through mlua's vendored feature.
The build currently fails in luajit-src:
thread 'main' panicked at luajit-src-210.7.4+c6ffc14/src/lib.rs:284:68:
failed to find cl
The problem appears to be that try_build() unconditionally selects build_msvc() whenever the target contains msvc:
if target.contains("msvc") {
return self.build_msvc();
}
build_msvc() then calls:
let cl = cc::windows_registry::find_tool(target, "cl.exe")
.expect("failed to find cl");
This relies on Windows registry-based MSVC compiler discovery, which isn't available when building from Linux.
Installing clang-cl and exposing it as cl through PATH doesn't help because find_tool() uses Windows registry discovery rather than PATH lookup.
Environment
Host: Linux (Debian Trixie)
Build environment: Docker (rust:1.99.1-trixie)
Target: x86_64-pc-windows-msvc
Cross-compilation: cargo-xwin 0.23.1
Rust dependency: mlua 0.12.0
LuaJIT dependency: luajit-src 210.7.4+c6ffc14
LuaJIT features: vendored, luajit
Expected behavior
It would be great if luajit-src supported cross-compiling LuaJIT from Linux to Windows MSVC without requiring a native Windows build environment.
Potentially, this could be implemented by providing a Linux-hosted MSVC-compatible build path using Clang/LLVM and the Windows SDK.
The existing Unix Makefile build path already has some Windows cross-compilation support through TARGET_SYS=Windows, although the host tools and MSVC-specific output requirements would also need to be handled.