[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)
Sharadh Rajaraman via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 21 04:25:52 PDT 2026
sharadhr wrote:
I think the spirit of this MR is useful, allowing `clang --sysroot` on any platform to target `{arch}-pc-windows-msvc`.
However, I agree with @zmodem when he says this:
> This is about using clang with MSVC/Win SDK turned into a Unix-style sysroot
@trcrsired, I don't think it was said that 'cross-compilation is a narrow scenario', instead it was 'making the Windows SDK and MSVC STL into a Unix-like sysroot' is a narrow scenario, which is broadly true.
Shoehorning the Windows SDK and MSVC STL into a Unix-like layout is, in my opinion, too much to ask of the user. We _can_ support this scenario, I won't say no either, but I believe the proper way is to get Clang to accept the layout as-is from the [Build Tools installer](https://aka.ms/vs/stable/vs_BuildTools.exe) (for example). Surely `clang-cl` already has all this machinery, and it is a matter of wiring up the discovered paths to clang++, with case-insensitive handling on case-sensitive filesystems.
The most obvious, first-party way to set up an MSVC ABI + MSVC STL cross-compile environment on Unix-like environments would be to use the above installer on Windows itself or maybe WINE and install it to a case-insensitive FS, mount that filesystem on the Unix-like host, and then write `clang --sysroot=...`. If you are running `clang` on your Android phone, this would entail copy-pasting the Windows SDK and MSVC STL into an SD card, loading it up, and then writing `clang --sysroot=/sdcard/VC/...` or something similar.
I'm not sure this functionality is present in the current PR, which is what I discussed in the first place. There is a lot of demand for this setup, I agree, but asking the user to do this extra work is not very ergonomic (and now that the links to the external GitHub page and scripts are gone, is less discoverable as well).
https://github.com/llvm/llvm-project/pull/96417
More information about the cfe-commits
mailing list