2013-08-06 13:38:00 +00:00
|
|
|
"""
|
|
|
|
mbed SDK
|
2019-03-06 20:34:09 +00:00
|
|
|
Copyright (c) 2011-2019 ARM Limited
|
2020-02-20 14:22:24 +00:00
|
|
|
SPDX-License-Identifier: Apache-2.0
|
2013-08-06 13:38:00 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
2016-06-09 22:50:03 +00:00
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
2013-08-06 13:38:00 +00:00
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
"""
|
2018-02-23 15:57:02 +00:00
|
|
|
from __future__ import print_function, absolute_import
|
2019-03-01 16:02:44 +00:00
|
|
|
from builtins import str # noqa: F401
|
2018-02-23 15:57:02 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
import re
|
2016-09-23 16:36:46 +00:00
|
|
|
from copy import copy
|
2019-10-23 08:41:04 +00:00
|
|
|
from os.path import join, dirname, splitext, basename, exists, isfile, relpath, sep
|
2019-03-01 16:02:44 +00:00
|
|
|
from os import makedirs, write, remove
|
2017-02-01 22:22:06 +00:00
|
|
|
from tempfile import mkstemp
|
2018-03-13 10:32:24 +00:00
|
|
|
from shutil import rmtree
|
2018-06-19 15:41:08 +00:00
|
|
|
from distutils.version import LooseVersion
|
2013-06-24 13:32:08 +00:00
|
|
|
|
2020-03-20 14:54:35 +00:00
|
|
|
from tools.toolchains.mbed_toolchain import (
|
|
|
|
mbedToolchain, TOOLCHAIN_PATHS, should_replace_small_c_lib
|
|
|
|
)
|
2019-03-29 16:12:13 +00:00
|
|
|
from tools.utils import mkdir, NotSupportedException, run_cmd
|
2019-03-06 20:34:09 +00:00
|
|
|
from tools.resources import FileRef
|
2013-06-24 13:32:08 +00:00
|
|
|
|
2020-05-22 14:34:07 +00:00
|
|
|
ARMC5_MIGRATION_WARNING = (
|
2020-05-22 14:37:19 +00:00
|
|
|
"Warning: Arm Compiler 5 is no longer supported as of Mbed 6. "
|
2020-05-22 14:34:07 +00:00
|
|
|
"Please upgrade your environment to Arm Compiler 6 "
|
|
|
|
"which is free to use with Mbed OS. For more information, "
|
|
|
|
"please visit https://os.mbed.com/docs/mbed-os/latest/tools/index.html"
|
|
|
|
)
|
|
|
|
|
Enabling small C library option and deprecating uARM toolchain
- By default, Mbed OS build tools use standard C library for all supported toolchains.
It is possible to use smaller C libraries by overriding the "target.default_lib" option
with "small". This option is only currently supported for the GCC_ARM toolchain.
This override config option is now extended in the build tool for ARM toolchain.
- Add configuration option to specify libraries supported for each toolchain per targets.
- Move __aeabi_assert function from rtos to retarget code so it’s available for bare metal.
- Use 2 memory region model for ARM toolchain scatter file for the following targets:
NUCLEO_F207ZG, STM32F411xE, STM32F429xI, NUCLEO_L073RZ, STM32F303xE
- Add a warning message in the build tools to deprecate uARM toolchain.
- NewLib-Nano C library is not supporting floating-point and printf with %hhd,%hhu,%hhX,%lld,%llu,%llX
format specifier so skipping those green tea test cases.
2019-10-08 15:04:02 +00:00
|
|
|
UARM_TOOLCHAIN_WARNING = (
|
2020-01-15 12:51:45 +00:00
|
|
|
"Warning: We noticed that you are using uARM Toolchain either via --toolchain command line or default_toolchain option. "
|
|
|
|
"We are deprecating the use of the uARM Toolchain. "
|
2020-01-07 14:44:40 +00:00
|
|
|
"For more information on how to use the ARM toolchain with small C libraries, "
|
|
|
|
"please visit https://os.mbed.com/docs/mbed-os/latest/reference/using-small-c-libraries.html"
|
|
|
|
)
|
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
class ARM(mbedToolchain):
|
|
|
|
LINKER_EXT = '.sct'
|
|
|
|
LIBRARY_EXT = '.ar'
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
STD_LIB_NAME = "%s.ar"
|
2019-03-01 16:02:44 +00:00
|
|
|
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error|Fatal error): (?P<message>.+)')
|
|
|
|
INDEX_PATTERN = re.compile('(?P<col>\s*)\^')
|
2013-06-24 13:32:08 +00:00
|
|
|
DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')
|
2016-09-23 16:36:46 +00:00
|
|
|
SHEBANG = "#! armcc -E"
|
2019-03-01 16:02:44 +00:00
|
|
|
SUPPORTED_CORES = [
|
|
|
|
"Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4", "Cortex-M4F",
|
|
|
|
"Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-A9"
|
|
|
|
]
|
2018-06-19 15:41:08 +00:00
|
|
|
ARMCC_RANGE = (LooseVersion("5.06"), LooseVersion("5.07"))
|
2019-03-19 22:33:40 +00:00
|
|
|
ARMCC_PRODUCT_RE = re.compile(b"Product: (.*)")
|
2018-07-10 18:59:22 +00:00
|
|
|
ARMCC_VERSION_RE = re.compile(b"Component: ARM Compiler (\d+\.\d+)")
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2016-09-12 23:54:39 +00:00
|
|
|
@staticmethod
|
|
|
|
def check_executable():
|
2016-09-13 17:06:01 +00:00
|
|
|
"""Returns True if the executable (armcc) location specified by the
|
|
|
|
user exists OR the executable can be found on the PATH.
|
|
|
|
Returns False otherwise."""
|
2016-09-13 18:38:58 +00:00
|
|
|
return mbedToolchain.generic_check_executable("ARM", 'armcc', 2, 'bin')
|
2016-09-12 23:54:39 +00:00
|
|
|
|
2016-09-27 18:15:22 +00:00
|
|
|
def __init__(self, target, notify=None, macros=None,
|
2019-11-20 15:58:37 +00:00
|
|
|
build_profile=None, build_dir=None, coverage_patterns=None):
|
2018-04-25 19:21:25 +00:00
|
|
|
mbedToolchain.__init__(
|
|
|
|
self, target, notify, macros, build_dir=build_dir,
|
|
|
|
build_profile=build_profile)
|
2017-10-20 15:05:37 +00:00
|
|
|
if target.core not in self.SUPPORTED_CORES:
|
|
|
|
raise NotSupportedException(
|
|
|
|
"this compiler does not support the core %s" % target.core)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2020-03-20 14:54:35 +00:00
|
|
|
toolchain = "arm"
|
|
|
|
|
|
|
|
if should_replace_small_c_lib(target, toolchain):
|
|
|
|
target.c_lib = "std"
|
|
|
|
|
|
|
|
self.check_c_lib_supported(target, toolchain)
|
Enabling small C library option and deprecating uARM toolchain
- By default, Mbed OS build tools use standard C library for all supported toolchains.
It is possible to use smaller C libraries by overriding the "target.default_lib" option
with "small". This option is only currently supported for the GCC_ARM toolchain.
This override config option is now extended in the build tool for ARM toolchain.
- Add configuration option to specify libraries supported for each toolchain per targets.
- Move __aeabi_assert function from rtos to retarget code so it’s available for bare metal.
- Use 2 memory region model for ARM toolchain scatter file for the following targets:
NUCLEO_F207ZG, STM32F411xE, STM32F429xI, NUCLEO_L073RZ, STM32F303xE
- Add a warning message in the build tools to deprecate uARM toolchain.
- NewLib-Nano C library is not supporting floating-point and printf with %hhd,%hhu,%hhX,%lld,%llu,%llX
format specifier so skipping those green tea test cases.
2019-10-08 15:04:02 +00:00
|
|
|
|
2019-12-10 17:20:34 +00:00
|
|
|
if (
|
|
|
|
getattr(target, "default_toolchain", "ARM") == "uARM"
|
2020-01-17 13:51:41 +00:00
|
|
|
or getattr(target, "c_lib", "std") == "small"
|
2019-12-10 17:20:34 +00:00
|
|
|
):
|
2018-06-12 14:29:10 +00:00
|
|
|
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
|
|
|
|
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
|
2018-08-07 18:21:03 +00:00
|
|
|
if "-D__MICROLIB" not in self.flags['common']:
|
|
|
|
self.flags['common'].append("-D__MICROLIB")
|
2018-06-12 14:29:10 +00:00
|
|
|
if "--library_type=microlib" not in self.flags['ld']:
|
|
|
|
self.flags['ld'].append("--library_type=microlib")
|
2018-08-07 18:21:03 +00:00
|
|
|
if "--library_type=microlib" not in self.flags['common']:
|
|
|
|
self.flags['common'].append("--library_type=microlib")
|
2018-06-12 14:29:10 +00:00
|
|
|
|
2019-11-14 11:58:01 +00:00
|
|
|
self.check_and_add_minimal_printf(target)
|
|
|
|
|
2019-04-12 11:44:34 +00:00
|
|
|
cpu = {
|
|
|
|
"Cortex-M0+": "Cortex-M0plus",
|
|
|
|
"Cortex-M4F": "Cortex-M4.fp.sp",
|
|
|
|
"Cortex-M7F": "Cortex-M7.fp.sp",
|
|
|
|
"Cortex-M7FD": "Cortex-M7.fp.dp"}.get(target.core, target.core)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2016-07-19 10:14:42 +00:00
|
|
|
ARM_BIN = join(TOOLCHAIN_PATHS['ARM'], "bin")
|
2018-04-30 14:29:41 +00:00
|
|
|
|
2013-10-14 14:32:41 +00:00
|
|
|
main_cc = join(ARM_BIN, "armcc")
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2016-06-10 12:12:21 +00:00
|
|
|
self.flags['common'] += ["--cpu=%s" % cpu]
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2016-12-09 17:29:36 +00:00
|
|
|
self.asm = [main_cc] + self.flags['common'] + self.flags['asm']
|
|
|
|
self.cc = [main_cc] + self.flags['common'] + self.flags['c']
|
2019-03-01 16:02:44 +00:00
|
|
|
self.cppc = (
|
|
|
|
[main_cc] + self.flags['common'] +
|
|
|
|
self.flags['c'] + self.flags['cxx']
|
|
|
|
)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2017-09-18 21:40:52 +00:00
|
|
|
self.ld = [join(ARM_BIN, "armlink")] + self.flags['ld']
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
self.ar = join(ARM_BIN, "armar")
|
|
|
|
self.elf2bin = join(ARM_BIN, "fromelf")
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2018-01-08 15:50:33 +00:00
|
|
|
self.SHEBANG += " --cpu=%s" % cpu
|
2018-01-05 21:16:57 +00:00
|
|
|
|
2019-03-19 22:33:40 +00:00
|
|
|
self.product_name = None
|
|
|
|
|
2018-06-18 19:03:09 +00:00
|
|
|
def version_check(self):
|
2019-03-19 22:33:40 +00:00
|
|
|
# The --ide=mbed removes an instability with checking the version of
|
2019-03-21 21:24:44 +00:00
|
|
|
# the ARMC6 binary that comes with Mbed Studio.
|
|
|
|
# NOTE: the --ide=mbed argument is only for use with Mbed OS
|
2019-03-19 22:33:40 +00:00
|
|
|
stdout, _, retcode = run_cmd(
|
|
|
|
[self.cc[0], "--vsn", "--ide=mbed"],
|
|
|
|
redirect=True
|
|
|
|
)
|
2018-06-19 15:41:08 +00:00
|
|
|
msg = None
|
|
|
|
min_ver, max_ver = self.ARMCC_RANGE
|
2019-03-19 22:33:40 +00:00
|
|
|
output = stdout.encode("utf-8")
|
|
|
|
match = self.ARMCC_VERSION_RE.search(output)
|
2019-03-01 16:02:44 +00:00
|
|
|
if match:
|
|
|
|
found_version = LooseVersion(match.group(1).decode("utf-8"))
|
|
|
|
else:
|
|
|
|
found_version = None
|
2018-06-26 14:15:01 +00:00
|
|
|
min_ver, max_ver = self.ARMCC_RANGE
|
2019-03-01 16:02:44 +00:00
|
|
|
if found_version and (found_version < min_ver
|
|
|
|
or found_version >= max_ver):
|
2018-06-25 19:41:37 +00:00
|
|
|
msg = ("Compiler version mismatch: Have {}; "
|
|
|
|
"expected version >= {} and < {}"
|
|
|
|
.format(found_version, min_ver, max_ver))
|
2018-06-25 23:04:11 +00:00
|
|
|
elif not match or len(match.groups()) != 1:
|
2018-06-19 15:41:08 +00:00
|
|
|
msg = ("Compiler version mismatch: Could not detect version; "
|
2018-06-25 19:41:37 +00:00
|
|
|
"expected version >= {} and < {}"
|
2018-06-19 15:41:08 +00:00
|
|
|
.format(min_ver, max_ver))
|
|
|
|
|
|
|
|
if msg:
|
|
|
|
self.notify.cc_info({
|
|
|
|
"message": msg,
|
|
|
|
"file": "",
|
|
|
|
"line": "",
|
|
|
|
"col": "",
|
2018-08-24 03:13:00 +00:00
|
|
|
"severity": "WARNING",
|
2018-06-19 15:41:08 +00:00
|
|
|
})
|
2018-06-18 19:03:09 +00:00
|
|
|
|
2019-03-19 22:33:40 +00:00
|
|
|
msg = None
|
|
|
|
match = self.ARMCC_PRODUCT_RE.search(output)
|
|
|
|
if match:
|
|
|
|
self.product_name = match.group(1).decode("utf-8")
|
|
|
|
else:
|
|
|
|
self.product_name = None
|
|
|
|
|
|
|
|
if not match or len(match.groups()) != 1:
|
|
|
|
msg = (
|
|
|
|
"Could not detect product name: defaulting to professional "
|
|
|
|
"version of ARMC6"
|
|
|
|
)
|
|
|
|
|
2018-06-12 14:54:34 +00:00
|
|
|
def _get_toolchain_labels(self):
|
2018-10-02 16:23:14 +00:00
|
|
|
if getattr(self.target, "default_toolchain", "ARM") == "uARM":
|
2019-07-10 09:40:54 +00:00
|
|
|
return ["ARM", "ARM_MICRO", "ARMC5"]
|
2018-06-12 14:54:34 +00:00
|
|
|
else:
|
2019-07-10 09:40:54 +00:00
|
|
|
return ["ARM", "ARM_STD", "ARMC5"]
|
2018-06-12 14:54:34 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
def parse_dependencies(self, dep_path):
|
|
|
|
dependencies = []
|
|
|
|
for line in open(dep_path).readlines():
|
|
|
|
match = ARM.DEP_PATTERN.match(line)
|
|
|
|
if match is not None:
|
2019-03-01 16:02:44 +00:00
|
|
|
# we need to append chroot, because when the .d files are
|
|
|
|
# generated the compiler is chrooted
|
|
|
|
dependencies.append(
|
|
|
|
(self.CHROOT if self.CHROOT else '') + match.group('file')
|
|
|
|
)
|
2013-06-24 13:32:08 +00:00
|
|
|
return dependencies
|
2017-08-15 18:32:52 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
def parse_output(self, output):
|
2016-07-19 10:14:42 +00:00
|
|
|
msg = None
|
2013-06-24 13:32:08 +00:00
|
|
|
for line in output.splitlines():
|
2019-03-29 16:12:13 +00:00
|
|
|
match = self.DIAGNOSTIC_PATTERN.match(line)
|
2013-06-24 13:32:08 +00:00
|
|
|
if match is not None:
|
2016-07-19 10:14:42 +00:00
|
|
|
if msg is not None:
|
2018-04-25 19:21:25 +00:00
|
|
|
self.notify.cc_info(msg)
|
2016-09-28 19:42:35 +00:00
|
|
|
msg = None
|
2016-07-19 10:14:42 +00:00
|
|
|
msg = {
|
|
|
|
'severity': match.group('severity').lower(),
|
|
|
|
'file': match.group('file'),
|
|
|
|
'line': match.group('line'),
|
|
|
|
'message': match.group('message'),
|
|
|
|
'text': '',
|
|
|
|
'target_name': self.target.name,
|
|
|
|
'toolchain_name': self.name
|
|
|
|
}
|
2019-03-01 16:02:44 +00:00
|
|
|
if match.group('column'):
|
|
|
|
msg['col'] = match.group('column')
|
|
|
|
else:
|
|
|
|
msg['col'] = 0
|
2016-07-19 10:14:42 +00:00
|
|
|
elif msg is not None:
|
2019-03-01 16:02:44 +00:00
|
|
|
# Determine the warning/error column by calculating the '^'
|
|
|
|
# position
|
2016-07-19 10:14:42 +00:00
|
|
|
match = ARM.INDEX_PATTERN.match(line)
|
|
|
|
if match is not None:
|
|
|
|
msg['col'] = len(match.group('col'))
|
2018-04-25 19:21:25 +00:00
|
|
|
self.notify.cc_info(msg)
|
2016-07-19 10:14:42 +00:00
|
|
|
msg = None
|
|
|
|
else:
|
|
|
|
msg['text'] += line+"\n"
|
2018-12-06 17:33:10 +00:00
|
|
|
|
2016-07-19 10:14:42 +00:00
|
|
|
if msg is not None:
|
2018-04-25 19:21:25 +00:00
|
|
|
self.notify.cc_info(msg)
|
2015-11-12 18:16:10 +00:00
|
|
|
|
2016-06-09 22:50:03 +00:00
|
|
|
def get_dep_option(self, object):
|
|
|
|
base, _ = splitext(object)
|
|
|
|
dep_path = base + '.d'
|
2014-07-11 08:13:22 +00:00
|
|
|
return ["--depend", dep_path]
|
2015-11-12 18:16:10 +00:00
|
|
|
|
2016-07-19 10:14:42 +00:00
|
|
|
def get_config_option(self, config_header):
|
2016-06-24 17:24:31 +00:00
|
|
|
return ['--preinclude=' + config_header]
|
2016-06-16 18:34:02 +00:00
|
|
|
|
2018-04-23 20:23:00 +00:00
|
|
|
def get_compile_options(self, defines, includes, for_asm=False):
|
2016-07-19 10:14:42 +00:00
|
|
|
opts = ['-D%s' % d for d in defines]
|
2018-06-15 14:25:12 +00:00
|
|
|
config_header = self.get_config_header()
|
|
|
|
if config_header is not None:
|
|
|
|
opts = opts + self.get_config_option(config_header)
|
2018-04-23 20:23:00 +00:00
|
|
|
if for_asm:
|
|
|
|
return opts
|
2016-07-19 10:14:42 +00:00
|
|
|
if self.RESPONSE_FILES:
|
|
|
|
opts += ['--via', self.get_inc_file(includes)]
|
|
|
|
else:
|
2018-11-08 15:23:49 +00:00
|
|
|
opts += ["-I%s" % i for i in includes if i]
|
2016-07-19 10:14:42 +00:00
|
|
|
|
2016-06-16 13:13:50 +00:00
|
|
|
return opts
|
2016-06-09 22:50:03 +00:00
|
|
|
|
|
|
|
def assemble(self, source, object, includes):
|
|
|
|
# Preprocess first, then assemble
|
|
|
|
dir = join(dirname(object), '.temp')
|
|
|
|
mkdir(dir)
|
|
|
|
tempfile = join(dir, basename(object) + '.E.s')
|
2018-04-30 14:29:41 +00:00
|
|
|
|
2016-06-09 22:50:03 +00:00
|
|
|
# Build preprocess assemble command
|
2018-04-30 14:34:32 +00:00
|
|
|
cmd_pre = copy(self.asm)
|
2018-04-23 20:23:00 +00:00
|
|
|
cmd_pre.extend(self.get_compile_options(
|
|
|
|
self.get_symbols(True), includes, True))
|
|
|
|
cmd_pre.extend(["-E", "-o", tempfile, source])
|
2016-06-09 22:50:03 +00:00
|
|
|
|
|
|
|
# Build main assemble command
|
|
|
|
cmd = self.asm + ["-o", object, tempfile]
|
|
|
|
|
|
|
|
# Return command array, don't execute
|
|
|
|
return [cmd_pre, cmd]
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2016-06-09 22:50:03 +00:00
|
|
|
def compile(self, cc, source, object, includes):
|
|
|
|
# Build compile command
|
|
|
|
cmd = cc + self.get_compile_options(self.get_symbols(), includes)
|
2018-04-30 14:29:41 +00:00
|
|
|
|
2016-06-09 22:50:03 +00:00
|
|
|
cmd.extend(self.get_dep_option(object))
|
2018-04-30 14:29:41 +00:00
|
|
|
|
2016-06-09 22:50:03 +00:00
|
|
|
cmd.extend(["-o", object, source])
|
|
|
|
|
|
|
|
return [cmd]
|
|
|
|
|
|
|
|
def compile_c(self, source, object, includes):
|
|
|
|
return self.compile(self.cc, source, object, includes)
|
|
|
|
|
|
|
|
def compile_cpp(self, source, object, includes):
|
|
|
|
return self.compile(self.cppc, source, object, includes)
|
|
|
|
|
2019-03-06 20:34:09 +00:00
|
|
|
def correct_scatter_shebang(self, sc_fileref, cur_dir_name=None):
|
2016-09-23 16:36:46 +00:00
|
|
|
"""Correct the shebang at the top of a scatter file.
|
|
|
|
|
2019-10-23 08:41:04 +00:00
|
|
|
The shebang line is the line at the top of the file starting with '#!'. If this line is present
|
|
|
|
then the linker will execute the command on that line on the content of the scatter file prior
|
|
|
|
to consuming the content into the link. Typically the shebang line will contain an instruction
|
|
|
|
to run the C-preprocessor (either 'armcc -E' or 'armclang -E') which allows for macro expansion,
|
|
|
|
inclusion of headers etc. Other options are passed to the preprocessor to specify aspects of the
|
|
|
|
system such as the processor architecture and cpu type.
|
|
|
|
|
|
|
|
The build system (at this point) will have constructed what it considers to be a correct shebang
|
|
|
|
line for this build. If this differs from the line in the scatter file then the scatter file
|
|
|
|
will be rewritten by this function to contain the build-system-generated shebang line. Note
|
|
|
|
that the rewritten file will be placed in the BUILD output directory.
|
|
|
|
|
|
|
|
Include processing
|
|
|
|
|
|
|
|
If the scatter file runs the preprocessor, and contains #include statements then the pre-processor
|
|
|
|
include path specifies where the #include files are to be found. Typically, #include files
|
|
|
|
are specified with a path relative to the location of the original scatter file. When the
|
|
|
|
preprocessor runs, the system automatically passes the location of the scatter file into the
|
|
|
|
include path through an implicit '-I' option to the preprocessor, and this works fine in the
|
|
|
|
offline build system.
|
|
|
|
Unfortunately this approach does not work in the online build, because the preprocessor
|
|
|
|
command runs in a chroot. The true (non-chroot) path to the file as known by the build system
|
|
|
|
looks something like this:
|
|
|
|
/tmp/chroots/ch-eefd72fb-2bcb-4e99-9043-573d016618bb/extras/mbed-os.lib/...
|
|
|
|
whereas the path known by the preprocessor will be:
|
|
|
|
/extras/mbed-os.lib/...
|
|
|
|
Consequently, the chroot path has to be explicitly passed to the preprocessor through an
|
|
|
|
explicit -I/path/to/chroot/file option in the shebang line.
|
|
|
|
|
|
|
|
*** THERE IS AN ASSUMPTION THAT THE CHROOT PATH IS THE REAL FILE PATH WITH THE FIRST
|
|
|
|
*** THREE ELEMENTS REMOVED. THIS ONLY HOLDS TRUE UNTIL THE ONLINE BUILD SYSTEM CHANGES
|
|
|
|
|
|
|
|
If the include path manipulation as described above does change, then any scatter file
|
|
|
|
containing a #include statement is likely to fail on the online compiler.
|
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
Positional arguments:
|
2019-03-06 20:34:09 +00:00
|
|
|
sc_fileref -- FileRef object of the scatter file
|
2016-09-23 16:36:46 +00:00
|
|
|
|
2018-06-15 18:05:38 +00:00
|
|
|
Keyword arguments:
|
|
|
|
cur_dir_name -- the name (not path) of the directory containing the
|
|
|
|
scatter file
|
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
Return:
|
2019-04-05 16:46:39 +00:00
|
|
|
The FileRef of the correct scatter file
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
Side Effects:
|
|
|
|
This method MAY write a new scatter file to disk
|
|
|
|
"""
|
2019-03-06 20:34:09 +00:00
|
|
|
with open(sc_fileref.path, "r") as input:
|
2016-09-23 16:36:46 +00:00
|
|
|
lines = input.readlines()
|
2019-10-23 08:41:04 +00:00
|
|
|
|
|
|
|
# If the existing scatter file has no shebang line, or the line that it does have
|
|
|
|
# matches the desired line then the existing scatter file is used directly without rewriting.
|
2018-01-10 21:46:20 +00:00
|
|
|
if (lines[0].startswith(self.SHEBANG) or
|
2019-10-23 08:41:04 +00:00
|
|
|
not lines[0].startswith("#!")):
|
2019-03-06 20:34:09 +00:00
|
|
|
return sc_fileref
|
2019-10-23 08:41:04 +00:00
|
|
|
|
|
|
|
new_scatter = join(self.build_dir, ".link_script.sct")
|
|
|
|
if cur_dir_name is None:
|
|
|
|
cur_dir_name = dirname(sc_fileref.path)
|
|
|
|
|
|
|
|
# For a chrooted system, adjust the path to the scatter file to be a valid
|
|
|
|
# chroot location by removing the first three elements of the path.
|
|
|
|
if cur_dir_name.startswith("/tmp/chroots"):
|
|
|
|
cur_dir_name = sep + join(*(cur_dir_name.split(sep)[4:]))
|
|
|
|
|
|
|
|
# Add the relocated scatter file path to the include path.
|
|
|
|
self.SHEBANG += " -I%s" % cur_dir_name
|
|
|
|
|
|
|
|
# Only rewrite if doing a full build...
|
|
|
|
if self.need_update(new_scatter, [sc_fileref.path]):
|
|
|
|
with open(new_scatter, "w") as out:
|
|
|
|
# Write the new shebang line...
|
|
|
|
out.write(self.SHEBANG + "\n")
|
|
|
|
# ...followed by the unmolested remaining content from the original scatter file.
|
|
|
|
out.write("".join(lines[1:]))
|
|
|
|
|
|
|
|
return FileRef(".link_script.sct", new_scatter)
|
2017-01-30 23:12:35 +00:00
|
|
|
|
2019-03-29 16:12:13 +00:00
|
|
|
def get_link_command(
|
|
|
|
self,
|
|
|
|
output,
|
|
|
|
objects,
|
|
|
|
libraries,
|
|
|
|
lib_dirs,
|
|
|
|
scatter_file
|
|
|
|
):
|
2016-09-23 16:36:46 +00:00
|
|
|
base, _ = splitext(output)
|
|
|
|
map_file = base + ".map"
|
|
|
|
args = ["-o", output, "--info=totals", "--map", "--list=%s" % map_file]
|
|
|
|
args.extend(objects)
|
|
|
|
args.extend(libraries)
|
|
|
|
if lib_dirs:
|
|
|
|
args.extend(["--userlibpath", ",".join(lib_dirs)])
|
|
|
|
if scatter_file:
|
2019-03-06 20:34:09 +00:00
|
|
|
scatter_name = relpath(scatter_file)
|
|
|
|
new_scatter = self.correct_scatter_shebang(FileRef(scatter_name, scatter_file))
|
|
|
|
args.extend(["--scatter", new_scatter.path])
|
2016-09-23 16:36:46 +00:00
|
|
|
|
2019-02-19 16:58:14 +00:00
|
|
|
cmd = self.ld + args
|
2016-06-09 22:50:03 +00:00
|
|
|
|
2016-07-19 10:14:42 +00:00
|
|
|
if self.RESPONSE_FILES:
|
2016-06-09 22:50:03 +00:00
|
|
|
cmd_linker = cmd[0]
|
2016-07-19 10:14:42 +00:00
|
|
|
link_files = self.get_link_file(cmd[1:])
|
|
|
|
cmd = [cmd_linker, '--via', link_files]
|
2016-06-09 22:50:03 +00:00
|
|
|
|
2019-03-19 22:33:40 +00:00
|
|
|
return cmd
|
|
|
|
|
|
|
|
def link(self, output, objects, libraries, lib_dirs, scatter_file):
|
|
|
|
cmd = self.get_link_command(
|
|
|
|
output, objects, libraries, lib_dirs, scatter_file
|
|
|
|
)
|
|
|
|
|
2018-04-25 19:21:25 +00:00
|
|
|
self.notify.cc_verbose("Link: %s" % ' '.join(cmd))
|
2016-07-19 10:14:42 +00:00
|
|
|
self.default_cmd(cmd)
|
2016-06-09 22:50:03 +00:00
|
|
|
|
|
|
|
def archive(self, objects, lib_path):
|
2016-07-19 10:14:42 +00:00
|
|
|
if self.RESPONSE_FILES:
|
|
|
|
param = ['--via', self.get_arch_file(objects)]
|
|
|
|
else:
|
|
|
|
param = objects
|
|
|
|
self.default_cmd([self.ar, '-r', lib_path] + param)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2019-03-19 22:33:40 +00:00
|
|
|
def get_binary_commands(self, bin_arg, bin, elf):
|
|
|
|
return [self.elf2bin, bin_arg, '-o', bin, elf]
|
|
|
|
|
2014-02-07 12:10:39 +00:00
|
|
|
def binary(self, resources, elf, bin):
|
2017-03-22 19:47:46 +00:00
|
|
|
_, fmt = splitext(bin)
|
2019-03-01 16:02:44 +00:00
|
|
|
# On .hex format, combine multiple .hex files (for multiple load
|
|
|
|
# regions) into one
|
2018-04-16 08:10:57 +00:00
|
|
|
bin_arg = {".bin": "--bin", ".hex": "--i32combined"}[fmt]
|
2019-03-19 22:33:40 +00:00
|
|
|
cmd = self.get_binary_commands(bin_arg, bin, elf)
|
2018-03-13 10:32:24 +00:00
|
|
|
|
|
|
|
# remove target binary file/path
|
|
|
|
if exists(bin):
|
|
|
|
if isfile(bin):
|
|
|
|
remove(bin)
|
|
|
|
else:
|
|
|
|
rmtree(bin)
|
|
|
|
|
2018-04-25 19:21:25 +00:00
|
|
|
self.notify.cc_verbose("FromELF: %s" % ' '.join(cmd))
|
2016-06-09 22:50:03 +00:00
|
|
|
self.default_cmd(cmd)
|
2014-05-29 13:42:03 +00:00
|
|
|
|
2017-02-01 22:22:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def name_mangle(name):
|
|
|
|
return "_Z%i%sv" % (len(name), name)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def make_ld_define(name, value):
|
2018-08-31 11:13:55 +00:00
|
|
|
return "--predefine=\"-D%s=%s\"" % (name, value)
|
2017-02-01 22:22:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def redirect_symbol(source, sync, build_dir):
|
|
|
|
if not exists(build_dir):
|
|
|
|
makedirs(build_dir)
|
|
|
|
handle, filename = mkstemp(prefix=".redirect-symbol.", dir=build_dir)
|
|
|
|
write(handle, "RESOLVE %s AS %s\n" % (source, sync))
|
|
|
|
return "--edit=%s" % filename
|
|
|
|
|
2019-03-29 16:12:13 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
class ARM_STD(ARM):
|
2019-03-01 16:02:44 +00:00
|
|
|
|
2018-10-03 17:47:33 +00:00
|
|
|
OFFICIALLY_SUPPORTED = True
|
2019-03-01 16:02:44 +00:00
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
target,
|
|
|
|
notify=None,
|
|
|
|
macros=None,
|
|
|
|
build_profile=None,
|
2019-11-20 15:58:37 +00:00
|
|
|
build_dir=None,
|
|
|
|
coverage_patterns=None
|
2019-03-01 16:02:44 +00:00
|
|
|
):
|
|
|
|
ARM.__init__(
|
|
|
|
self,
|
|
|
|
target,
|
|
|
|
notify,
|
|
|
|
macros,
|
|
|
|
build_dir=build_dir,
|
2019-11-20 15:58:37 +00:00
|
|
|
build_profile=build_profile,
|
|
|
|
coverage_patterns=None
|
2019-03-01 16:02:44 +00:00
|
|
|
)
|
2019-02-25 20:42:26 +00:00
|
|
|
if int(target.build_tools_metadata["version"]) > 0:
|
2019-03-29 16:12:13 +00:00
|
|
|
# check only for ARMC5 because ARM_STD means using ARMC5, and thus
|
2019-03-01 16:02:44 +00:00
|
|
|
# supported_toolchains must include ARMC5
|
2019-03-29 16:12:13 +00:00
|
|
|
if not set(target.supported_toolchains).intersection(
|
|
|
|
set(("ARMC5", "ARM"))
|
|
|
|
):
|
2019-03-01 16:02:44 +00:00
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM compiler 5 support is required for ARM build"
|
|
|
|
)
|
2019-02-25 20:42:26 +00:00
|
|
|
else:
|
2019-03-01 16:02:44 +00:00
|
|
|
if not set(("ARM", "uARM")).intersection(set(
|
|
|
|
target.supported_toolchains
|
|
|
|
)):
|
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM/uARM compiler support is required for ARM build"
|
|
|
|
)
|
2013-06-24 13:32:08 +00:00
|
|
|
|
2019-03-29 16:12:13 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
class ARM_MICRO(ARM):
|
2019-03-01 16:02:44 +00:00
|
|
|
|
2013-07-08 16:31:04 +00:00
|
|
|
PATCHED_LIBRARY = False
|
2019-03-01 16:02:44 +00:00
|
|
|
|
2018-10-03 17:47:33 +00:00
|
|
|
OFFICIALLY_SUPPORTED = True
|
2019-02-12 23:43:57 +00:00
|
|
|
|
2019-03-01 16:02:44 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
target,
|
|
|
|
notify=None,
|
|
|
|
macros=None,
|
|
|
|
silent=False,
|
|
|
|
extra_verbose=False,
|
|
|
|
build_profile=None,
|
2020-06-05 14:20:40 +00:00
|
|
|
build_dir=None,
|
|
|
|
coverage_patterns=None,
|
2019-03-01 16:02:44 +00:00
|
|
|
):
|
|
|
|
target.default_toolchain = "uARM"
|
2019-02-25 20:42:26 +00:00
|
|
|
if int(target.build_tools_metadata["version"]) > 0:
|
2019-03-01 16:02:44 +00:00
|
|
|
# At this point we already know that we want to use ARMC5+Microlib
|
|
|
|
# so check for if they are supported For, AC6+Microlib we still
|
|
|
|
# use ARMC6 class
|
2019-03-29 16:12:13 +00:00
|
|
|
if not set(("ARMC5", "uARM")).issubset(set(
|
2019-03-01 16:02:44 +00:00
|
|
|
target.supported_toolchains
|
|
|
|
)):
|
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM/uARM compiler support is required for ARM build"
|
|
|
|
)
|
2019-02-25 20:42:26 +00:00
|
|
|
else:
|
2019-03-01 16:02:44 +00:00
|
|
|
if not set(("ARM", "uARM")).intersection(set(
|
|
|
|
target.supported_toolchains
|
|
|
|
)):
|
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM/uARM compiler support is required for ARM build"
|
|
|
|
)
|
|
|
|
ARM.__init__(
|
|
|
|
self,
|
|
|
|
target,
|
|
|
|
notify,
|
|
|
|
macros,
|
|
|
|
build_dir=build_dir,
|
|
|
|
build_profile=build_profile
|
|
|
|
)
|
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
class ARMC6(ARM_STD):
|
2019-03-01 16:02:44 +00:00
|
|
|
|
|
|
|
OFFICIALLY_SUPPORTED = False
|
2016-09-23 16:36:46 +00:00
|
|
|
SHEBANG = "#! armclang -E --target=arm-arm-none-eabi -x c"
|
2019-03-01 16:02:44 +00:00
|
|
|
SUPPORTED_CORES = [
|
|
|
|
"Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
|
|
|
|
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD",
|
|
|
|
"Cortex-M23", "Cortex-M23-NS", "Cortex-M33", "Cortex-M33F",
|
|
|
|
"Cortex-M33-NS", "Cortex-M33F-NS", "Cortex-M33FE-NS", "Cortex-M33FE",
|
|
|
|
"Cortex-A9"
|
|
|
|
]
|
2018-06-19 15:41:08 +00:00
|
|
|
ARMCC_RANGE = (LooseVersion("6.10"), LooseVersion("7.0"))
|
2019-03-29 16:12:13 +00:00
|
|
|
LD_DIAGNOSTIC_PATTERN = re.compile(
|
|
|
|
'(?P<severity>Warning|Error): (?P<message>.+)'
|
|
|
|
)
|
|
|
|
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
|
2018-06-18 19:03:09 +00:00
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
@staticmethod
|
|
|
|
def check_executable():
|
|
|
|
return mbedToolchain.generic_check_executable("ARMC6", "armclang", 1)
|
|
|
|
|
|
|
|
def __init__(self, target, *args, **kwargs):
|
|
|
|
mbedToolchain.__init__(self, target, *args, **kwargs)
|
2017-10-20 15:05:37 +00:00
|
|
|
if target.core not in self.SUPPORTED_CORES:
|
|
|
|
raise NotSupportedException(
|
|
|
|
"this compiler does not support the core %s" % target.core)
|
2016-09-23 16:36:46 +00:00
|
|
|
|
2019-02-25 20:42:26 +00:00
|
|
|
if int(target.build_tools_metadata["version"]) > 0:
|
2019-03-01 16:02:44 +00:00
|
|
|
if not set(("ARM", "ARMC6", "uARM")).intersection(set(
|
|
|
|
target.supported_toolchains
|
|
|
|
)):
|
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM/ARMC6 compiler support is required for ARMC6 build"
|
|
|
|
)
|
2019-02-25 20:42:26 +00:00
|
|
|
else:
|
2019-03-01 16:02:44 +00:00
|
|
|
if not set(("ARM", "ARMC6")).intersection(set(
|
|
|
|
target.supported_toolchains
|
|
|
|
)):
|
|
|
|
raise NotSupportedException(
|
|
|
|
"ARM/ARMC6 compiler support is required for ARMC6 build"
|
|
|
|
)
|
|
|
|
|
2020-03-20 14:54:35 +00:00
|
|
|
toolchain = "arm"
|
|
|
|
|
|
|
|
if should_replace_small_c_lib(target, toolchain):
|
|
|
|
target.c_lib = "std"
|
|
|
|
|
|
|
|
self.check_c_lib_supported(target, toolchain)
|
Enabling small C library option and deprecating uARM toolchain
- By default, Mbed OS build tools use standard C library for all supported toolchains.
It is possible to use smaller C libraries by overriding the "target.default_lib" option
with "small". This option is only currently supported for the GCC_ARM toolchain.
This override config option is now extended in the build tool for ARM toolchain.
- Add configuration option to specify libraries supported for each toolchain per targets.
- Move __aeabi_assert function from rtos to retarget code so it’s available for bare metal.
- Use 2 memory region model for ARM toolchain scatter file for the following targets:
NUCLEO_F207ZG, STM32F411xE, STM32F429xI, NUCLEO_L073RZ, STM32F303xE
- Add a warning message in the build tools to deprecate uARM toolchain.
- NewLib-Nano C library is not supporting floating-point and printf with %hhd,%hhu,%hhX,%lld,%llu,%llX
format specifier so skipping those green tea test cases.
2019-10-08 15:04:02 +00:00
|
|
|
|
2019-12-10 17:20:34 +00:00
|
|
|
if (
|
|
|
|
getattr(target, "default_toolchain", "ARMC6") == "uARM"
|
2020-01-17 13:51:41 +00:00
|
|
|
or getattr(target, "c_lib", "std") == "small"
|
2019-12-10 17:20:34 +00:00
|
|
|
):
|
2019-02-12 23:43:57 +00:00
|
|
|
if "-DMBED_RTOS_SINGLE_THREAD" not in self.flags['common']:
|
|
|
|
self.flags['common'].append("-DMBED_RTOS_SINGLE_THREAD")
|
|
|
|
if "-D__MICROLIB" not in self.flags['common']:
|
|
|
|
self.flags['common'].append("-D__MICROLIB")
|
2019-02-19 16:48:21 +00:00
|
|
|
if "--library_type=microlib" not in self.flags['ld']:
|
|
|
|
self.flags['ld'].append("--library_type=microlib")
|
|
|
|
if "--library_type=microlib" not in self.flags['asm']:
|
2019-03-01 16:02:44 +00:00
|
|
|
self.flags['asm'].append("--library_type=microlib")
|
2017-08-31 14:56:07 +00:00
|
|
|
|
2019-11-14 11:58:01 +00:00
|
|
|
self.check_and_add_minimal_printf(target)
|
|
|
|
|
2019-05-02 10:26:49 +00:00
|
|
|
if target.is_TrustZone_non_secure_target:
|
2019-01-23 19:45:00 +00:00
|
|
|
# Add linking time preprocessor macro DOMAIN_NS
|
2019-05-02 10:26:49 +00:00
|
|
|
# (DOMAIN_NS is passed to compiler and assembler via CORTEX_SYMBOLS
|
|
|
|
# in mbedToolchain.get_symbols)
|
|
|
|
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
|
|
|
|
self.flags["ld"].append(define_string)
|
2019-01-23 19:45:00 +00:00
|
|
|
|
2019-05-02 10:26:49 +00:00
|
|
|
core = target.core_without_NS
|
2019-01-23 20:41:19 +00:00
|
|
|
cpu = {
|
|
|
|
"Cortex-M0+": "cortex-m0plus",
|
|
|
|
"Cortex-M4F": "cortex-m4",
|
|
|
|
"Cortex-M7F": "cortex-m7",
|
|
|
|
"Cortex-M7FD": "cortex-m7",
|
2019-02-04 21:40:51 +00:00
|
|
|
"Cortex-M33": "cortex-m33+nodsp",
|
|
|
|
"Cortex-M33F": "cortex-m33+nodsp",
|
2019-04-30 11:55:46 +00:00
|
|
|
"Cortex-M33E": "cortex-m33",
|
2019-01-25 15:24:04 +00:00
|
|
|
"Cortex-M33FE": "cortex-m33"}.get(core, core)
|
2019-01-23 20:41:19 +00:00
|
|
|
|
|
|
|
cpu = cpu.lower()
|
|
|
|
self.flags['common'].append("-mcpu=%s" % cpu)
|
|
|
|
self.SHEBANG += " -mcpu=%s" % cpu
|
|
|
|
|
|
|
|
# FPU handling
|
2019-04-30 11:48:38 +00:00
|
|
|
if core in ["Cortex-M4", "Cortex-M7", "Cortex-M33", "Cortex-M33E"]:
|
2019-04-12 11:44:34 +00:00
|
|
|
self.flags['common'].append("-mfpu=none")
|
|
|
|
elif core == "Cortex-M4F":
|
2016-09-23 16:36:46 +00:00
|
|
|
self.flags['common'].append("-mfpu=fpv4-sp-d16")
|
|
|
|
self.flags['common'].append("-mfloat-abi=hard")
|
2019-04-12 11:44:34 +00:00
|
|
|
elif core == "Cortex-M7F" or core.startswith("Cortex-M33F"):
|
2016-09-23 16:36:46 +00:00
|
|
|
self.flags['common'].append("-mfpu=fpv5-sp-d16")
|
2018-12-19 12:19:40 +00:00
|
|
|
self.flags['common'].append("-mfloat-abi=hard")
|
2019-01-23 20:41:19 +00:00
|
|
|
elif core == "Cortex-M7FD":
|
2016-09-23 16:36:46 +00:00
|
|
|
self.flags['common'].append("-mfpu=fpv5-d16")
|
2018-12-19 12:19:40 +00:00
|
|
|
self.flags['common'].append("-mfloat-abi=hard")
|
2018-04-17 16:58:02 +00:00
|
|
|
|
2019-04-12 11:44:34 +00:00
|
|
|
asm_ld_cpu = {
|
|
|
|
"Cortex-M0+": "Cortex-M0plus",
|
|
|
|
"Cortex-M4": "Cortex-M4.no_fp",
|
|
|
|
"Cortex-M4F": "Cortex-M4",
|
|
|
|
"Cortex-M7": "Cortex-M7.no_fp",
|
2016-09-23 16:36:46 +00:00
|
|
|
"Cortex-M7F": "Cortex-M7.fp.sp",
|
2019-04-12 11:44:34 +00:00
|
|
|
"Cortex-M7FD": "Cortex-M7",
|
2019-01-18 20:12:01 +00:00
|
|
|
"Cortex-M33": "Cortex-M33.no_dsp.no_fp",
|
2019-04-17 08:07:15 +00:00
|
|
|
"Cortex-M33E": "Cortex-M33.no_fp",
|
2019-01-18 20:12:01 +00:00
|
|
|
"Cortex-M33F": "Cortex-M33.no_dsp",
|
2019-01-25 15:24:04 +00:00
|
|
|
"Cortex-M33FE": "Cortex-M33"}.get(core, core)
|
2019-01-18 20:12:01 +00:00
|
|
|
|
2019-04-12 11:44:34 +00:00
|
|
|
self.flags['asm'].append("--cpu=%s" % asm_ld_cpu)
|
|
|
|
self.flags['ld'].append("--cpu=%s" % asm_ld_cpu)
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
self.cc = ([join(TOOLCHAIN_PATHS["ARMC6"], "armclang")] +
|
|
|
|
self.flags['common'] + self.flags['c'])
|
|
|
|
self.cppc = ([join(TOOLCHAIN_PATHS["ARMC6"], "armclang")] +
|
|
|
|
self.flags['common'] + self.flags['cxx'])
|
2019-03-01 16:02:44 +00:00
|
|
|
self.asm = [join(TOOLCHAIN_PATHS["ARMC6"], "armasm")]
|
|
|
|
self.asm += self.flags['asm']
|
|
|
|
self.ld = [join(TOOLCHAIN_PATHS["ARMC6"], "armlink")]
|
|
|
|
self.ld += self.flags['ld']
|
2018-11-22 13:18:51 +00:00
|
|
|
self.ar = join(TOOLCHAIN_PATHS["ARMC6"], "armar")
|
2016-09-23 16:36:46 +00:00
|
|
|
self.elf2bin = join(TOOLCHAIN_PATHS["ARMC6"], "fromelf")
|
|
|
|
|
2019-03-29 16:12:13 +00:00
|
|
|
# Adding this for safety since this inherits the `version_check`
|
|
|
|
# function but does not call the constructor of ARM_STD, so the
|
|
|
|
# `product_name` variable is not initialized.
|
2019-03-19 22:33:40 +00:00
|
|
|
self.product_name = None
|
|
|
|
|
2018-06-12 14:54:34 +00:00
|
|
|
def _get_toolchain_labels(self):
|
2019-02-19 16:48:21 +00:00
|
|
|
if getattr(self.target, "default_toolchain", "ARM") == "uARM":
|
2019-02-21 21:31:01 +00:00
|
|
|
return ["ARM", "ARM_MICRO", "ARMC6"]
|
2019-02-19 16:48:21 +00:00
|
|
|
else:
|
2019-02-21 21:31:01 +00:00
|
|
|
return ["ARM", "ARM_STD", "ARMC6"]
|
2018-06-12 14:54:34 +00:00
|
|
|
|
2019-03-19 22:33:40 +00:00
|
|
|
@property
|
|
|
|
def is_mbed_studio_armc6(self):
|
|
|
|
return self.product_name and "Mbed Studio" in self.product_name
|
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
def parse_dependencies(self, dep_path):
|
2017-08-15 18:32:52 +00:00
|
|
|
return mbedToolchain.parse_dependencies(self, dep_path)
|
2016-09-23 16:36:46 +00:00
|
|
|
|
2017-09-07 16:33:06 +00:00
|
|
|
def is_not_supported_error(self, output):
|
|
|
|
return "#error [NOT_SUPPORTED]" in output
|
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
def parse_output(self, output):
|
2019-03-29 16:12:13 +00:00
|
|
|
for line in output.splitlines():
|
|
|
|
match = self.LD_DIAGNOSTIC_PATTERN.match(line)
|
|
|
|
if match is not None:
|
|
|
|
self.notify.cc_info({
|
|
|
|
'severity': match.group('severity').lower(),
|
|
|
|
'message': match.group('message'),
|
|
|
|
'text': '',
|
|
|
|
'target_name': self.target.name,
|
|
|
|
'toolchain_name': self.name,
|
|
|
|
'col': 0,
|
|
|
|
'file': "",
|
|
|
|
'line': 0
|
|
|
|
})
|
|
|
|
match = self.DIAGNOSTIC_PATTERN.search(line)
|
|
|
|
if match is not None:
|
|
|
|
self.notify.cc_info({
|
|
|
|
'severity': match.group('severity').lower(),
|
|
|
|
'file': match.group('file'),
|
|
|
|
'line': match.group('line'),
|
|
|
|
'col': match.group('col'),
|
|
|
|
'message': match.group('message'),
|
|
|
|
'text': '',
|
|
|
|
'target_name': self.target.name,
|
|
|
|
'toolchain_name': self.name
|
|
|
|
})
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
def get_config_option(self, config_header):
|
|
|
|
return ["-include", config_header]
|
|
|
|
|
|
|
|
def get_compile_options(self, defines, includes, for_asm=False):
|
2019-03-19 22:33:09 +00:00
|
|
|
|
2016-09-23 16:36:46 +00:00
|
|
|
opts = ['-D%s' % d for d in defines]
|
2019-03-19 22:33:09 +00:00
|
|
|
|
2019-02-28 01:28:35 +00:00
|
|
|
if self.RESPONSE_FILES:
|
|
|
|
opts += ['@{}'.format(self.get_inc_file(includes))]
|
|
|
|
else:
|
|
|
|
opts += ["-I%s" % i for i in includes if i]
|
2019-03-19 22:33:09 +00:00
|
|
|
|
2019-02-19 18:45:36 +00:00
|
|
|
config_header = self.get_config_header()
|
|
|
|
if config_header:
|
|
|
|
opts.extend(self.get_config_option(config_header))
|
2016-09-23 16:36:46 +00:00
|
|
|
if for_asm:
|
2019-03-19 22:33:40 +00:00
|
|
|
opts = [
|
2019-03-01 16:02:44 +00:00
|
|
|
"--cpreproc",
|
|
|
|
"--cpreproc_opts=%s" % ",".join(self.flags['common'] + opts)
|
|
|
|
]
|
2019-03-19 22:33:40 +00:00
|
|
|
|
|
|
|
if self.is_mbed_studio_armc6:
|
2019-03-21 21:24:44 +00:00
|
|
|
# NOTE: the --ide=mbed argument is only for use with Mbed OS
|
2019-03-19 22:33:40 +00:00
|
|
|
opts.insert(0, "--ide=mbed")
|
|
|
|
|
2019-02-19 18:45:36 +00:00
|
|
|
return opts
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
def assemble(self, source, object, includes):
|
2019-03-21 10:20:02 +00:00
|
|
|
# Preprocess first, then assemble
|
|
|
|
root, _ = splitext(object)
|
|
|
|
tempfile = root + '.E'
|
|
|
|
|
|
|
|
# Build preprocess assemble command
|
|
|
|
cmd_pre = copy(self.cc)
|
2016-09-23 16:36:46 +00:00
|
|
|
cmd_pre.extend(self.get_compile_options(
|
2019-03-21 10:20:02 +00:00
|
|
|
self.get_symbols(True), includes, for_asm=False))
|
|
|
|
cmd_pre.extend(["-E", "-MT", object, "-o", tempfile, source])
|
|
|
|
|
|
|
|
# Build main assemble command
|
|
|
|
cmd = self.asm + ["-o", object, tempfile]
|
2019-05-07 16:45:30 +00:00
|
|
|
if self.is_mbed_studio_armc6:
|
|
|
|
# NOTE: the --ide=mbed argument is only for use with Mbed OS
|
|
|
|
cmd.insert(1, "--ide=mbed")
|
2019-03-21 10:20:02 +00:00
|
|
|
|
|
|
|
# Return command array, don't execute
|
|
|
|
return [cmd_pre, cmd]
|
2016-09-23 16:36:46 +00:00
|
|
|
|
|
|
|
def compile(self, cc, source, object, includes):
|
|
|
|
cmd = copy(cc)
|
|
|
|
cmd.extend(self.get_compile_options(self.get_symbols(), includes))
|
|
|
|
cmd.extend(["-o", object, source])
|
|
|
|
return [cmd]
|
2019-03-19 22:33:40 +00:00
|
|
|
|
2019-03-29 16:12:13 +00:00
|
|
|
def get_link_command(
|
|
|
|
self,
|
|
|
|
output,
|
|
|
|
objects,
|
|
|
|
libraries,
|
|
|
|
lib_dirs,
|
|
|
|
scatter_file
|
|
|
|
):
|
2019-03-19 22:33:40 +00:00
|
|
|
cmd = ARM.get_link_command(
|
|
|
|
self, output, objects, libraries, lib_dirs, scatter_file
|
|
|
|
)
|
|
|
|
|
|
|
|
if self.is_mbed_studio_armc6:
|
2019-03-21 21:24:44 +00:00
|
|
|
# NOTE: the --ide=mbed argument is only for use with Mbed OS
|
2019-03-19 22:33:40 +00:00
|
|
|
cmd.insert(1, "--ide=mbed")
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
|
|
|
|
def get_binary_commands(self, bin_arg, bin, elf):
|
|
|
|
cmd = ARM.get_binary_commands(self, bin_arg, bin, elf)
|
|
|
|
|
|
|
|
if self.is_mbed_studio_armc6:
|
2019-03-21 21:24:44 +00:00
|
|
|
# NOTE: the --ide=mbed argument is only for use with Mbed OS
|
2019-03-19 22:33:40 +00:00
|
|
|
cmd.insert(1, "--ide=mbed")
|
|
|
|
|
|
|
|
return cmd
|
2019-11-14 11:58:01 +00:00
|
|
|
|