]> granicus.if.org Git - clang/commitdiff
Add support for -stdlib=libc++ in the NetBSD toolchain.
authorJoerg Sonnenberger <joerg@bec.de>
Tue, 30 Apr 2013 01:21:43 +0000 (01:21 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Tue, 30 Apr 2013 01:21:43 +0000 (01:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
lib/Frontend/InitHeaderSearch.cpp

index faad1dc074104031ff93ef886afafebcbd800a45..06f541057f46ce18c5e9e96d1fd9c7b42d2236e9 100644 (file)
@@ -1861,6 +1861,42 @@ Tool *NetBSD::buildLinker() const {
   return new tools::netbsd::Link(*this);
 }
 
+ToolChain::CXXStdlibType
+NetBSD::GetCXXStdlibType(const ArgList &Args) const {
+  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
+    StringRef Value = A->getValue();
+    if (Value == "libstdc++")
+      return ToolChain::CST_Libstdcxx;
+    if (Value == "libc++")
+      return ToolChain::CST_Libcxx;
+
+    getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+      << A->getAsString(Args);
+  }
+
+  return ToolChain::CST_Libstdcxx;
+}
+
+void NetBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+                                          ArgStringList &CC1Args) const {
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+      DriverArgs.hasArg(options::OPT_nostdincxx))
+    return;
+
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx:
+    addSystemInclude(DriverArgs, CC1Args,
+                     getDriver().SysRoot + "/usr/include/c++/");
+    break;
+  case ToolChain::CST_Libstdcxx:
+    addSystemInclude(DriverArgs, CC1Args,
+                     getDriver().SysRoot + "/usr/include/g++");
+    addSystemInclude(DriverArgs, CC1Args,
+                     getDriver().SysRoot + "/usr/include/g++/backward");
+    break;
+  }
+}
+
 /// Minix - Minix tool chain which can call as(1) and ld(1) directly.
 
 Minix::Minix(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
index 040b6f98ea282a8b261d2694c95b307443de341a..3afd8dd228b61cdc25bf674e003e49d98e7c5fef 100644 (file)
@@ -474,6 +474,11 @@ public:
   virtual bool IsMathErrnoDefault() const { return false; }
   virtual bool IsObjCNonFragileABIDefault() const { return true; }
 
+  virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const;
+
+  virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+                                            ArgStringList &CC1Args) const;
+
 protected:
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
index 4f0d554d5684c22c807705669efdbfae657dfb4c..f4ca4d498aec40057a0f7fcd68623c643d7eb1da 100644 (file)
@@ -421,9 +421,6 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp
     // FreeBSD 7.3
     AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple);
     break;
-  case llvm::Triple::NetBSD:
-    AddGnuCPlusPlusIncludePaths("/usr/include/g++", "", "", "", triple);
-    break;
   case llvm::Triple::OpenBSD: {
     std::string t = triple.getTriple();
     if (t.substr(0, 6) == "x86_64")