[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 27 00:05:03 PDT 2025


trcrsired wrote:

> This is going badly off-topic.
> 
> Supporting `--sysroot` with plain Clang is alright and good. Supporting libc++ is also good.
> 
> But both need to automatically find a **normally-installed** MSVC SDK without a GNU-like refactor, and yes, that includes things like `Program Files(x86)`. So in other words it needs to work similar to how `/winsysroot` currently does.
> 
> Ideally the argument should simply change the priority of the sysroot lookup (which is what `/winsysroot` does anyway) instead of imposing a full GNU-style filesystem reorganisation. To address @Andarwinux's and @YexuanXiao's concerns it could also directly invoke the linker through the driver while simultaneously forwarding the sysroot information.
> 
> Then we can special-case `-stdlib=libc++` to internally set up the include and library paths to firstly sysroot if provided and then falling back to Clang's own libc++, instead of having the user do it manually [as linked above](https://github.com/llvm/llvm-project/issues/53004#issuecomment-1207167610). Since libc++ is distributed in GNU-style layout, this needs to use the resource directory to find the correct path for the headers and libraries.
> 
> This is exactly what @zmodem [first asked](https://github.com/llvm/llvm-project/pull/96417?notification_referrer_id=NT_kwDOADlIYLMxMTIwODI4MjkyMTozNzU0MDgw#issuecomment-2200709561), and I concur.

i think a better solution would be making winsysroot to have different semantics with sysroot so that user and build can choose whatever they need

https://github.com/llvm/llvm-project/pull/96417


More information about the cfe-commits mailing list