Skip to content

Commit d06ba63

Browse files
authored
Merge pull request #15148 from compnerd/msvc-sdk
2 parents 7415d35 + 45979fa commit d06ba63

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,21 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
563563
invocationArgStrs.push_back("-Xclang");
564564
invocationArgStrs.push_back("-nostdsysteminc");
565565
} else {
566-
// On Darwin, Clang uses -isysroot to specify the include
567-
// system root. On other targets, it seems to use --sysroot.
568-
if (triple.isOSDarwin()) {
569-
invocationArgStrs.push_back("-isysroot");
566+
if (triple.isWindowsMSVCEnvironment()) {
567+
llvm::SmallString<261> path; // MAX_PATH + 1
568+
path = searchPathOpts.SDKPath;
569+
llvm::sys::path::append(path, "usr", "include");
570+
llvm::sys::path::native(path);
571+
572+
invocationArgStrs.push_back("-isystem");
573+
invocationArgStrs.push_back(path.str());
570574
} else {
571-
invocationArgStrs.push_back("--sysroot");
575+
// On Darwin, Clang uses -isysroot to specify the include
576+
// system root. On other targets, it seems to use --sysroot.
577+
invocationArgStrs.push_back(triple.isOSDarwin() ? "-isysroot"
578+
: "--sysroot");
579+
invocationArgStrs.push_back(searchPathOpts.SDKPath);
572580
}
573-
invocationArgStrs.push_back(searchPathOpts.SDKPath);
574581
}
575582

576583
const std::string &moduleCachePath = importerOpts.ModuleCachePath;

0 commit comments

Comments
 (0)