Index: lib/Driver/WindowsToolChain.cpp =================================================================== --- lib/Driver/WindowsToolChain.cpp +++ lib/Driver/WindowsToolChain.cpp @@ -18,6 +18,7 @@ #include "llvm/Option/ArgList.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Path.h" +#include "llvm/Support/FileSystem.h" // Include the necessary headers to interface with the Windows registry and // environment. @@ -33,42 +34,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().isOSBinFormatMachO()) - return new tools::darwin::Assemble(*this); - getDriver().Diag(clang::diag::err_no_external_assembler); - return nullptr; -} - -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 @@ -187,7 +152,7 @@ /// \brief Get Windows SDK installation directory. static bool getWindowsSDKDir(std::string &path) { - char windowsSDKInstallDir[256]; + char windowsSDKInstallDir[MAX_PATH]; // Try the Windows registry. bool hasSDKDir = getSystemRegistryString( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION", @@ -241,6 +206,7 @@ } // Try the environment. + const char *vs110comntools = getenv("VS110CMONTOOLS"); const char *vs100comntools = getenv("VS100COMNTOOLS"); const char *vs90comntools = getenv("VS90COMNTOOLS"); const char *vs80comntools = getenv("VS80COMNTOOLS"); @@ -248,7 +214,11 @@ // Try to find the version that we were compiled with if(false) {} - #if (_MSC_VER >= 1600) // VC100 + #if (_MSC_VER >= 1700) // VC110 + else if(vs110comntools) { + vscomntools = vs110comntools; + } + #elif (_MSC_VER >= 1600) // VC100 else if(vs100comntools) { vscomntools = vs100comntools; } @@ -261,6 +231,8 @@ vscomntools = vs80comntools; } #endif + else if (vs110comntools) + vscomntools = vs110comntools; // Otherwise find any version we can else if (vs100comntools) vscomntools = vs100comntools; @@ -279,6 +251,52 @@ #endif // _MSC_VER +Windows::Windows(const Driver &D, const llvm::Triple& Triple, + const ArgList &Args) + : ToolChain(D, Triple, Args) { + std::string VSPath; + if (getVisualStudioDir(VSPath)) { + VSPath += "\\VC\\bin"; + llvm::Triple HostTriple(LLVM_HOST_TRIPLE); + if( HostTriple.isArch64Bit() ) { + if( llvm::sys::fs::exists(VSPath + "\\amd64") ) + VSPath += "\\amd64"; + } + getProgramPaths().push_back(VSPath); + } +} + +Tool *Windows::buildLinker() const { + return new tools::visualstudio::Link(*this); +} + +Tool *Windows::buildAssembler() const { + if (getTriple().isOSBinFormatMachO()) + return new tools::darwin::Assemble(*this); + getDriver().Diag(clang::diag::err_no_external_assembler); + return nullptr; +} + +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)) @@ -326,9 +344,17 @@ } return; } - + // As a fallback, select default install paths. const StringRef Paths[] = { + "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include", + "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include", + "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/include", + "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include", + "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/include", + "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/PlatformSDK/Include", + + "C:/Program Files/Microsoft Visual Studio 11.0/VC/include", "C:/Program Files/Microsoft Visual Studio 10.0/VC/include", "C:/Program Files/Microsoft Visual Studio 9.0/VC/include", "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",