Skip to content

[toolchains] Refactor sys libs #3600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/export/makefile/Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SREC_CAT = srec_cat
{% endfor %}

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

# Tools and Flags
###############################################################################
Expand Down
17 changes: 17 additions & 0 deletions tools/export/makefile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def generate(self):

libraries = [self.prepare_lib(basename(lib)) for lib
in self.resources.libraries]
sys_libs = [self.prepare_sys_lib(lib) for lib
in self.toolchain.sys_libs]

ctx = {
'name': self.project_name,
Expand All @@ -61,6 +63,7 @@ def generate(self):
'library_paths': self.resources.lib_dirs,
'linker_script': self.resources.linker_script,
'libraries': libraries,
'ld_sys_libs': sys_libs,
'hex_files': self.resources.hex_files,
'vpath': (["../../.."]
if (basename(dirname(dirname(self.export_dir)))
Expand Down Expand Up @@ -171,6 +174,10 @@ class GccArm(Makefile):
def prepare_lib(libname):
return "-l:" + libname

@staticmethod
def prepare_sys_lib(libname):
return "-l" + libname


class Armc5(Makefile):
"""ARM Compiler 5 specific makefile target"""
Expand All @@ -186,6 +193,10 @@ class Armc5(Makefile):
def prepare_lib(libname):
return libname

@staticmethod
def prepare_sys_lib(libname):
return libname


class IAR(Makefile):
"""IAR specific makefile target"""
Expand All @@ -202,3 +213,9 @@ def prepare_lib(libname):
if "lib" == libname[:3]:
libname = libname[3:]
return "-l" + splitext(libname)[0]

@staticmethod
def prepare_sys_lib(libname):
if "lib" == libname[:3]:
libname = libname[3:]
return "-l" + splitext(libname)[0]
6 changes: 1 addition & 5 deletions tools/export/makefile/make-gcc-arm.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{% extends "makefile/Makefile.tmpl" %}

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

{% block elf2bin %}
$(ELF2BIN) -O binary $< $@
Expand Down
3 changes: 3 additions & 0 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def __init__(self, target, notify=None, macros=None, silent=False, extra_verbose
# Toolchain flags
self.flags = deepcopy(build_profile or self.profile_template)

# System libraries provided by the toolchain
self.sys_libs = []

# User-defined macros
self.macros = macros or []

Expand Down
1 change: 0 additions & 1 deletion tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def __init__(self, target, notify=None, macros=None,
self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']

self.ld = [join(ARM_BIN, "armlink")]
self.sys_libs = []

self.ar = join(ARM_BIN, "armar")
self.elf2bin = join(ARM_BIN, "fromelf")
Expand Down