r366013 - [Driver] Simplify AddLibgcc

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 14 00:16:14 PDT 2019


Author: maskray
Date: Sun Jul 14 00:16:13 2019
New Revision: 366013

URL: http://llvm.org/viewvc/llvm-project?rev=366013&view=rev
Log:
[Driver] Simplify AddLibgcc

Modified:
    cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=366013&r1=366012&r2=366013&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Sun Jul 14 00:16:13 2019
@@ -1194,17 +1194,11 @@ static void AddUnwindLibrary(const ToolC
 
 static void AddLibgcc(const ToolChain &TC, const Driver &D,
                       ArgStringList &CmdArgs, const ArgList &Args) {
-  bool isAndroid = TC.getTriple().isAndroid();
-
   LibGccType LGT = getLibGccType(D, Args);
-  bool LibGccFirst = (D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc) ||
-                     LGT == LibGccType::StaticLibGcc;
-  if (LibGccFirst)
+  if (LGT != LibGccType::SharedLibGcc)
     CmdArgs.push_back("-lgcc");
-
   AddUnwindLibrary(TC, D, CmdArgs, Args);
-
-  if (!LibGccFirst)
+  if (LGT == LibGccType::SharedLibGcc)
     CmdArgs.push_back("-lgcc");
 
   // According to Android ABI, we have to link with libdl if we are
@@ -1212,7 +1206,7 @@ static void AddLibgcc(const ToolChain &T
   //
   // NOTE: This fixes a link error on Android MIPS as well.  The non-static
   // libgcc for MIPS relies on _Unwind_Find_FDE and dl_iterate_phdr from libdl.
-  if (isAndroid && getLibGccType(D, Args) != LibGccType::StaticLibGcc)
+  if (TC.getTriple().isAndroid() && LGT != LibGccType::StaticLibGcc)
     CmdArgs.push_back("-ldl");
 }
 




More information about the cfe-commits mailing list