From: Chris Lattner Date: Thu, 19 Feb 2009 06:48:28 +0000 (+0000) Subject: fix a bug introduced in my previous patch: moving clang headers to the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6858dd3fcc2d3ac6a706a0294be1d3ac51849022;p=clang fix a bug introduced in my previous patch: moving clang headers to the "after" group instead of the system group makes it so #include 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 --- diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 79166fb0bd..525c27facc 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -1098,8 +1098,11 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers, 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) diff --git a/include/clang/Driver/InitHeaderSearch.h b/include/clang/Driver/InitHeaderSearch.h index a113456e8a..b02117e1b6 100644 --- a/include/clang/Driver/InitHeaderSearch.h +++ b/include/clang/Driver/InitHeaderSearch.h @@ -50,7 +50,7 @@ public: /// 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. diff --git a/lib/Driver/InitHeaderSearch.cpp b/lib/Driver/InitHeaderSearch.cpp index 4b5275d726..5b0b2c2f72 100644 --- a/lib/Driver/InitHeaderSearch.cpp +++ b/lib/Driver/InitHeaderSearch.cpp @@ -24,7 +24,7 @@ using namespace clang; 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(); @@ -32,7 +32,7 @@ void InitHeaderSearch::AddPath(const std::string &Path, IncludeDirGroup Group, 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.