r188531 - Windows ToolChain: add VS bin dir to PogramPaths

Hans Wennborg hans at hanshq.net
Thu Aug 15 20:15:11 PDT 2013


Author: hans
Date: Thu Aug 15 22:15:10 2013
New Revision: 188531

URL: http://llvm.org/viewvc/llvm-project?rev=188531&view=rev
Log:
Windows ToolChain: add VS bin dir to PogramPaths

We have a lot of fancy logic to find Visual Studio, which is currently used
to set the system header include paths.

Use the same code to set the ProgramPaths, which is used for finding programs
such as link.exe. Previously, Clang would just search PATH for link.exe,
but now it should find it if it's able to find Visual Studio.

Differential Revision: http://llvm-reviews.chandlerc.com/D1417

Modified:
    cfe/trunk/lib/Driver/WindowsToolChain.cpp

Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=188531&r1=188530&r2=188531&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Thu Aug 15 22:15:10 2013
@@ -33,42 +33,6 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-Windows::Windows(const Driver &D, const llvm::Triple& Triple,
-                 const ArgList &Args)
-  : ToolChain(D, Triple, Args) {
-}
-
-Tool *Windows::buildLinker() const {
-  return new tools::visualstudio::Link(*this);
-}
-
-Tool *Windows::buildAssembler() const {
-  if (getTriple().getEnvironment() == llvm::Triple::MachO)
-    return new tools::darwin::Assemble(*this);
-  getDriver().Diag(clang::diag::err_no_external_windows_assembler);
-  return NULL;
-}
-
-bool Windows::IsIntegratedAssemblerDefault() const {
-  return true;
-}
-
-bool Windows::IsUnwindTablesDefault() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
-bool Windows::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
-bool Windows::isPIEDefault() const {
-  return false;
-}
-
-bool Windows::isPICDefaultForced() const {
-  return getArch() == llvm::Triple::x86_64;
-}
-
 // FIXME: This probably should goto to some platform utils place.
 #ifdef _MSC_VER
 
@@ -200,7 +164,7 @@ static bool getWindowsSDKDir(std::string
   return false;
 }
 
-  // Get Visual Studio installation directory.
+// Get Visual Studio installation directory.
 static bool getVisualStudioDir(std::string &path) {
   // First check the environment variables that vsvars32.bat sets.
   const char* vcinstalldir = getenv("VCINSTALLDIR");
@@ -277,6 +241,47 @@ static bool getVisualStudioDir(std::stri
 
 #endif // _MSC_VER
 
+Windows::Windows(const Driver &D, const llvm::Triple& Triple,
+                 const ArgList &Args)
+  : ToolChain(D, Triple, Args) {
+#ifdef _MSC_VER
+  std::string VSDir;
+  if (getVisualStudioDir(VSDir))
+    getProgramPaths().push_back(VSDir + "\\VC\\bin");
+#endif
+}
+
+Tool *Windows::buildLinker() const {
+  return new tools::visualstudio::Link(*this);
+}
+
+Tool *Windows::buildAssembler() const {
+  if (getTriple().getEnvironment() == llvm::Triple::MachO)
+    return new tools::darwin::Assemble(*this);
+  getDriver().Diag(clang::diag::err_no_external_windows_assembler);
+  return NULL;
+}
+
+bool Windows::IsIntegratedAssemblerDefault() const {
+  return true;
+}
+
+bool Windows::IsUnwindTablesDefault() const {
+  return getArch() == llvm::Triple::x86_64;
+}
+
+bool Windows::isPICDefault() const {
+  return getArch() == llvm::Triple::x86_64;
+}
+
+bool Windows::isPIEDefault() const {
+  return false;
+}
+
+bool Windows::isPICDefaultForced() const {
+  return getArch() == llvm::Triple::x86_64;
+}
+
 void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
                                         ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))





More information about the cfe-commits mailing list