[clang] ace56d4 - [WoA][MSVC] Use default linker setting in MSVC-compatible driver

Maxim Kuvyrkov via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 00:44:53 PDT 2021


Author: Maxim Kuvyrkov
Date: 2021-03-18T07:42:55Z
New Revision: ace56d41aca8cac7cead9c2c97278aa50fc945b1

URL: https://github.com/llvm/llvm-project/commit/ace56d41aca8cac7cead9c2c97278aa50fc945b1
DIFF: https://github.com/llvm/llvm-project/commit/ace56d41aca8cac7cead9c2c97278aa50fc945b1.diff

LOG: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

At the moment "link.exe" is hard-coded as default linker in MSVC.cpp,
so there's no way to use LLD as default linker for MSVC driver.

This patch adds checking of CLANG_DEFAULT_LINKER to MSVC.cpp.

Reviewed By: asl

Differential Revision: https://reviews.llvm.org/D98493

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/MSVC.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 96de02378ca2..38ad7125b4af 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+					  CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+    Linker = "link";
   if (Linker.equals_lower("lld"))
     Linker = "lld-link";
 


        


More information about the cfe-commits mailing list