From: Rafael Espindola Date: Mon, 17 Oct 2011 22:14:51 +0000 (+0000) Subject: Implement -static-libstdc++ for linux. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=19706f8e702c04d19bc1ace504cbb9df008b6daa;p=clang Implement -static-libstdc++ for linux. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142290 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index ae8c7945cb..1c6635da1a 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -686,6 +686,7 @@ def single__module : Flag<"-single_module">; def specs_EQ : Joined<"-specs=">; def specs : Separate<"-specs">, Flags<[Unsupported]>; def static_libgcc : Flag<"-static-libgcc">; +def static_libstdcxx : Flag<"-static-libstdc++">; def static : Flag<"-static">, Flags<[NoArgumentUnused]>; def std_default_EQ : Joined<"-std-default=">; def std_EQ : Joined<"-std=">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index a71015307d..20b02f541e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4375,7 +4375,13 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA, AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); if (D.CCCIsCXX && !Args.hasArg(options::OPT_nostdlib)) { + bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && + !Args.hasArg(options::OPT_static); + if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bstatic"); ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); + if (OnlyLibstdcxxStatic) + CmdArgs.push_back("-Bdynamic"); CmdArgs.push_back("-lm"); }