From a8a21d30a1fc357831b9f6c02a17b9738ea4f97d Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Mon, 23 Jul 2018 10:43:45 -0500 Subject: [PATCH 1/2] Implement Linker command/response files in make export --- tools/export/makefile/Makefile.tmpl | 3 ++- tools/export/makefile/__init__.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/export/makefile/Makefile.tmpl b/tools/export/makefile/Makefile.tmpl index 83a7f2b039e..c53a311af73 100644 --- a/tools/export/makefile/Makefile.tmpl +++ b/tools/export/makefile/Makefile.tmpl @@ -135,8 +135,9 @@ $(PROJECT).link_script{{link_script_ext}}: $(LINKER_SCRIPT) {% block target_project_elf %} $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) {% if pp_cmd -%} $(PROJECT).link_script{{link_script_ext}} {% else%} $(LINKER_SCRIPT) {% endif %} + $(file > $@.in, $(filter %.o, $^)) +@echo "link: $(notdir $@)" - @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS) + @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ {{response_option}}$@.in $(LIBRARIES) $(LD_SYS_LIBS) {% endblock %} $(PROJECT).bin: $(PROJECT).elf diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index 0c1c07bbd3b..c4d7412a0af 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -113,6 +113,7 @@ def generate(self): 'user_library_flag': self.USER_LIBRARY_FLAG, 'needs_asm_preproc': self.PREPROCESS_ASM, 'shell_escape': shell_escape, + 'response_option': self.RESPONSE_OPTION, } if hasattr(self.toolchain, "preproc"): @@ -233,6 +234,7 @@ class GccArm(Makefile): TOOLCHAIN = "GCC_ARM" LINK_SCRIPT_OPTION = "-T" USER_LIBRARY_FLAG = "-L" + RESPONSE_OPTION = "@" @staticmethod def prepare_lib(libname): @@ -250,6 +252,7 @@ class Arm(Makefile): LINK_SCRIPT_OPTION = "--scatter" USER_LIBRARY_FLAG = "--userlibpath " TEMPLATE = 'make-arm' + RESPONSE_OPTION = "--via " @staticmethod def prepare_lib(libname): @@ -289,6 +292,7 @@ class IAR(Makefile): TOOLCHAIN = "IAR" LINK_SCRIPT_OPTION = "--config" USER_LIBRARY_FLAG = "-L" + RESPONSE_OPTION = "-f " @staticmethod def prepare_lib(libname): From 6918e6a76b7ab3e0e7b4f89319ea39d3dad0972b Mon Sep 17 00:00:00 2001 From: Volodymyr Medvid Date: Mon, 4 Feb 2019 20:10:39 +0200 Subject: [PATCH 2/2] makefile export: create .link_options.txt with echo $(file > $@.in, $(filter %.o, $^)) is not supported in GNU Make 3.81. Create the linker response file with pipe redirect from echo command. This is tested with Cygwin make and make 3.8.1 shipped with macOS. Also, change the linker responce file name to .link_options.txt. This is an internal file, not a build artifact. --- tools/export/makefile/Makefile.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/export/makefile/Makefile.tmpl b/tools/export/makefile/Makefile.tmpl index c53a311af73..6dca2f531b9 100644 --- a/tools/export/makefile/Makefile.tmpl +++ b/tools/export/makefile/Makefile.tmpl @@ -135,9 +135,9 @@ $(PROJECT).link_script{{link_script_ext}}: $(LINKER_SCRIPT) {% block target_project_elf %} $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) {% if pp_cmd -%} $(PROJECT).link_script{{link_script_ext}} {% else%} $(LINKER_SCRIPT) {% endif %} - $(file > $@.in, $(filter %.o, $^)) + +@echo "$(filter %.o, $^)" > .link_options.txt +@echo "link: $(notdir $@)" - @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ {{response_option}}$@.in $(LIBRARIES) $(LD_SYS_LIBS) + @$(LD) $(LD_FLAGS) {{link_script_option}} $(filter-out %.o, $^) $(LIBRARY_PATHS) --output $@ {{response_option}}.link_options.txt $(LIBRARIES) $(LD_SYS_LIBS) {% endblock %} $(PROJECT).bin: $(PROJECT).elf