[PATCH] Windows ToolChain: add VS bin dir to ProgramPaths

Hans Wennborg hans at chromium.org
Thu Aug 15 17:05:38 PDT 2013


Hi rnk,

The Windows ToolChain has a lot of fancy logic to find Visual Studio, which is used to set system include paths.

We should make use of the same code to set the ToolChain ProgramPaths, which is used for finding programs such as link.exe (currently ProgramPaths is empty, which means clang just searches the system path).

(The patch looks larger than it is; I'm just moving some functions to come before the constructor definition, which I'm changing.)

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

Files:
  lib/Driver/WindowsToolChain.cpp

Index: lib/Driver/WindowsToolChain.cpp
===================================================================
--- lib/Driver/WindowsToolChain.cpp
+++ lib/Driver/WindowsToolChain.cpp
@@ -33,42 +33,6 @@
 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 @@
   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 @@
 
 #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))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1417.1.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130815/6c2a4354/attachment.bin>


More information about the cfe-commits mailing list