This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Add /winsdkdir and /winsdkversion flags
ClosedPublic

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

Details

Summary

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.

Diff Detail

Event Timeline

thakis created this revision.Jan 26 2021, 12:31 PM
thakis requested review of this revision.Jan 26 2021, 12:31 PM
hans accepted this revision.Jan 27 2021, 2:19 AM

Nice, lgtm

This revision is now accepted and ready to land.Jan 27 2021, 2:19 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2021, 3:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript