From 0068b71558e31120270acfaeb182d73ed7fe5f14 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Mon, 8 Sep 2025 13:33:46 +0200 Subject: [PATCH] Ensure static IdStrings get prepopulated when initializing yosys An alternative would be to call ensure_prepopulated() in various IdString methods. --- kernel/rtlil.h | 9 +++++++-- kernel/yosys.cc | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 471aa5e5f..9112ae64b 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -217,8 +217,7 @@ struct RTLIL::IdString return it->second; } - if (global_id_index_.empty()) - prepopulate(); + ensure_prepopulated(); if (!p[0]) return 0; @@ -457,6 +456,12 @@ struct RTLIL::IdString private: static void prepopulate(); + +public: + static void ensure_prepopulated() { + if (global_id_index_.empty()) + prepopulate(); + } }; namespace hashlib { diff --git a/kernel/yosys.cc b/kernel/yosys.cc index fee951b0f..3b982c655 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -196,6 +196,8 @@ void yosys_setup() already_setup = true; already_shutdown = false; + IdString::ensure_prepopulated(); + #ifdef WITH_PYTHON // With Python 3.12, calling PyImport_AppendInittab on an already // initialized platform fails (such as when libyosys is imported