]> granicus.if.org Git - clang/commitdiff
clang-cl: Postpone Wmsvc-not-found emission until link.exe gets used.
authorNico Weber <nicolasweber@gmx.de>
Tue, 17 Jul 2018 15:07:40 +0000 (15:07 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 17 Jul 2018 15:07:40 +0000 (15:07 +0000)
Wmsvc-not-found was added in r297851 to help diagnose why link.exe can't be
executed. However, it's emitted even when using -fuse-ld=lld, and in cross
builds there's no way to get rid of the warning other than disabling it.

Instead, emit it when we look up link.exe and it ends up not being executable.
That way, when passing -fuse-ld=lld it will never be printed.
It will also not be printed if we find link.exe on PATH.

(We might want to eventually default to lld one day, at least when running on a
non-Win host, but that's for another day.)

Fixes PR38016.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/MSVC.cpp
lib/Driver/ToolChains/MSVC.h

index 3ce1bfa0aa64a82fa6c658b721def0b1ed775db8..d062c6abc955c2d6fbb58afda7126df6d0f7b0c0 100644 (file)
@@ -469,6 +469,9 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     // 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);
+
 #ifdef _WIN32
     // When cross-compiling with VS2017 or newer, link.exe expects to have
     // its containing bin directory at the top of PATH, followed by the
@@ -684,8 +687,6 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
 }
 
 Tool *MSVCToolChain::buildLinker() const {
-  if (VCToolChainPath.empty())
-    getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
   return new tools::visualstudio::Linker(*this);
 }
 
index d498cd56427968b4a627678fcc85e14547db4956..1db589ec9706721c7224203ef8ba851b17fd173c 100644 (file)
@@ -123,6 +123,8 @@ public:
 
   void printVerboseInfo(raw_ostream &OS) const override;
 
+  bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
+
 protected:
   void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
                                      llvm::opt::ArgStringList &CC1Args,