Skip to content

Commit 7316b89

Browse files
authored
Merge pull request #3600 from theotherjimmy/refactor-sys-libs
[toolchains] Refactor sys libs
2 parents 595b9cf + 3489b14 commit 7316b89

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

tools/export/makefile/Makefile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SREC_CAT = srec_cat
8080
{% endfor %}
8181

8282
LD_FLAGS :={%- block ld_flags -%} {{ld_flags|join(" ")}} {% endblock %}
83-
{% block sys_libs -%}{%- endblock %}
83+
LD_SYS_LIBS :={%- block sys_libs -%} {{ld_sys_libs|join(" ")}} {% endblock %}
8484

8585
# Tools and Flags
8686
###############################################################################

tools/export/makefile/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def generate(self):
5252

5353
libraries = [self.prepare_lib(basename(lib)) for lib
5454
in self.resources.libraries]
55+
sys_libs = [self.prepare_sys_lib(lib) for lib
56+
in self.toolchain.sys_libs]
5557

5658
ctx = {
5759
'name': self.project_name,
@@ -61,6 +63,7 @@ def generate(self):
6163
'library_paths': self.resources.lib_dirs,
6264
'linker_script': self.resources.linker_script,
6365
'libraries': libraries,
66+
'ld_sys_libs': sys_libs,
6467
'hex_files': self.resources.hex_files,
6568
'vpath': (["../../.."]
6669
if (basename(dirname(dirname(self.export_dir)))
@@ -171,6 +174,10 @@ class GccArm(Makefile):
171174
def prepare_lib(libname):
172175
return "-l:" + libname
173176

177+
@staticmethod
178+
def prepare_sys_lib(libname):
179+
return "-l" + libname
180+
174181

175182
class Armc5(Makefile):
176183
"""ARM Compiler 5 specific makefile target"""
@@ -186,6 +193,10 @@ class Armc5(Makefile):
186193
def prepare_lib(libname):
187194
return libname
188195

196+
@staticmethod
197+
def prepare_sys_lib(libname):
198+
return libname
199+
189200

190201
class IAR(Makefile):
191202
"""IAR specific makefile target"""
@@ -202,3 +213,9 @@ def prepare_lib(libname):
202213
if "lib" == libname[:3]:
203214
libname = libname[3:]
204215
return "-l" + splitext(libname)[0]
216+
217+
@staticmethod
218+
def prepare_sys_lib(libname):
219+
if "lib" == libname[:3]:
220+
libname = libname[3:]
221+
return "-l" + splitext(libname)[0]

tools/export/makefile/make-gcc-arm.tmpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{% extends "makefile/Makefile.tmpl" %}
22

3-
{% block sys_libs %}
4-
{% for lib in ["-lstdc++", "-lsupc++", "-lm", "-lc", "-lgcc", "-lnosys"] -%}
5-
LD_SYS_LIBS += {{lib}}
6-
{% endfor %}
7-
{%- endblock %}
3+
{%- block sys_libs -%} -Wl,--start-group {{ld_sys_libs|join(" ")}} -Wl,--end-group {%- endblock -%}
84

95
{% block elf2bin %}
106
$(ELF2BIN) -O binary $< $@

tools/toolchains/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ def __init__(self, target, notify=None, macros=None, silent=False, extra_verbose
266266
# Toolchain flags
267267
self.flags = deepcopy(build_profile or self.profile_template)
268268

269+
# System libraries provided by the toolchain
270+
self.sys_libs = []
271+
269272
# User-defined macros
270273
self.macros = macros or []
271274

tools/toolchains/arm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def __init__(self, target, notify=None, macros=None,
6666
self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
6767

6868
self.ld = [join(ARM_BIN, "armlink")]
69-
self.sys_libs = []
7069

7170
self.ar = join(ARM_BIN, "armar")
7271
self.elf2bin = join(ARM_BIN, "fromelf")

0 commit comments

Comments
 (0)