From 23c78ebef866ae869419953415e882b4c1ff1177 Mon Sep 17 00:00:00 2001 From: Paulo Dalla Santa Date: Wed, 23 Sep 2026 18:25:20 -0300 Subject: [PATCH 1/2] ghdl: copy sim_flags before appending generics _get_command() extended the "ghdl.sim_flags" list stored in sim_options in place. Configurations added after set_sim_option() share that list (shallow Configuration.copy()), so it grew with the -g flags of every simulation and a configuration inherited generics set by earlier ones that it doesn't set itself. Parallel runs made this order dependent. --- vunit/sim_if/ghdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vunit/sim_if/ghdl.py b/vunit/sim_if/ghdl.py index bb28a5c85..b6898747b 100644 --- a/vunit/sim_if/ghdl.py +++ b/vunit/sim_if/ghdl.py @@ -347,7 +347,7 @@ def _get_command( else: cmd += [config.entity_name, config.architecture_name] - sim = config.sim_options.get("ghdl.sim_flags", []) + sim = list(config.sim_options.get("ghdl.sim_flags", [])) sim += hooks.get_flags(self, "run_flags") for name, value in config.generics.items(): sim += [f"-g{name!s}={value!s}"] From f4904d540b4a27d5dd6c429009a8791f0cf1f36f Mon Sep 17 00:00:00 2001 From: Paulo Dalla Santa Date: Thu, 15 Oct 2026 15:34:41 -0300 Subject: [PATCH 2/2] Add a test and a news fragment for the shared ghdl.sim_flags fix --- docs/news.d/1223.bugfix.rst | 1 + tests/unit/test_ghdl_interface.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 docs/news.d/1223.bugfix.rst diff --git a/docs/news.d/1223.bugfix.rst b/docs/news.d/1223.bugfix.rst new file mode 100644 index 000000000..b12a12842 --- /dev/null +++ b/docs/news.d/1223.bugfix.rst @@ -0,0 +1 @@ +GHDL: a configuration no longer inherits the generics of other configurations through a shared ``ghdl.sim_flags`` list. diff --git a/tests/unit/test_ghdl_interface.py b/tests/unit/test_ghdl_interface.py index e72fa8967..70d6a3ded 100644 --- a/tests/unit/test_ghdl_interface.py +++ b/tests/unit/test_ghdl_interface.py @@ -286,6 +286,34 @@ def test_elaborate_e_project(self, determine_version): ], ) + @mock.patch.object(GHDLInterface, "determine_version", return_value=5.0) + def test_sim_flags_are_not_shared_between_configurations(self, determine_version): + design_unit = Entity("tb_entity", file_name=str(Path("tempdir") / "file.vhd")) + design_unit.generic_names = ["runner_cfg", "a", "b"] + + # A configuration added after setting ghdl.sim_flags is a shallow copy and shares the list of flags + default_config = Configuration("default", design_unit) + default_config.set_sim_option("ghdl.sim_flags", ["--ieee-asserts=disable"]) + sets_b = default_config.copy() + sets_b.set_generic("b", 1) + sets_a = default_config.copy() + sets_a.set_generic("a", 1) + + simif = GHDLInterface(prefix="prefix", output_path="") + simif._vhdl_standard = VHDL.standard("2008") # pylint: disable=protected-access + simif._project = Project() # pylint: disable=protected-access + simif._project.add_library("lib", "lib_path") # pylint: disable=protected-access + + def get_generic_flags(config): + cmd = simif._get_command( # pylint: disable=protected-access + config, str(Path("output_path") / "ghdl"), False, False, "tb_entity", None + ) + return [flag for flag in cmd if flag.startswith("-g")] + + self.assertEqual(get_generic_flags(sets_b), ["-gb=1"]) + self.assertEqual(get_generic_flags(sets_a), ["-ga=1"]) + self.assertEqual(default_config.sim_options["ghdl.sim_flags"], ["--ieee-asserts=disable"]) + @mock.patch.object(GHDLInterface, "determine_version", return_value=5.0) def test_prefix_is_a_read_only_property(self, determine_version): simif = GHDLInterface(prefix="prefix", output_path="")