diff options
-rw-r--r-- | lld/ELF/Config.h | 1 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 1 | ||||
-rw-r--r-- | lld/ELF/Options.td | 2 | ||||
-rw-r--r-- | lld/ELF/OutputSections.cpp | 10 |
4 files changed, 12 insertions, 2 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 273b756c0a5..aeaa0f9f52c 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -74,6 +74,7 @@ struct Configuration { bool Static = false; bool StripAll; bool SysvHash = true; + bool Threads; bool Verbose; bool ZExecStack; bool ZNodelete; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 8fff516946a..064938abaaa 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -239,6 +239,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->SaveTemps = Args.hasArg(OPT_save_temps); Config->Shared = Args.hasArg(OPT_shared); Config->StripAll = Args.hasArg(OPT_strip_all); + Config->Threads = Args.hasArg(OPT_threads); Config->Verbose = Args.hasArg(OPT_verbose); Config->DynamicLinker = getString(Args, OPT_dynamic_linker); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 24e984119c4..c11cb9469f2 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -118,6 +118,8 @@ def strip_all : Flag<["--"], "strip-all">, def sysroot : Joined<["--"], "sysroot=">, HelpText<"Set the system root">; +def threads : Joined<["--"], "threads">; + def undefined : Joined<["--"], "undefined=">, HelpText<"Force undefined symbol during linking">; diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 79705664b50..d9c0d160b4b 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -12,6 +12,7 @@ #include "LinkerScript.h" #include "SymbolTable.h" #include "Target.h" +#include "lld/Core/Parallel.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/MathExtras.h" #include <map> @@ -929,8 +930,13 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) { ArrayRef<uint8_t> Filler = Script->getFiller(this->Name); if (!Filler.empty()) fill(Buf, this->getSize(), Filler); - for (InputSection<ELFT> *C : Sections) - C->writeTo(Buf); + if (Config->Threads) { + parallel_for_each(Sections.begin(), Sections.end(), + [=](InputSection<ELFT> *C) { C->writeTo(Buf); }); + } else { + for (InputSection<ELFT> *C : Sections) + C->writeTo(Buf); + } } template <class ELFT> |