diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-16 18:58:27 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-09-17 08:57:54 +0200 |
commit | 4eea8d4bc44116b3465d7fdeb053d66bf95428f4 (patch) | |
tree | e3c82bff46957925f0bf7d65e3eeb915273d22b3 | |
parent | bsps/arm: Use RTEMS_SECTION() (diff) | |
download | rtems-4eea8d4bc44116b3465d7fdeb053d66bf95428f4.tar.bz2 |
build: Fix dependencies for start and asm files
Add a feature to enforce an explicit target file for assembler sources.
Add a build start file node list and use it as a test program
dependency.
The fix for #3846 and #4080 needs to be combined, because the fix
for #3846 requires the removal of 'before=["cstlib"]'. This patch fixes
two issues:
1. The tracking of start file dependencies.
2. Reflect that executables depend on the start files.
We need a start.o file in the right path so that the linker can find is
as specified by the linker script, and not for example a start.S.17.o
file in some path. This part is addressed by the "explicit_asm_target"
feature.
This build process extension
@after("apply_link")
@feature("cprogram", "cxxprogram")
def process_start_files(self):
if getattr(self, "start_files", False):
self.link_task.dep_nodes.extend(self.bld.start_files)
addresses 2.
Close #3846.
Close #4080.
-rwxr-xr-x | wscript | 45 |
1 files changed, 38 insertions, 7 deletions
@@ -40,6 +40,8 @@ try: except: import ConfigParser as configparser +from waflib.TaskGen import after, before_method, feature + is_windows_host = os.name == "nt" or sys.platform in ["msys", "cygwin"] default_prefix = "/opt/rtems/6" compilers = ["gcc", "clang"] @@ -149,6 +151,31 @@ def _is_enabled(enabled, enabled_by): return enabled_by in enabled +def _asm_explicit_target(self, node): + task = self.create_task( + "asm", node, self.bld.bldnode.make_node(self.target) + ) + try: + self.compiled_tasks.append(task) + except AttributeError: + self.compiled_tasks = [task] + return task + + +@feature("asm_explicit_target") +@before_method("process_source") +def _enable_asm_explicit_target(self): + self.mappings = dict(self.mappings) # Copy + self.mappings[".S"] = _asm_explicit_target + + +@after("apply_link") +@feature("cprogram", "cxxprogram") +def process_start_files(self): + if getattr(self, "start_files", False): + self.link_task.dep_nodes.extend(self.bld.start_files) + + class Item(object): def __init__(self, uid, data): self.uid = uid @@ -241,17 +268,15 @@ class Item(object): for install in self.data["install"]: bld.install_files(install["destination"], install["source"]) - def asm(self, bld, bic, source, target=None, deps=[], cppflags=[]): + def asm(self, bld, bic, source, target=None): if target is None: target = os.path.splitext(source)[0] + ".o" bld( asflags=self.data["asflags"], - before=["cstlib"], - cppflags=cppflags + self.data["cppflags"], - features="asm c", + cppflags=self.data["cppflags"], + features="asm_explicit_target asm c", includes=bic.includes + self.data["includes"], - rule="${CC} ${ASFLAGS} ${CPPFLAGS} ${DEFINES_ST:DEFINES} ${CPPPATH_ST:INCPATHS} -c ${SRC[0]} -o ${TGT}", - source=[source] + deps, + source=[source], target=target, ) return target @@ -532,7 +557,12 @@ class StartFileItem(Item): super(StartFileItem, self).__init__(uid, data) def do_build(self, bld, bic): - self.asm(bld, bic, self.data["source"], self.get(bld, "target")) + tgt = self.asm(bld, bic, self.data["source"], self.get(bld, "target")) + node = bld.bldnode.make_node(tgt) + try: + bld.start_files.append(node) + except AttributeError: + bld.start_files = [node] self.install_target(bld) @@ -626,6 +656,7 @@ class TestProgramItem(Item): install_path=None, ldflags=bic.ldflags + self.data["ldflags"], source=self.data["source"], + start_files=True, stlib=self.data["stlib"], target=self.get(bld, "target"), use=self.data["use-before"] + bic.use + self.data["use-after"], |