Index: lib/Driver/Tools.cpp |
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp |
index e26b93db12af2c6198f1f30743fb23be34fe5606..276d15eb8c344f19e782a867262c556cda2666e5 100644 |
--- a/lib/Driver/Tools.cpp |
+++ b/lib/Driver/Tools.cpp |
@@ -7717,10 +7717,12 @@ void nacltools::Link::ConstructJob(Compilation &C, const JobAction &JA, |
CmdArgs.push_back("--start-group"); |
CmdArgs.push_back("-lc"); |
// libc++ and PPAPI programs always require libpthread, so just always |
- // include it in the group. |
- Args.ClaimAllArgs(options::OPT_pthread); |
- Args.ClaimAllArgs(options::OPT_pthreads); |
- CmdArgs.push_back("-lpthread"); |
+ // include it in the group for C++. |
+ if (Args.hasArg(options::OPT_pthread) || |
+ Args.hasArg(options::OPT_pthreads) || |
+ D.CCCIsCXX()) { |
+ CmdArgs.push_back("-lpthread"); |
+ } |
CmdArgs.push_back("-lgcc"); |
CmdArgs.push_back("--as-needed"); |
@@ -8502,4 +8504,3 @@ void CrossWindows::Link::ConstructJob(Compilation &C, const JobAction &JA, |
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs)); |
} |
- |