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 <sebastian.huber@embedded-brains.de>
This commit is contained in:
Sebastian Huber authored and Kinsey Moore committed 2026-08-19 12:24:36 -05:00
1 parent 0788428d48
commit d92289d3fa
1 file changed
+15
+15
View File
@@ -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