mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
Herald added a project: clang.

Previously, if this is encountered, clang will later just fail to execute 
link.exe.

Or is this intentional, to avoid executing msys based link.exe accidentally, if 
the MSVC installation isn't found?

This improves using clang in msvc mode on linux, where one intentionally might 
not want to point clang to the MSVC installation itself (which isn't executable 
as such), but where a link.exe named wine wrapper is available in the path.

Alternatively, are there other ways of overriding the condition above 
(Linker.equals_lower("link")) to keep using link.exe for linking, but just 
picking it from the path? (I have another patch locally, using an environment 
variable for it.) Yet another alternative is to pass -fuse-ld=lld-link of 
course.


Repository:
  rC Clang

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,10 @@
     // their own link.exe which may come first.
     linkPath = FindVisualStudioExecutable(TC, "link.exe");
 
-    if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath))
+    if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) {
       C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+      linkPath = TC.GetProgramPath("link.exe");
+    }
 
 #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,10 @@
     // their own link.exe which may come first.
     linkPath = FindVisualStudioExecutable(TC, "link.exe");
 
-    if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath))
+    if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) {
       C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+      linkPath = TC.GetProgramPath("link.exe");
+    }
 
 #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

Reply via email to