summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2019-03-03 10:06:34 +0000
committerMichal Gorny <mgorny@gentoo.org>2019-03-03 10:06:34 +0000
commitd3516b51cae6f3ec38be2db718534f0446057b77 (patch)
tree886e4f75e391b4eecc4badce687d2098fafcaf3d /clang/lib
parentce686597722cecdecf9c33d0cfc3ba7909cd65b1 (diff)
downloadbcm5719-llvm-d3516b51cae6f3ec38be2db718534f0446057b77.tar.gz
bcm5719-llvm-d3516b51cae6f3ec38be2db718534f0446057b77.zip
[clang] [ToolChains/NetBSD] Support relative libc++ header path
Support locating the libc++ header files relatively to the clang executable, in addition to the default system path. This is meant to cover two use cases: running just-built clang from the install directory, and running installed clang from non-standard location (e.g. /usr/local). This is the first step towards ensuring that tests of more LLVM projects can work out-of-the-box within the build tree, and use the correct set of headers (rather than e.g. mixing just-built clang+libcxx with system install of libcxx). It avoids requiring the user to hack around missing include paths, or LLVM build system to replicate system-specific C++ library defaults in order to append appropriate paths implicitly. Differential Revision: https://reviews.llvm.org/D58592 llvm-svn: 355282
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains/NetBSD.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index ae9564b817c..53587e27853 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -16,6 +16,7 @@
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/VirtualFileSystem.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -422,8 +423,23 @@ ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() const {
void NetBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
- addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/usr/include/c++/");
+ const std::string Candidates[] = {
+ // directory relative to build tree
+ getDriver().Dir + "/../include/c++/v1",
+ // system install with full upstream path
+ getDriver().SysRoot + "/usr/include/c++/v1",
+ // system install from src
+ getDriver().SysRoot + "/usr/include/c++",
+ };
+
+ for (const auto &IncludePath : Candidates) {
+ if (!getVFS().exists(IncludePath + "/__config"))
+ continue;
+
+ // Use the first candidate that looks valid.
+ addSystemInclude(DriverArgs, CC1Args, IncludePath);
+ return;
+ }
}
void NetBSD::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
OpenPOWER on IntegriCloud