From 41d8efb607700cc0953a60ffc56fc55cc0c357cf Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Mon, 13 Jun 2016 15:26:33 +0100 Subject: [PATCH 1/2] GCC_ARM changes to support uVisor. Other changes to test tools --- tools/export/gcc_arm_common.tmpl | 5 ++--- tools/test.py | 7 +++++-- tools/toolchains/__init__.py | 10 +++++----- tools/toolchains/gcc.py | 14 +++++++------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/export/gcc_arm_common.tmpl b/tools/export/gcc_arm_common.tmpl index d641b0af3dd..d7a03a1c805 100644 --- a/tools/export/gcc_arm_common.tmpl +++ b/tools/export/gcc_arm_common.tmpl @@ -37,12 +37,11 @@ CPU = {% block cpu %}{% for cf in cpu_flags %}{{cf|replace("-mfloat-abi=softfp", CC_FLAGS = {% block cc_flags %}$(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP{% endblock %} CC_SYMBOLS = {% block cc_symbols %}{% for s in symbols %}-D{{s}} {% endfor %}{% endblock %} -LD_FLAGS = {%- block ld_flags -%} +LD_FLAGS = {%- block ld_flags -%} $(CPU) -Wl,--gc-sections --specs=nano.specs -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r -Wl,--wrap,_realloc_r {%- if "-mcpu=cortex-m0" in cpu_flags or "-mcpu=cortex-m0plus" in cpu_flags -%} -{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref #LD_FLAGS += -u _printf_float -u _scanf_float {%- else -%} -{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref +{{ ' ' }}-u _printf_float -u _scanf_float {%- endif -%} {% endblock %} LD_SYS_LIBS = {% block ld_sys_libs %}-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys{% endblock %} diff --git a/tools/test.py b/tools/test.py index 1c7fbcd5d2c..16e002bee2a 100644 --- a/tools/test.py +++ b/tools/test.py @@ -21,6 +21,7 @@ import sys import os import json +import fnmatch ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) sys.path.insert(0, ROOT) @@ -105,8 +106,10 @@ all_tests_keys = all_tests.keys() for name in all_names: - if name in all_tests_keys: - tests[name] = all_tests[name] + if any(fnmatch.fnmatch(testname, name) for testname in all_tests): + for testname, test in all_tests.items(): + if fnmatch.fnmatch(testname, name): + tests[testname] = test else: print "[Warning] Test with name '%s' was not found in the available tests" % (name) else: diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 8f55af6800e..ae0006bb671 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -251,9 +251,12 @@ def print_notify(self, event, silent=False): """ msg = None - if event['type'] in ['info', 'debug']: + if not self.VERBOSE and event['type'] == 'tool_error': msg = event['message'] - + + elif event['type'] in ['info', 'debug']: + msg = event['message'] + elif event['type'] == 'cc': event['severity'] = event['severity'].title() event['file'] = basename(event['file']) @@ -773,9 +776,6 @@ def link_program(self, r, tmp_path, name): def default_cmd(self, command): self.debug("Command: %s"% ' '.join(command)) _stdout, _stderr, _rc = run_cmd(command) - # Print all warning / erros from stderr to console output - for error_line in _stderr.splitlines(): - print error_line self.debug("Return: %s"% _rc) diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index f8e252dc794..aa71e1360e6 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -89,7 +89,7 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False, self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "-fno-rtti", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags - self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu + self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r"] + self.cpu self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] self.ar = join(tool_path, "arm-none-eabi-ar") @@ -175,7 +175,7 @@ def compile(self, cc, source, object, includes): cmd.extend(self.get_dep_option(object)) cmd.extend(["-o", object, source]) - + # Call cmdline hook cmd = self.hook.get_cmdline_compiler(cmd) @@ -194,13 +194,13 @@ def link(self, output, objects, libraries, lib_dirs, mem_map): name, _ = splitext(basename(l)) libs.append("-l%s" % name[3:]) libs.extend(["-l%s" % l for l in self.sys_libs]) - + # Build linker command map_file = splitext(output)[0] + ".map" cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"] if mem_map: cmd.extend(['-T', mem_map]) - + for L in lib_dirs: cmd.extend(['-L', L]) cmd.extend(libs) @@ -215,7 +215,7 @@ def link(self, output, objects, libraries, lib_dirs, mem_map): cmd_list = [] for c in cmd[1:]: if c: - cmd_list.append(('"%s"' % c) if not c.startswith('-') else c) + cmd_list.append(('"%s"' % c) if not c.startswith('-') else c) string = " ".join(cmd_list).replace("\\", "/") f.write(string) @@ -228,7 +228,7 @@ def archive(self, objects, lib_path): with open(archive_files, "wb") as f: o_list = [] for o in objects: - o_list.append('"%s"' % o) + o_list.append('"%s"' % o) string = " ".join(o_list).replace("\\", "/") f.write(string) @@ -268,7 +268,7 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False, self.cc += ["-DMBED_RTOS_SINGLE_THREAD"] self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"] - if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368", "ARM_BEETLE_SOC"]: + if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: self.ld.extend(["-u _printf_float", "-u _scanf_float"]) elif target.name in ["RZ_A1H", "VK_RZ_A1H", "ARCH_MAX", "DISCO_F407VG", "DISCO_F429ZI", "DISCO_F469NI", "NUCLEO_F401RE", "NUCLEO_F410RB", "NUCLEO_F411RE", "NUCLEO_F446RE", "ELMO_F411RE", "MTS_MDOT_F411RE", "MTS_DRAGONFLY_F411RE", "DISCO_F746NG"]: self.ld.extend(["-u_printf_float", "-u_scanf_float"]) From dcb0ea82ee660f47be30d986bd700c9cc2f662f5 Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Mon, 13 Jun 2016 15:31:53 +0100 Subject: [PATCH 2/2] Reapply gcc toolchain changes --- tools/toolchains/gcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index aa71e1360e6..4d7ee319d06 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -268,7 +268,7 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False, self.cc += ["-DMBED_RTOS_SINGLE_THREAD"] self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"] - if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: + if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368", "ARM_BEETLE_SOC"]: self.ld.extend(["-u _printf_float", "-u _scanf_float"]) elif target.name in ["RZ_A1H", "VK_RZ_A1H", "ARCH_MAX", "DISCO_F407VG", "DISCO_F429ZI", "DISCO_F469NI", "NUCLEO_F401RE", "NUCLEO_F410RB", "NUCLEO_F411RE", "NUCLEO_F446RE", "ELMO_F411RE", "MTS_MDOT_F411RE", "MTS_DRAGONFLY_F411RE", "DISCO_F746NG"]: self.ld.extend(["-u_printf_float", "-u_scanf_float"])