From: Yaron Keren Date: Tue, 17 May 2016 19:01:16 +0000 (+0000) Subject: Teach clang to look for libcxx in /usr/local/include/c++ on Linux X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89a379de617e1914a6aa0ab8ad757bc3a74800be;p=clang Teach clang to look for libcxx in /usr/local/include/c++ on Linux As The default CMAKE install prefix is /usr/local ( https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html ), sudo ninja install ends up installing clang, LLVM and libcxx under /usr/local. In development scenario, when clang is run from the build location it will not find libcxx at neither (build location)/../include/c++ nor /usr/include/c++. This patch lets development clang find system installed libcxx without adding -isystem /usr/local/include/c++. Also addresses the FIXME by explaining the use-case for these include paths. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269801 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index d296980ce7..49e8c06a75 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -4130,11 +4130,11 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) { const std::string LibCXXIncludePathCandidates[] = { DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"), - - // We also check the system as for a long time this is the only place - // Clang looked. - // FIXME: We should really remove this. It doesn't make any sense. - DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++")}; + // If this is a development, non-installed, clang, libcxx will + // not be found at ../include/c++ but it likely to be found at + // one of the following two locations: + DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/local/include/c++"), + DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++") }; for (const auto &IncludePath : LibCXXIncludePathCandidates) { if (IncludePath.empty() || !getVFS().exists(IncludePath)) continue;