[all-commits] [llvm/llvm-project] 828474: clang-cl: Invent a /winsysroot concept
Nico Weber via All-commits
all-commits at lists.llvm.org
Fri Jan 29 06:47:46 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 82847436e9258a12503dcfadb5dc373cb42fea43
https://github.com/llvm/llvm-project/commit/82847436e9258a12503dcfadb5dc373cb42fea43
Author: Nico Weber <thakis at chromium.org>
Date: 2021-01-29 (Fri, 29 Jan 2021)
Changed paths:
M clang/include/clang/Driver/Options.td
M clang/lib/Driver/ToolChains/MSVC.cpp
A clang/test/Driver/cl-sysroot.cpp
Log Message:
-----------
clang-cl: Invent a /winsysroot concept
On non-Windows platforms, --sysroot can be used to make the compiler use
a single, hermetic directory for all header and library files.
This is useful, but difficult to do on Windows. After D95472 it's
possible to achieve this with two flags:
out/gn/bin/clang-cl win.c -fuse-ld=lld \
/vctoolsdir path/to/VC/Tools/MSVC/14.26.28801 \
/winsdkdir path/to/win_sdk
But that's still cumbersome: It requires two flags instead of one, and
it requires writing down the (changing) VC/Tools/MSVC version.
This adds a new `/winsysroot <dir>` flag that's effectively an alias to
these two flags. With this, building against a hermetic Windows
toolchain only needs:
out/gn/bin/clang-cl win.c -fuse-ld=lld /winsysroot path
`/winsysroot <dir>` is the same as adding
/vctoolsdir <dir>/VC/Tools/MSVC/<vctoolsver>
/winsdkdir <dir>/Windows Kits/<winsdkmajorversion>
`<vctoolsver>` is taken from `/vctoolsversion` if passed, or else it's
the name of the directory in `<dir>/VC/Tools/MSVC` that's the highest
numeric tuple.
`<winsdkmajorversion>` is the major version in /winsdkversion if passed,
else it's the name of the directory in `<dir>/Windows Kits` that's the
highest number.
So `/winsysroot <path>` requires this subfolder structure:
path/
VC/
Tools/
MSVC/
14.26.28801 (or another number)
include/
...
Windows Kits/
10/
Include/
10.0.19041.0/ (or another number)
um/
...
Lib/
10.0.19041.0/ (or another number)
um/
x64/
...
...
Differential Revision: https://reviews.llvm.org/D95534
More information about the All-commits
mailing list