"after" group instead of the system group makes it so #include <limits.h>
picks up the *system* limits.h file before clang's. This causes a failure
on linux and is definitely not what we want.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65026
91177308-0d34-0410-b5e6-
96231b3b80d8
MainExecutablePath.eraseComponent(); // Remove /clang from foo/bin/clang
MainExecutablePath.eraseComponent(); // Remove /bin from foo/bin
MainExecutablePath.appendComponent("Headers"); // Get foo/Headers
- Init.AddPath(MainExecutablePath.c_str(), InitHeaderSearch::After,
- false, false, false);
+
+ // We pass true to ignore sysroot so that we *always* look for clang headers
+ // relative to our executable, never relative to -isysroot.
+ Init.AddPath(MainExecutablePath.c_str(), InitHeaderSearch::System,
+ false, false, false, true /*ignore sysroot*/);
}
if (!nostdinc)
/// AddPath - Add the specified path to the specified group list.
void AddPath(const std::string &Path, IncludeDirGroup Group,
bool isCXXAware, bool isUserSupplied,
- bool isFramework);
+ bool isFramework, bool IgnoreSysRoot = false);
/// AddEnvVarPaths - Add a list of paths from an environment variable to a
/// header search list.
void InitHeaderSearch::AddPath(const std::string &Path, IncludeDirGroup Group,
bool isCXXAware, bool isUserSupplied,
- bool isFramework) {
+ bool isFramework, bool IgnoreSysRoot) {
assert(!Path.empty() && "can't handle empty path here");
FileManager &FM = Headers.getFileMgr();
llvm::SmallString<256> MappedPath;
// Handle isysroot.
- if (Group == System) {
+ if (Group == System && !IgnoreSysRoot) {
// FIXME: Portability. This should be a sys::Path interface, this doesn't
// handle things like C:\ right, nor win32 \\network\device\blah.
if (isysroot.size() != 1 || isysroot[0] != '/') // Add isysroot if present.