Fix to use parallel build for projects with a lot of files (#4116)

This commit is contained in:
Krzysztof Boroński 2023-04-15 00:52:05 +02:00 committed by GitHub
parent 7d3b3761b2
commit 754a0b8320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -26,6 +26,9 @@ class V3HierBlockPlan;
class V3EmitMk final {
public:
// Number of source files after which to use parallel compiles
static const size_t PARALLEL_FILE_CNT_THRESHOLD = 128;
static void emitmk();
static void emitHierVerilation(const V3HierBlockPlan* planp);
};

View File

@ -565,6 +565,13 @@ static void process() {
reportStatsIfEnabled();
if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) {
size_t src_f_cnt = 0;
for (AstNode* nodep = v3Global.rootp()->filesp(); nodep; nodep = nodep->nextp()) {
if (const AstCFile* cfilep = VN_CAST(nodep, CFile))
src_f_cnt += cfilep->source() ? 1 : 0;
}
if (src_f_cnt >= V3EmitMk::PARALLEL_FILE_CNT_THRESHOLD) v3Global.useParallelBuild(true);
// Makefile must be after all other emitters
if (v3Global.opt.main()) V3EmitCMain::emit();
if (v3Global.opt.cmake()) V3EmitCMake::emit();