diff options
author | Pascal Stumpf <pascal@cvs.openbsd.org> | 2016-09-05 12:04:54 +0000 |
---|---|---|
committer | Pascal Stumpf <pascal@cvs.openbsd.org> | 2016-09-05 12:04:54 +0000 |
commit | 967688277c566e063a8942bdbd0124b254c91c28 (patch) | |
tree | bd88e359f9d6aa9f945862bd88e4b9ab8f233ee5 | |
parent | 72229fd29a94dd69fe74e0463e88833f3e25bf55 (diff) |
Let clang use libc++/libc++abi and its header files per default. You can still
use the old libstdc++ by specifying -stdlib=libstdc++.
with hints from/looks good to patrick@, ok kettenis@
-rw-r--r-- | gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp | 52 | ||||
-rw-r--r-- | gnu/llvm/tools/clang/lib/Driver/ToolChains.h | 7 | ||||
-rw-r--r-- | gnu/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp | 8 |
3 files changed, 59 insertions, 8 deletions
diff --git a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp index 99c7b8e68c6..45622b22ab5 100644 --- a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp +++ b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp @@ -2986,6 +2986,58 @@ Tool *OpenBSD::buildAssembler() const { Tool *OpenBSD::buildLinker() const { return new tools::openbsd::Linker(*this); } +ToolChain::CXXStdlibType OpenBSD::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_Libcxx; +} + +void OpenBSD::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++/v1"); + break; + case ToolChain::CST_Libstdcxx: + std::string Triple = getTriple().str(); + if (Triple.substr(0, 6) == "x86_64") + Triple.replace(0, 6, "amd64"); + addSystemInclude(DriverArgs, CC1Args, + getDriver().SysRoot + "/usr/include/g++"); + addSystemInclude(DriverArgs, CC1Args, + getDriver().SysRoot + "/usr/include/g++/" + Triple); + addSystemInclude(DriverArgs, CC1Args, + getDriver().SysRoot + "/usr/include/g++/backward"); + break; + } +} + +void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + switch (GetCXXStdlibType(Args)) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-lc++"); + CmdArgs.push_back("-lc++abi"); + CmdArgs.push_back("-lpthread"); + break; + case ToolChain::CST_Libstdcxx: + CmdArgs.push_back("-lstdc++"); + break; + } +} + /// Bitrig - Bitrig tool chain which can call as(1) and ld(1) directly. Bitrig::Bitrig(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) diff --git a/gnu/llvm/tools/clang/lib/Driver/ToolChains.h b/gnu/llvm/tools/clang/lib/Driver/ToolChains.h index f940e5847e1..08fe0b80783 100644 --- a/gnu/llvm/tools/clang/lib/Driver/ToolChains.h +++ b/gnu/llvm/tools/clang/lib/Driver/ToolChains.h @@ -676,6 +676,13 @@ public: bool IsObjCNonFragileABIDefault() const override { return true; } bool isPIEDefault() const override { return true; } + CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; + void AddClangCXXStdlibIncludeArgs( + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const override; + unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override { return 2; } diff --git a/gnu/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp b/gnu/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp index 26bab0db534..56ba45c0003 100644 --- a/gnu/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/gnu/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp @@ -413,14 +413,6 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp case llvm::Triple::DragonFly: AddPath("/usr/include/c++/5.0", CXXSystem, false); break; - case llvm::Triple::OpenBSD: { - std::string t = triple.getTriple(); - if (t.substr(0, 6) == "x86_64") - t.replace(0, 6, "amd64"); - AddGnuCPlusPlusIncludePaths("/usr/include/g++", - t, "", "", triple); - break; - } case llvm::Triple::Minix: AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", "", "", "", triple); |