From: Rafael Espindola Date: Fri, 3 Feb 2012 01:01:20 +0000 (+0000) Subject: Replace the old --with-cxx-* configure options with a single --with-gcc-toolchain X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=353300c4af020ce5d8368d1c336cbf7583c33a7d;p=clang Replace the old --with-cxx-* configure options with a single --with-gcc-toolchain that just uses the new toolchain probing logic. This fixes linking with -m32 on 64 bit systems (the /32 dir was not being added to the search). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149652 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake index c39932c946..8500c13ed5 100644 --- a/include/clang/Config/config.h.cmake +++ b/include/clang/Config/config.h.cmake @@ -4,17 +4,8 @@ /* Relative directory for resource files */ #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}" -/* 32 bit multilib directory. */ -#define CXX_INCLUDE_32BIT_DIR "${CXX_INCLUDE_32BIT_DIR}" - -/* 64 bit multilib directory. */ -#define CXX_INCLUDE_64BIT_DIR "${CXX_INCLUDE_64BIT_DIR}" - -/* Arch the libstdc++ headers. */ -#define CXX_INCLUDE_ARCH "${CXX_INCLUDE_ARCH}" - -/* Directory with the libstdc++ headers. */ -#define CXX_INCLUDE_ROOT "${CXX_INCLUDE_ROOT}" +/* Directory with the libstdc++ installation. */ +#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" /* Directories clang will search for headers */ #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 0c8d3dc82e..4fe29de90d 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -37,7 +37,7 @@ # include "clang/Config/config.h" #endif -#include "llvm/Config/config.h" // for CXX_INCLUDE_ROOT +#include "llvm/Config/config.h" // for GCC_INSTALL_PREFIX using namespace clang::driver; using namespace clang::driver::toolchains; @@ -1116,34 +1116,6 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( const Driver &D, const llvm::Triple &TargetTriple) : IsValid(false) { - // FIXME: Using CXX_INCLUDE_ROOT is here is a bit of a hack, but - // avoids adding yet another option to configure/cmake. - // It would probably be cleaner to break it in two variables - // CXX_GCC_ROOT with just /foo/bar - // CXX_GCC_VER with 4.5.2 - // Then we would have - // CXX_INCLUDE_ROOT = CXX_GCC_ROOT/include/c++/CXX_GCC_VER - // and this function would return - // CXX_GCC_ROOT/lib/gcc/CXX_INCLUDE_ARCH/CXX_GCC_VER - llvm::SmallString<128> CxxIncludeRoot(CXX_INCLUDE_ROOT); - if (CxxIncludeRoot != "") { - // This is of the form /foo/bar/include/c++/4.5.2/ - if (CxxIncludeRoot.back() == '/') - llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the / - StringRef Version = llvm::sys::path::filename(CxxIncludeRoot); - llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the version - llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the c++ - llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the include - GCCInstallPath = CxxIncludeRoot.str(); - GCCInstallPath.append("/lib/gcc/"); - GCCInstallPath.append(CXX_INCLUDE_ARCH); - GCCInstallPath.append("/"); - GCCInstallPath.append(Version); - GCCParentLibPath = GCCInstallPath + "/../../.."; - IsValid = true; - return; - } - llvm::Triple MultiarchTriple = getMultiarchAlternateTriple(TargetTriple); llvm::Triple::ArchType TargetArch = TargetTriple.getArch(); // The library directories which may contain GCC installations. @@ -1159,9 +1131,18 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( // Compute the set of prefixes for our search. SmallVector Prefixes(D.PrefixDirs.begin(), D.PrefixDirs.end()); - Prefixes.push_back(D.SysRoot); - Prefixes.push_back(D.SysRoot + "/usr"); - Prefixes.push_back(D.InstalledDir + "/.."); + + llvm::SmallString<128> CxxInstallRoot(GCC_INSTALL_PREFIX); + if (CxxInstallRoot != "") { + if (CxxInstallRoot.back() == '/') + llvm::sys::path::remove_filename(CxxInstallRoot); // remove the / + + Prefixes.push_back(CxxInstallRoot.str()); + } else { + Prefixes.push_back(D.SysRoot); + Prefixes.push_back(D.SysRoot + "/usr"); + Prefixes.push_back(D.InstalledDir + "/.."); + } // Loop over the various components which exist and select the best GCC // installation available. GCC installs are ranked by version number. @@ -2233,22 +2214,6 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, return; } - const llvm::Triple &TargetTriple = getTriple(); - - StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT); - if (!CxxIncludeRoot.empty()) { - StringRef CxxIncludeArch(CXX_INCLUDE_ARCH); - if (CxxIncludeArch.empty()) - CxxIncludeArch = TargetTriple.str(); - - addLibStdCXXIncludePaths( - CxxIncludeRoot, - CxxIncludeArch + (isTarget64Bit() ? CXX_INCLUDE_64BIT_DIR - : CXX_INCLUDE_32BIT_DIR), - DriverArgs, CC1Args); - return; - } - // We need a detected GCC installation on Linux to provide libstdc++'s // headers. We handled the libc++ case above. if (!GCCInstallation.isValid()) diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index 9faa126755..e1a8c53de8 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -329,19 +329,6 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, void InitHeaderSearch:: AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { llvm::Triple::OSType os = triple.getOS(); - StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT); - if (CxxIncludeRoot != "") { - StringRef CxxIncludeArch(CXX_INCLUDE_ARCH); - if (CxxIncludeArch == "") - AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, triple.str().c_str(), - CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, - triple); - else - AddGnuCPlusPlusIncludePaths(CxxIncludeRoot, CXX_INCLUDE_ARCH, - CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, - triple); - return; - } // FIXME: temporary hack: hard-coded paths. if (triple.isOSDarwin()) {