[all-commits] [llvm/llvm-project] a5d85c: clang-cl: Add /winsdkdir and /winsdkversion flags

Nico Weber via All-commits all-commits at lists.llvm.org
Wed Jan 27 03:42:12 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a5d85cbec58edc447b607f503ca4344e184dbb39
      https://github.com/llvm/llvm-project/commit/a5d85cbec58edc447b607f503ca4344e184dbb39
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-01-27 (Wed, 27 Jan 2021)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/MSVC.cpp
    M clang/lib/Driver/ToolChains/MSVC.h
    M clang/test/Driver/cl-options.c

  Log Message:
  -----------
  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




More information about the All-commits mailing list