From d92289d3fa25e97ebe4b68f3686436d8bee8a120 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 22 Jul 2026 07:38:31 +0800 Subject: [PATCH] build: Relink executables if a linkcmds changes Some BSPs provide linker scripts which are generated during `./waf configure`, for example the memory layout of `spec/build/bsps/arm/fvp/linkcmds.yml`. The executable link tasks did not depend on these generated files, so a reconfiguration which changed a linker script did not trigger a relink of the test programs, leaving stale executables. Add the configuration files collected in env.cfg_files (which include the generated linker scripts) as dependencies to all executable link tasks: - the standard cprogram/cxxprogram links via process_start_files(), - the custom link() task used by link_cc()/link_cxx(), and - the gnatmake() task. A change to any configuration file now relinks the executables. Assisted-by: Claude:claude-opus-4-8 claude-code Signed-off-by: Sebastian Huber --- wscript | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wscript b/wscript index c9511c5338..2de3e2dbec 100755 --- a/wscript +++ b/wscript @@ -223,9 +223,22 @@ def _enable_cxx_explicit_target(self): self.mappings[".cc"] = _cxx_explicit_target +def _cfg_file_nodes(bld): + # The configuration files (for example a generated linker script) are + # written during ./waf configure. Depend on them so that a reconfiguration + # which changes a linker script triggers a relink of the executables. + try: + return bld.cfg_file_nodes + except AttributeError: + nodes = [bld.root.make_node(f) for f in bld.env.cfg_files] + bld.cfg_file_nodes = nodes + return nodes + + @after("apply_link") @feature("cprogram", "cxxprogram") def process_start_files(self): + self.link_task.dep_nodes.extend(_cfg_file_nodes(self.bld)) if getattr(self, "start_files", False): self.link_task.dep_nodes.extend(self.bld.start_files) @@ -434,6 +447,7 @@ class Item(object): bic.ldflags + self.substitute(bld, self.data["ldflags"])) tsk.set_inputs([bld.bldnode.make_node(s) for s in source]) tsk.set_outputs(bld.bldnode.make_node(target)) + tsk.dep_nodes.extend(_cfg_file_nodes(bld)) bld.add_to_group(tsk) return target @@ -503,6 +517,7 @@ class Item(object): ) tsk = gnatmake(bld, bic, objdir, objs, main, target, self) + tsk.dep_nodes.extend(_cfg_file_nodes(bld)) bld.add_to_group(tsk) return target