Modify clang so that when TOOLS_PREFIX is defined we register the

CLANG_PREFIX macro. This changes the default header search path when we
are building clang as part of cross-tools.

Submitted by:	Dimitry Andric <dimitry at andric.com>
Reviewed by:	freebsd-current
This commit is contained in:
Rui Paulo 2010-08-21 15:46:33 +00:00
parent ad8a0e422c
commit 2aedda247b
3 changed files with 25 additions and 12 deletions

View File

@ -26,6 +26,10 @@
#include <cstdlib> // ::getenv #include <cstdlib> // ::getenv
#ifndef CLANG_PREFIX
#define CLANG_PREFIX
#endif
using namespace clang::driver; using namespace clang::driver;
using namespace clang::driver::toolchains; using namespace clang::driver::toolchains;
@ -869,11 +873,9 @@ FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32)
getProgramPaths().push_back(getDriver().Dir + "/../libexec"); getProgramPaths().push_back(getDriver().Dir + "/../libexec");
getProgramPaths().push_back("/usr/libexec"); getProgramPaths().push_back("/usr/libexec");
if (Lib32) { if (Lib32) {
getFilePaths().push_back(getDriver().Dir + "/../lib32"); getFilePaths().push_back(CLANG_PREFIX "/usr/lib32");
getFilePaths().push_back("/usr/lib32");
} else { } else {
getFilePaths().push_back(getDriver().Dir + "/../lib"); getFilePaths().push_back(CLANG_PREFIX "/usr/lib");
getFilePaths().push_back("/usr/lib");
} }
} }

View File

@ -30,6 +30,9 @@
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#include <windows.h> #include <windows.h>
#endif #endif
#ifndef CLANG_PREFIX
#define CLANG_PREFIX
#endif
using namespace clang; using namespace clang;
using namespace clang::frontend; using namespace clang::frontend;
@ -408,9 +411,10 @@ static bool getWindowsSDKDir(std::string &path) {
void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts) { const HeaderSearchOptions &HSOpts) {
#if 0 /* Remove unneeded include paths. */
// FIXME: temporary hack: hard-coded paths. // FIXME: temporary hack: hard-coded paths.
AddPath("/usr/local/include", System, true, false, false); #ifndef __FreeBSD__
AddPath(CLANG_PREFIX "/usr/local/include", System, true, false, false);
#endif
// Builtin includes use #include_next directives and should be positioned // Builtin includes use #include_next directives and should be positioned
// just prior C include dirs. // just prior C include dirs.
@ -421,7 +425,6 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
P.appendComponent("include"); P.appendComponent("include");
AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true); AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
} }
#endif
// Add dirs specified via 'configure --with-c-include-dirs'. // Add dirs specified via 'configure --with-c-include-dirs'.
llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS); llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);
@ -518,13 +521,15 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::MinGW32: case llvm::Triple::MinGW32:
AddPath("c:/mingw/include", System, true, false, false); AddPath("c:/mingw/include", System, true, false, false);
break; break;
case llvm::Triple::FreeBSD:
AddPath(CLANG_PREFIX "/usr/include/clang/" CLANG_VERSION_STRING,
System, false, false, false);
break;
default: default:
break; break;
} }
AddPath("/usr/include/clang/" CLANG_VERSION_STRING, AddPath(CLANG_PREFIX "/usr/include", System, false, false, false);
System, false, false, false);
AddPath("/usr/include", System, false, false, false);
} }
void InitHeaderSearch:: void InitHeaderSearch::
@ -726,8 +731,10 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
case llvm::Triple::FreeBSD: case llvm::Triple::FreeBSD:
// FreeBSD 8.0 // FreeBSD 8.0
// FreeBSD 7.3 // FreeBSD 7.3
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple); AddGnuCPlusPlusIncludePaths(CLANG_PREFIX "/usr/include/c++/4.2",
AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2/backward", "", "", "", triple); "", "", "", triple);
AddGnuCPlusPlusIncludePaths(CLANG_PREFIX "/usr/include/c++/4.2/backward",
"", "", "", triple);
break; break;
case llvm::Triple::Minix: case llvm::Triple::Minix:
AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",

View File

@ -28,6 +28,10 @@ LLVM_REQUIRES_RTTI=
CFLAGS+=-fno-rtti CFLAGS+=-fno-rtti
.endif .endif
.ifdef TOOLS_PREFIX
CFLAGS+=-DCLANG_PREFIX=\"${TOOLS_PREFIX}\"
.endif
.PATH: ${LLVM_SRCS}/${SRCDIR} .PATH: ${LLVM_SRCS}/${SRCDIR}
TBLGEN=tblgen ${CFLAGS:M-I*} TBLGEN=tblgen ${CFLAGS:M-I*}