Skip to content

gcc - use group for ld to resolve symbols from libraries #1718

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
May 9, 2016
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 workspace_tools/export/gcc_arm_common.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ clean:

{% block target_project_elf %}
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ -Wl,--start-group $(LIBRARIES) $(LD_SYS_LIBS) -Wl,--end-group
{% endblock %}

$(PROJECT).bin: $(PROJECT).elf
Expand Down
10 changes: 1 addition & 9 deletions workspace_tools/toolchains/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class GCC(mbedToolchain):
LIBRARY_EXT = '.a'

STD_LIB_NAME = "lib%s.a"
CIRCULAR_DEPENDENCIES = True
DIAGNOSTIC_PATTERN = re.compile('((?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')

def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
Expand Down Expand Up @@ -171,15 +170,8 @@ def link(self, output, objects, libraries, lib_dirs, mem_map):
libs.append("-l%s" % name[3:])
libs.extend(["-l%s" % l for l in self.sys_libs])

# NOTE: There is a circular dependency between the mbed library and the clib
# We could define a set of week symbols to satisfy the clib dependencies in "sys.o",
# but if an application uses only clib symbols and not mbed symbols, then the final
# image is not correctly retargeted
if self.CIRCULAR_DEPENDENCIES:
libs.extend(libs)

self.default_cmd(self.hook.get_cmdline_linker(self.ld + ["-T%s" % mem_map, "-o", output] +
objects + ["-L%s" % L for L in lib_dirs] + libs))
objects + ["-L%s" % L for L in lib_dirs] + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"]))

@hook_tool
def binary(self, resources, elf, bin):
Expand Down