Skip to content

Commit 69c3da5

Browse files
committed
iar - flags consolidation
- vla flag is not compatible with c++ (not supported), it generates an error in the IDE. Therefore we remove it - common flags - add dlib and thum to the common flags. - cpu flag is for only runtime cmd, IDE sets it via defined MCU, not required.
1 parent bf6b88a commit 69c3da5

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

tools/export/iar.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from tools.export.exporters import Exporter
2222
from tools.targets import TARGET_MAP, TARGET_NAMES
23+
from tools.settings import IAR_PATH
2324

2425
# If you wish to add a new target, add it to project_generator_definitions, and then
2526
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -70,6 +71,15 @@ def generate(self):
7071
project_data['tool_specific']['iar'].setdefault("misc", {})
7172
project_data['tool_specific']['iar'].update(tool_specific['iar'])
7273
project_data['tool_specific']['iar']['misc'].update(self.progen_flags)
74+
# progen does not have common flags, expand c flags by common one
75+
project_data['tool_specific']['iar']['misc']['c_flags'] += self.progen_flags['common_flags']
76+
# template sets full dlib, this would produce the error as it's duplicate
77+
project_data['tool_specific']['iar']['misc']['c_flags'].remove("--dlib_config")
78+
project_data['tool_specific']['iar']['misc']['c_flags'].remove(os.path.join(IAR_PATH, "inc", "c", "DLib_Config_Full.h"))
79+
# these c++ flags are set by template - c++, no rtti, no exceptions
80+
project_data['tool_specific']['iar']['misc']['cxx_flags'].remove("--c++")
81+
project_data['tool_specific']['iar']['misc']['cxx_flags'].remove("--no_rtti")
82+
project_data['tool_specific']['iar']['misc']['cxx_flags'].remove("--no_exceptions")
7383
project_data['common']['build_dir'] = os.path.join(project_data['common']['build_dir'], 'iar_arm')
7484
self.progen_gen_file('iar_arm', project_data)
7585

tools/toolchains/iar.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class IAR(mbedToolchain):
3838
# Pa093: Implicit conversion from float to integer (ie: wait_ms(85.4) -> wait_ms(85))
3939
# Pa082: Operation involving two values from two registers (ie: (float)(*obj->MR)/(float)(LPC_PWM1->MR0))
4040
"-e", # Enable IAR language extension
41-
"--diag_suppress=Pa050,Pa084,Pa093,Pa082"],
41+
"--diag_suppress=Pa050,Pa084,Pa093,Pa082",
42+
"--thumb",
43+
"--dlib_config", join(IAR_PATH, "inc", "c", "DLib_Config_Full.h")],
4244
'asm': [],
43-
'c': ["--vla"],
45+
'c': [],
4446
'cxx': ["--c++", "--no_rtti", "--no_exceptions", "--guard_calls"],
4547
'ld': ["--skip_dynamic_initialization", "--threaded_lib"],
4648
}
@@ -51,35 +53,31 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
5153
cpuchoice = "Cortex-M7"
5254
else:
5355
cpuchoice = target.core
54-
self.flags["common"] += [
55-
"--cpu=%s" % cpuchoice, "--thumb",
56-
"--dlib_config", join(IAR_PATH, "inc", "c", "DLib_Config_Full.h"),
57-
]
5856

5957
if target.core == "Cortex-M7F":
6058
self.flags["common"].append("--fpu=VFPv5_sp")
6159

60+
optimization = []
6261
if "debug-info" in self.options:
63-
self.flags["common"].append("-r")
64-
self.flags["common"].append("-On")
62+
optimization.append("-r")
63+
optimization.append("-On")
6564
else:
66-
self.flags["common"].append("-Oh")
65+
optimization.append("-Oh")
6766

6867
IAR_BIN = join(IAR_PATH, "bin")
6968
main_cc = join(IAR_BIN, "iccarm")
7069

71-
self.flags["asm"] += ["--cpu", cpuchoice]
7270
if target.core == "Cortex-M7F":
7371
self.flags["asm"] += ["--fpu", "VFPv5_sp"]
74-
self.asm = [join(IAR_BIN, "iasmarm")] + self.flags["asm"]
72+
self.asm = [join(IAR_BIN, "iasmarm")] + self.flags["asm"] + ["--cpu=%s" % cpuchoice]
7573
if not "analyze" in self.options:
7674
self.cc = [main_cc]
7775
self.cppc = [main_cc]
7876
else:
7977
self.cc = [join(GOANNA_PATH, "goannacc"), '--with-cc="%s"' % main_cc.replace('\\', '/'), "--dialect=iar-arm", '--output-format="%s"' % self.GOANNA_FORMAT]
8078
self.cppc = [join(GOANNA_PATH, "goannac++"), '--with-cxx="%s"' % main_cc.replace('\\', '/'), "--dialect=iar-arm", '--output-format="%s"' % self.GOANNA_FORMAT]
81-
self.cc += self.flags["common"] + self.flags["c"]
82-
self.cppc += self.flags["common"] + self.flags["cxx"]
79+
self.cc += self.flags["common"] + self.flags["c"] + ["--cpu=%s" % cpuchoice] + optimization
80+
self.cppc += self.flags["common"] + self.flags["cxx"] + ["--cpu=%s" % cpuchoice] + optimization
8381
self.ld = join(IAR_BIN, "ilinkarm")
8482
self.ar = join(IAR_BIN, "iarchive")
8583
self.elf2bin = join(IAR_BIN, "ielftool")

0 commit comments

Comments
 (0)