[cfe-commits] r142269 - /cfe/trunk/lib/Driver/Tools.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 17 14:39:04 PDT 2011
Author: rafael
Date: Mon Oct 17 16:39:04 2011
New Revision: 142269
URL: http://llvm.org/viewvc/llvm-project?rev=142269&view=rev
Log:
Implement -static-libgcc on linux and refactor the code responsible for adding
libgcc to the link line into a helper function.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=142269&r1=142268&r2=142269&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 17 16:39:04 2011
@@ -4233,6 +4233,30 @@
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
+static void AddLibgcc(const Driver &D, ArgStringList &CmdArgs,
+ const ArgList &Args) {
+ bool StaticLibgcc = Args.hasArg(options::OPT_static) ||
+ Args.hasArg(options::OPT_static_libgcc);
+ if (!D.CCCIsCXX)
+ CmdArgs.push_back("-lgcc");
+
+ if (StaticLibgcc) {
+ if (D.CCCIsCXX)
+ CmdArgs.push_back("-lgcc");
+ } else {
+ if (!D.CCCIsCXX)
+ CmdArgs.push_back("--as-needed");
+ CmdArgs.push_back("-lgcc_s");
+ if (!D.CCCIsCXX)
+ CmdArgs.push_back("--no-as-needed");
+ }
+
+ if (StaticLibgcc)
+ CmdArgs.push_back("-lgcc_eh");
+ else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX)
+ CmdArgs.push_back("-lgcc");
+}
+
void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@@ -4359,24 +4383,7 @@
if (Args.hasArg(options::OPT_static))
CmdArgs.push_back("--start-group");
- if (!D.CCCIsCXX)
- CmdArgs.push_back("-lgcc");
-
- if (Args.hasArg(options::OPT_static)) {
- if (D.CCCIsCXX)
- CmdArgs.push_back("-lgcc");
- } else {
- if (!D.CCCIsCXX)
- CmdArgs.push_back("--as-needed");
- CmdArgs.push_back("-lgcc_s");
- if (!D.CCCIsCXX)
- CmdArgs.push_back("--no-as-needed");
- }
-
- if (Args.hasArg(options::OPT_static))
- CmdArgs.push_back("-lgcc_eh");
- else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX)
- CmdArgs.push_back("-lgcc");
+ AddLibgcc(D, CmdArgs, Args);
if (Args.hasArg(options::OPT_pthread) ||
Args.hasArg(options::OPT_pthreads))
@@ -4386,19 +4393,8 @@
if (Args.hasArg(options::OPT_static))
CmdArgs.push_back("--end-group");
- else {
- if (!D.CCCIsCXX)
- CmdArgs.push_back("-lgcc");
-
- if (!D.CCCIsCXX)
- CmdArgs.push_back("--as-needed");
- CmdArgs.push_back("-lgcc_s");
- if (!D.CCCIsCXX)
- CmdArgs.push_back("--no-as-needed");
-
- if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX)
- CmdArgs.push_back("-lgcc");
- }
+ else
+ AddLibgcc(D, CmdArgs, Args);
if (!Args.hasArg(options::OPT_nostartfiles)) {
More information about the cfe-commits
mailing list