[PATCH] D60094: [MSVC] If unable to find link.exe relative to MSVC, look for link.exe in the path

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 1 13:20:59 PDT 2019


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60094.193165.patch
Type: text/x-patch
Size: 672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190401/979bf3f0/attachment.bin>


More information about the cfe-commits mailing list