[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 30 13:57:17 PDT 2025
rnk wrote:
> We don’t have to do anything in practice, [Xwin](https://github.com/Jake-Shadle/xwin) is already such a « script » and it already creates symlinks for all the casing issues and supports the /winsysroot layout if asked.
>
> What is the advantage of using clang (not CL)? We’ve been telling users for years to not do that? —sysroot could just use the /winsysroot layout.
Well, we built `clang-cl` because we needed a migration path for users with MSVC-based build systems, and we felt it was worth smoothing over that migration path. For a long time, that's where the energy in our community was, so it was the recommended well-lit path, but things can change. Supposedly Mozilla only ever used the `clang` driver through that entire migration.
Clearly, just as their are folks porting MSVC codebases to Linux, there will be users porting autotools builds to Windows, and I don't see any reason to value their use case less than that of the MSVC-migrating users. So, that's the use case for using the `clang` driver to target Windows, and it seems valid to me.
`--sysroot` and `(/|--)winsysroot` are very different in how they function. I don't think aliasing them will help users. I think it would recreate the confusion they've had with `/Wall` / `-Weverything`.
---
To try to steelman the objections I'm hearing, it's basically that having two ways to do things leads to confusion and makes it hard to find the supported, well-lit-paths for cross-compilation. When you have too many options, you get unopinionated guides that overwhelm users with choice and confusion. Recent examples that come to mind for me are the Arch wiki installation guide and the LLVM Getting Started page.
I acknowledge these are real downsides, but I think the value of a `--sysroot` flag that functions consistently across platforms outweighs the potential confusion over the best approach.
If I had to pick a best approach to recommend, I like the idea of implementing case-insensitive header search, and wiring that into a `clang` driver `--winsysroot` flag, so it's just unpack and go, but I don't expect everyone will agree, and that's OK, so in short, I think we should merge the PR.
https://github.com/llvm/llvm-project/pull/96417
More information about the cfe-commits
mailing list