Index: lib/Driver/ToolChains/MSVC.h =================================================================== --- lib/Driver/ToolChains/MSVC.h +++ lib/Driver/ToolChains/MSVC.h @@ -131,6 +131,7 @@ private: std::string VCToolChainPath; bool IsVS2017OrNewer = false; + bool IsDevDivInternal = false; CudaInstallationDetector CudaInstallation; }; Index: lib/Driver/ToolChains/MSVC.cpp =================================================================== --- lib/Driver/ToolChains/MSVC.cpp +++ lib/Driver/ToolChains/MSVC.cpp @@ -76,7 +76,8 @@ // Check various environment variables to try and find a toolchain. static bool findVCToolChainViaEnvironment(std::string &Path, - bool &IsVS2017OrNewer) { + bool &IsVS2017OrNewer, + bool &IsDevDivInternal) { // These variables are typically set by vcvarsall.bat // when launching a developer command prompt. if (llvm::Optional VCToolsInstallDir = @@ -138,6 +139,13 @@ Path = ParentPath; IsVS2017OrNewer = false; return true; + } else if (llvm::sys::path::filename(ParentPath) == "x86ret" + || llvm::sys::path::filename(ParentPath) == "x86chk" + || llvm::sys::path::filename(ParentPath) == "amd64ret" + || llvm::sys::path::filename(ParentPath) == "amd64chk") { + Path = ParentPath; + IsDevDivInternal = true; + return true; } } else { @@ -677,7 +685,7 @@ // what they want to use. // Failing that, just try to find the newest Visual Studio version we can // and use its default VC toolchain. - findVCToolChainViaEnvironment(VCToolChainPath, IsVS2017OrNewer) || + findVCToolChainViaEnvironment(VCToolChainPath, IsVS2017OrNewer, IsDevDivInternal) || findVCToolChainViaSetupConfig(VCToolChainPath, IsVS2017OrNewer) || findVCToolChainViaRegistry(VCToolChainPath, IsVS2017OrNewer); } @@ -766,6 +774,21 @@ } } +// Similar to the above function, but for DevDiv internal builds. +static const char *llvmArchToDevDivInternalArch(llvm::Triple::ArchType Arch) { + using ArchType = llvm::Triple::ArchType; + switch (Arch) { + case ArchType::x86: + return "i386"; + case ArchType::x86_64: + return "amd64"; + case ArchType::arm: + return "arm"; + default: + return ""; + } +} + // Get the path to a specific subdirectory in the current toolchain for // a given target architecture. // VS2017 changed the VC toolchain layout, so this should be used instead @@ -776,7 +799,9 @@ llvm::SmallString<256> Path(VCToolChainPath); switch (Type) { case SubDirectoryType::Bin: - if (IsVS2017OrNewer) { + if (IsDevDivInternal) { + llvm::sys::path::append(Path, "bin", llvmArchToDevDivInternalArch(TargetArch)); + } else if (IsVS2017OrNewer) { bool HostIsX64 = llvm::Triple(llvm::sys::getProcessTriple()).isArch64Bit(); llvm::sys::path::append(Path, "bin", (HostIsX64 ? "HostX64" : "HostX86"), @@ -787,12 +812,20 @@ } break; case SubDirectoryType::Include: - llvm::sys::path::append(Path, "include"); + if (IsDevDivInternal) { + llvm::sys::path::append(Path, "inc"); + } else { + llvm::sys::path::append(Path, "include"); + } break; case SubDirectoryType::Lib: - llvm::sys::path::append( - Path, "lib", IsVS2017OrNewer ? llvmArchToWindowsSDKArch(TargetArch) - : llvmArchToLegacyVCArch(TargetArch)); + if (IsDevDivInternal) { + llvm::sys::path::append(Path, "lib", llvmArchToDevDivInternalArch(TargetArch)); + } else if (IsVS2017OrNewer) { + llvm::sys::path::append(Path, "lib", llvmArchToWindowsSDKArch(TargetArch)); + } else { + llvm::sys::path::append(Path, "lib", llvmArchToLegacyVCArch(TargetArch)); + } break; } return Path.str();