HomePhabricator

clang-cl: Add /winsdkdir and /winsdkversion flags

Authored by thakis on Jan 26 2021, 12:21 PM.

Description

clang-cl: Add /winsdkdir and /winsdkversion flags

These do for the Windows SDK path what D85998 did for
%VCToolsInstallDir% with /vctoolsdir: Offer a way to set them with an
explicit commandline switch.

With this (and /vctoolsdir), it's possible to compile and link
against hermetic vctools and winsdk directories with:

out/gn/bin/clang-cl win.c -fuse-ld=lld \
    /vctoolsdir path/to/VC/Tools/MSVC/14.26.28801 \
    /winsdkdir path/to/win_sdk

compared to a long list of -imsvc and /link /libpath: flags.

While here:

  • Change the case of the "Include" folder inside the windows sdk from "include" to "Include" to match on-disk case. Since the Windows file system is case-insensitive this isn't a behavior change, it's just a bit cleaner.
  • Add libpath tests to the /vctoolsdir
  • Add a FIXME about reading env vars for win sdk and ucrt sdk if these flags aren't present, to match the VCToolsInstallDir logic

We should also cache all these computed paths in the driver instead
of computing them every time they're queried, but that's for a future
patch.

It'd also be nice to invent a /winsysroot: flag that sets both
/vctoolsdir: and /winsdkdir: to some well-known subdirectory.
That's for a future patch as well.

Differential Revision: https://reviews.llvm.org/D95472

Details

Committed
thakisJan 27 2021, 3:37 AM
Differential Revision
D95472: clang-cl: Add /winsdkdir and /winsdkversion flags
Parents
rG00fcc0368731: [SCEV] Fix incorrect loop exit count analysis.
Branches
Unknown
Tags
Unknown