diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2018-07-17 15:07:40 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2018-07-17 15:07:40 +0000 |
| commit | df9c9ad687d0d22bd02dea42193371b639c7565f (patch) | |
| tree | 2aec0ee9320eb9a2c581b462d77f133d6b7a0b9f | |
| parent | e5597ad9f3132bf9f4d9baddb513d5c704f28c2c (diff) | |
| download | bcm5719-llvm-df9c9ad687d0d22bd02dea42193371b639c7565f.tar.gz bcm5719-llvm-df9c9ad687d0d22bd02dea42193371b639c7565f.zip | |
clang-cl: Postpone Wmsvc-not-found emission until link.exe gets used.
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.
llvm-svn: 337290
| -rw-r--r-- | clang/lib/Driver/ToolChains/MSVC.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChains/MSVC.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 3ce1bfa0aa6..d062c6abc95 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -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); } diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h index d498cd56427..1db589ec970 100644 --- a/clang/lib/Driver/ToolChains/MSVC.h +++ b/clang/lib/Driver/ToolChains/MSVC.h @@ -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, |

