Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: toolchains/arm.py
- Revision:
- 13:ab47a20b66f0
- Parent:
- 7:5af61d55adbe
- Child:
- 20:835f6355470d
diff -r f2e8a005c7d3 -r ab47a20b66f0 toolchains/arm.py
--- a/toolchains/arm.py Tue Jun 14 11:33:06 2016 +0100
+++ b/toolchains/arm.py Thu Jul 14 20:21:19 2016 +0100
@@ -21,9 +21,9 @@
from tools.settings import ARM_BIN, ARM_INC, ARM_LIB, MY_ARM_CLIB, ARM_CPPLIB, GOANNA_PATH
from tools.hooks import hook_tool
from tools.utils import mkdir
+import copy
class ARM(mbedToolchain):
- PROFILE = {}
LINKER_EXT = '.sct'
LIBRARY_EXT = '.ar'
@@ -31,42 +31,52 @@
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)')
DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, profile=None):
- mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose, profile=profile)
+
+ DEFAULT_FLAGS = {
+ 'common': ["-c", "--gnu",
+ "-Otime", "--split_sections", "--apcs=interwork",
+ "--brief_diagnostics", "--restrict", "--multibyte_chars", "-I \""+ARM_INC+"\""],
+ 'asm': [],
+ 'c': ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
+ 'cxx': ["--cpp", "--no_rtti", "--no_vla"],
+ 'ld': [],
+ }
+
+ def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
+ mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
if target.core == "Cortex-M0+":
cpu = "Cortex-M0"
elif target.core == "Cortex-M4F":
cpu = "Cortex-M4.fp"
+ elif target.core == "Cortex-M7FD":
+ cpu = "Cortex-M7.fp.dp"
elif target.core == "Cortex-M7F":
cpu = "Cortex-M7.fp.sp"
else:
cpu = target.core
main_cc = join(ARM_BIN, "armcc")
- common = self.PROFILE.get('COMMON_FLAGS', ["-c", "--gnu", "-O3",
- "-Otime", "--split_sections", "--apcs=interwork",
- ])
- common.extend(["--cpu=%s" % cpu, "--brief_diagnostics", "--restrict", "--multibyte_chars"])
- common.extend(['-I%s' % ARM_INC])
+ self.flags['common'] += ["--cpu=%s" % cpu]
if "save-asm" in self.options:
- common.extend(["--asm", "--interleave"])
+ self.flags['common'].extend(["--asm", "--interleave"])
if "debug-info" in self.options:
- common.append("-O0")
+ self.flags['common'].append("-g")
+ self.flags['c'].append("-O0")
else:
- common.append("-O3")
-
- # add debug symbols for all builds
- common.append("-g")
+ self.flags['c'].append("-O3")
- common_c = self.PROFILE.get('COMMON_C_FLAGS', ["--no_depend_system_headers"]) + ['--md']
+ self.asm = [main_cc] + self.flags['common'] + self.flags['asm']
+ if not "analyze" in self.options:
+ self.cc = [main_cc] + self.flags['common'] + self.flags['c']
+ self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
+ else:
+ self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c']
+ self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
- self.asm = [main_cc] + common
- self.cc = [main_cc] + common + common_c + self.PROFILE.get('COMMON_CC_FLAGS', ["--c99"])
- self.cppc = [main_cc] + common + common_c + self.PROFILE.get('COMMON_CPP_FLAGS', ["--cpp", "--no_rtti"])
- self.ld = [join(ARM_BIN, "armlink")] + self.PROFILE.get('COMMON_LD_FLAGS', [])
+ self.ld = [join(ARM_BIN, "armlink")]
self.sys_libs = []
self.ar = join(ARM_BIN, "armar")
@@ -106,8 +116,15 @@
dep_path = base + '.d'
return ["--depend", dep_path]
+ def get_config_option(self, config_header) :
+ return ['--preinclude=' + config_header]
+
def get_compile_options(self, defines, includes):
- return ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)]
+ opts = ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)]
+ config_header = self.get_config_header()
+ if config_header is not None:
+ opts = opts + self.get_config_option(config_header)
+ return opts
@hook_tool
def assemble(self, source, object, includes):
@@ -206,31 +223,41 @@
class ARM_STD(ARM):
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, profile=None):
- ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose, profile=profile)
- self.cc += ["-D__ASSERT_MSG"]
- self.cppc += ["-D__ASSERT_MSG"]
- self.ld.extend(["--libpath", ARM_LIB])
+ def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
+ ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
+
+ # Run-time values
+ self.ld.extend(["--libpath \"%s\"" % ARM_LIB])
class ARM_MICRO(ARM):
PATCHED_LIBRARY = False
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False, profile=None):
- ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose, profile=profile)
+ def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
+ ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
- # Compiler
+ # Extend flags
+ self.flags['common'].extend(["-D__MICROLIB"])
+ self.flags['c'].extend(["--library_type=microlib"])
+ self.flags['ld'].extend(["--library_type=microlib"])
+
+ # Run-time values
self.asm += ["-D__MICROLIB"]
- self.cc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
- self.cppc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
+ self.cc += ["-D__MICROLIB", "--library_type=microlib"]
+ self.cppc += ["-D__MICROLIB", "--library_type=microlib"]
+ self.ld += ["--library_type=microlib"]
- # Linker
- self.ld.append("--library_type=microlib")
+ # Only allow a single thread
+ self.cc += ["-DMBED_RTOS_SINGLE_THREAD"]
+ self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"]
# We had to patch microlib to add C++ support
# In later releases this patch should have entered mainline
if ARM_MICRO.PATCHED_LIBRARY:
- self.ld.append("--noscanlib")
+ # Run-time values
+ self.flags['ld'].extend(["--noscanlib"])
+ # Run-time values
+ self.ld += ["--noscanlib"]
# System Libraries
self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
@@ -241,4 +268,5 @@
elif target.core in ["Cortex-M0", "Cortex-M0+"]:
self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ps", "cpprt_p"]])
else:
- self.ld.extend(["--libpath", ARM_LIB])
+ # Run-time values
+ self.ld.extend(["--libpath \"%s\"" % ARM_LIB])
