Skip to content

Commit dcd358f

Browse files
author
Cruz Monrreal
authored
Merge pull request #7558 from theotherjimmy/tc-arm-v8m
Tools: Select compiler based on arch version
2 parents c5680b5 + 76078f6 commit dcd358f

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

tools/build_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
BUILD_DIR)
4545
from .resources import Resources, FileType, FileRef
4646
from .notifier.mock import MockNotifier
47-
from .targets import TARGET_NAMES, TARGET_MAP
47+
from .targets import TARGET_NAMES, TARGET_MAP, CORE_ARCH
4848
from .libraries import Library
4949
from .toolchains import TOOLCHAIN_CLASSES
5050
from .config import Config
@@ -316,6 +316,8 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
316316
raise NotSupportedException(
317317
"Target {} is not supported by toolchain {}".format(
318318
target.name, toolchain_name))
319+
if (toolchain_name == "ARM" and CORE_ARCH[target.core] == 8):
320+
toolchain_name = "ARMC6"
319321

320322
try:
321323
cur_tc = TOOLCHAIN_CLASSES[toolchain_name]
@@ -1196,9 +1198,13 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None,
11961198
row.append(text)
11971199

11981200
for unique_toolchain in unique_supported_toolchains:
1199-
if (unique_toolchain in TARGET_MAP[target].supported_toolchains or
1201+
tgt_obj = TARGET_MAP[target]
1202+
if (unique_toolchain in tgt_obj.supported_toolchains or
12001203
(unique_toolchain == "ARMC6" and
1201-
"ARM" in TARGET_MAP[target].supported_toolchains)):
1204+
"ARM" in tgt_obj.supported_toolchains) or
1205+
(unique_toolchain == "ARM" and
1206+
"ARMC6" in tgt_obj.supported_toolchains and
1207+
CORE_ARCH[tgt_obj.core] == 8)):
12021208
text = "Supported"
12031209
perm_counter += 1
12041210
else:

tools/targets/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from tools.utils import json_file_to_dict
3131

3232
__all__ = ["target", "TARGETS", "TARGET_MAP", "TARGET_NAMES", "CORE_LABELS",
33-
"HookError", "generate_py_target", "Target",
33+
"CORE_ARCH", "HookError", "generate_py_target", "Target",
3434
"CUMULATIVE_ATTRIBUTES", "get_resolution_order"]
3535

3636
CORE_LABELS = {
@@ -50,6 +50,23 @@
5050
"Cortex-M33-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"]
5151
}
5252

53+
CORE_ARCH = {
54+
"Cortex-M0": 6,
55+
"Cortex-M0+": 6,
56+
"Cortex-M1": 6,
57+
"Cortex-M3": 7,
58+
"Cortex-M4": 7,
59+
"Cortex-M4F": 7,
60+
"Cortex-M7": 7,
61+
"Cortex-M7F": 7,
62+
"Cortex-M7FD": 7,
63+
"Cortex-A9": 7,
64+
"Cortex-M23": 8,
65+
"Cortex-M23-NS": 8,
66+
"Cortex-M33": 8,
67+
"Cortex-M33-NS": 8,
68+
}
69+
5370
################################################################################
5471
# Generic Target class that reads and interprets the data in targets.json
5572

tools/test/toolchains/api_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_toolchain_profile_asm(profile, source_file):
184184
with patch('os.mkdir') as _mkdir:
185185
for _, tc_class in TOOLCHAIN_CLASSES.items():
186186
toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile,
187-
notify=MockNotifier)
187+
notify=MockNotifier())
188188
toolchain.inc_md5 = ""
189189
toolchain.build_dir = ""
190190
toolchain.config = MagicMock()

tools/toolchains/arm.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from shutil import rmtree
2626
from distutils.version import LooseVersion
2727

28+
from tools.targets import CORE_ARCH
2829
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2930
from tools.hooks import hook_tool
3031
from tools.utils import mkdir, NotSupportedException, run_cmd
@@ -368,6 +369,14 @@ def __init__(self, target, *args, **kwargs):
368369
if target.core not in self.SUPPORTED_CORES:
369370
raise NotSupportedException(
370371
"this compiler does not support the core %s" % target.core)
372+
if CORE_ARCH[target.core] < 8:
373+
self.notify.cc_info({
374+
'severity': "Error", 'file': "", 'line': "", 'col': "",
375+
'message': "ARMC6 does not support ARM architecture v{}"
376+
" targets".format(CORE_ARCH[target.core]),
377+
'text': '', 'target_name': self.target.name,
378+
'toolchain_name': self.name
379+
})
371380

372381
if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)):
373382
raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")

0 commit comments

Comments
 (0)