diff options
author | Nico Weber <nicolasweber@gmx.de> | 2017-07-25 18:02:57 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2017-07-25 18:02:57 +0000 |
commit | 0ee47d92b20019bed49841f93df1b5e4635061fc (patch) | |
tree | 67cbe70e812fd13f4bd7dbd5123894c0ce84607b /clang/lib/Driver/ToolChain.cpp | |
parent | f5ecb5e1b41f73868373bddc9fc0c6ebeecae5b5 (diff) | |
download | bcm5719-llvm-0ee47d92b20019bed49841f93df1b5e4635061fc.tar.gz bcm5719-llvm-0ee47d92b20019bed49841f93df1b5e4635061fc.zip |
Introduce -nostdlib++ flag to disable linking the C++ standard library.
Projects that want to statically link their own C++ standard library currently
need to pass -nostdlib or -nodefaultlibs, which also disables linking of the
builtins library, -lm, and so on. Alternatively, they could use `clang` instead
of `clang++`, but that already disables implicit addition of -lm on some
toolchains.
Add a dedicated flag -nostdlib++ that disables just linking of libc++ /
libstdc++. This is analogous to -nostdinc++.
https://reviews.llvm.org/D35780
llvm-svn: 308997
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 2be7f0f6900..b8dd37ca577 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -648,8 +648,16 @@ void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ); } +bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const { + return getDriver().CCCIsCXX() && + !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, + options::OPT_nostdlibxx); +} + void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { + assert(!Args.hasArg(options::OPT_nostdlibxx) && + "should not have called this"); CXXStdlibType Type = GetCXXStdlibType(Args); switch (Type) { |