diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -2452,15 +2452,6 @@ } } - // Now that we have every file, we can decide if we will need a - // dynamic symbol table. - // We need one if we were asked to export dynamic symbols or if we are - // producing a shared library. - // We also need one if any shared libraries are used and for pie executables - // (probably because the dynamic linker needs it). - config->hasDynSymTab = - !sharedFiles.empty() || config->isPic || config->exportDynamic; - // Some symbols (such as __ehdr_start) are defined lazily only when there // are undefined symbols for them, so we add these to trigger that logic. for (StringRef name : script->referencedSymbols) { @@ -2579,6 +2570,7 @@ // // With this the symbol table should be complete. After this, no new names // except a few linker-synthesized ones will be added to the symbol table. + const size_t numFilesBeforeLTO = files.size(); const size_t numObjsBeforeLTO = objectFiles.size(); invokeELFT(compileBitcodeFiles, skipLinkedOutput); @@ -2594,6 +2586,23 @@ if (skipLinkedOutput) return; + { + llvm::TimeTraceScope timeScope("Parse input files"); + for (size_t i = numFilesBeforeLTO; i < files.size(); ++i) { + llvm::TimeTraceScope timeScope("Parse input files", files[i]->getName()); + parseFile(files[i]); + } + } + + // Now that we have every file, we can decide if we will need a + // dynamic symbol table. + // We need one if we were asked to export dynamic symbols or if we are + // producing a shared library. + // We also need one if any shared libraries are used and for pie executables + // (probably because the dynamic linker needs it). + config->hasDynSymTab = + !sharedFiles.empty() || config->isPic || config->exportDynamic; + // compileBitcodeFiles may have produced lto.tmp object files. After this, no // more file will be added. auto newObjectFiles = makeArrayRef(objectFiles).slice(numObjsBeforeLTO);