diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-09-14 23:12:40 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-09-14 23:12:40 +0000 |
commit | 3f16c959e30b7e7ba8e4b8d597c313fbe457206d (patch) | |
tree | 6d3dd1d7750a0f36a1766407d09f5fa0a0c6a3ef /lib/Driver/ToolChain.cpp | |
parent | 641b98b7b52e0067beaf3978f2a8721e5d16c111 (diff) |
Driver: Add a -stdlib= argument which can be used to select the C++ standard
library to use.
- This is currently useful for testing libc++; you can now use 'clang++
-stdlib=libc++ t.cpp' to compile using it if installed.
- In the future could also be used to select other standard library choices if
alternatives become available (for example, to use an alternate C library).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChain.cpp')
-rw-r--r-- | lib/Driver/ToolChain.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index 0f63046409..337ea4e8f9 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -175,6 +175,16 @@ std::string ToolChain::ComputeEffectiveClangTriple(const ArgList &Args) const { } ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ + if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { + llvm::StringRef Value = A->getValue(Args); + if (Value == "libc++") + return ToolChain::CST_Libcxx; + if (Value == "libstdc++") + return ToolChain::CST_Libstdcxx; + getDriver().Diag(clang::diag::err_drv_invalid_stdlib_name) + << A->getAsString(Args); + } + return ToolChain::CST_Libstdcxx; } @@ -183,6 +193,11 @@ void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &Args, CXXStdlibType Type = GetCXXStdlibType(Args); switch (Type) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-cxx-system-include"); + CmdArgs.push_back("/usr/include/c++/v1"); + break; + case ToolChain::CST_Libstdcxx: // Currently handled by the mass of goop in InitHeaderSearch. break; @@ -194,6 +209,10 @@ void ToolChain::AddClangCXXStdlibLibArgs(const ArgList &Args, CXXStdlibType Type = GetCXXStdlibType(Args); switch (Type) { + case ToolChain::CST_Libcxx: + CmdArgs.push_back("-lc++"); + break; + case ToolChain::CST_Libstdcxx: CmdArgs.push_back("-lstdc++"); break; |