From 6066641423cdc3c4c87f15b90e58cd2928df1b48 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 25 Nov 2016 20:20:57 +0000 Subject: [PATCH] We shouldn't call parallle_for_each if -no-thread is given. llvm-svn: 287948 --- lld/ELF/Driver.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 9f1bb74..2791428 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -801,15 +801,18 @@ template void LinkerDriver::link(opt::InputArgList &Args) { // MergeInputSection::splitIntoPieces needs to be called before // any call of MergeInputSection::getOffset. Do that. - parallel_for_each(Symtab.Sections.begin(), Symtab.Sections.end(), - [](InputSectionBase *S) { - if (!S->Live) - return; - if (S->Compressed) - S->uncompress(); - if (auto *MS = dyn_cast>(S)) - MS->splitIntoPieces(); - }); + auto Fn = [](InputSectionBase *S) { + if (!S->Live) + return; + if (S->Compressed) + S->uncompress(); + if (auto *MS = dyn_cast>(S)) + MS->splitIntoPieces(); + }; + if (Config->Threads) + parallel_for_each(Symtab.Sections.begin(), Symtab.Sections.end(), Fn); + else + std::for_each(Symtab.Sections.begin(), Symtab.Sections.end(), Fn); // Write the result to the file. writeResult(); -- 2.7.4