mstorsjo updated this revision to Diff 194926. mstorsjo retitled this revision from "[MSVC] If unable to find link.exe relative to MSVC, look for link.exe in the path" to "[MSVC] If unable to find link.exe from a MSVC installation, look for link.exe next to cl.exe". mstorsjo edited the summary of this revision. mstorsjo added a comment.
Updated to not look blindly for link(.exe) in the PATH, but look for cl.exe and look for link.exe next to it. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60094/new/ https://reviews.llvm.org/D60094 Files: lib/Driver/ToolChains/MSVC.cpp Index: lib/Driver/ToolChains/MSVC.cpp =================================================================== --- lib/Driver/ToolChains/MSVC.cpp +++ lib/Driver/ToolChains/MSVC.cpp @@ -488,8 +488,18 @@ // their own link.exe which may come first. linkPath = FindVisualStudioExecutable(TC, "link.exe"); - if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) - C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) { + llvm::SmallString<128> ClPath; + ClPath = TC.GetProgramPath("cl.exe"); + if (llvm::sys::fs::can_execute(ClPath)) { + linkPath = llvm::sys::path::parent_path(ClPath); + llvm::sys::path::append(linkPath, "link.exe"); + if (!llvm::sys::fs::can_execute(linkPath)) + C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + } else { + C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + } + } #ifdef _WIN32 // When cross-compiling with VS2017 or newer, link.exe expects to have
Index: lib/Driver/ToolChains/MSVC.cpp =================================================================== --- lib/Driver/ToolChains/MSVC.cpp +++ lib/Driver/ToolChains/MSVC.cpp @@ -488,8 +488,18 @@ // their own link.exe which may come first. linkPath = FindVisualStudioExecutable(TC, "link.exe"); - if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) - C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) { + llvm::SmallString<128> ClPath; + ClPath = TC.GetProgramPath("cl.exe"); + if (llvm::sys::fs::can_execute(ClPath)) { + linkPath = llvm::sys::path::parent_path(ClPath); + llvm::sys::path::append(linkPath, "link.exe"); + if (!llvm::sys::fs::can_execute(linkPath)) + C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + } else { + C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found); + } + } #ifdef _WIN32 // When cross-compiling with VS2017 or newer, link.exe expects to have
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits