From: Sterling Augustine Date: Thu, 30 Aug 2018 20:42:49 +0000 (+0000) Subject: Revert r341107. That change breaks lto-android in a way is untested. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3572b0bd5d582e9a7049abec5aad8ec8afb63a9b;p=platform%2Fupstream%2Fllvm.git Revert r341107. That change breaks lto-android in a way is untested. llvm-svn: 341114 --- diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 8657174..1e093b2 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1126,41 +1126,23 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, bool IsIAMCU = Triple.isOSIAMCU(); bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || Args.hasArg(options::OPT_static); - // The driver ignores -shared-libgcc and therefore treats such cases as - // unspecified. Breaking out the two variables as below makes the current - // behavior explicit. - bool UnspecifiedLibgcc = !StaticLibgcc; - bool SharedLibgcc = !StaticLibgcc; - - // Gcc adds libgcc arguments in various ways: - // - // gcc : -lgcc --as-needed -lgcc_s --no-as-needed - // g++ : -lgcc_s -lgcc - // gcc shared: -lgcc_s -lgcc - // g++ shared: -lgcc_s -lgcc - // gcc static: -lgcc -lgcc_eh - // g++ static: -lgcc -lgcc_eh - // - // Also, certain targets need additional adjustments. - - bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc; - if (LibGccFirst) + if (!D.CCCIsCXX()) CmdArgs.push_back("-lgcc"); - bool AsNeeded = D.CCCIsCC() && !StaticLibgcc && !isCygMing; - if (AsNeeded) - CmdArgs.push_back("--as-needed"); - - if (UnspecifiedLibgcc || SharedLibgcc) + if (StaticLibgcc || isAndroid) { + if (D.CCCIsCXX()) + CmdArgs.push_back("-lgcc"); + } else { + if (!D.CCCIsCXX() && !isCygMing) + CmdArgs.push_back("--as-needed"); CmdArgs.push_back("-lgcc_s"); + if (!D.CCCIsCXX() && !isCygMing) + CmdArgs.push_back("--no-as-needed"); + } - else if (StaticLibgcc && !isAndroid && !IsIAMCU) + if (StaticLibgcc && !isAndroid && !IsIAMCU) CmdArgs.push_back("-lgcc_eh"); - - if (AsNeeded) - CmdArgs.push_back("--no-as-needed"); - - if (!LibGccFirst) + else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX()) CmdArgs.push_back("-lgcc"); // According to Android ABI, we have to link with libdl if we are