Skip to content

Commit c16c75f

Browse files
committed
iar - fix flags for cmd and exporters
Exporters and cmd do not share all flags, some asm and c flags are not the same (cpu, fpu)
1 parent 1bdd45c commit c16c75f

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

tools/toolchains/iar.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class IAR(mbedToolchain):
4141
"--diag_suppress=Pa050,Pa084,Pa093,Pa082"],
4242
'asm': [],
4343
'c': [],
44-
'cxx': ["--c++", "--no_rtti", "--no_exceptions", "--guard_calls"],
44+
'cxx': ["--guard_calls"],
4545
'ld': ["--skip_dynamic_initialization", "--threaded_lib"],
4646
}
4747

@@ -51,35 +51,43 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
5151
cpuchoice = "Cortex-M7"
5252
else:
5353
cpuchoice = target.core
54-
self.flags["common"] += [
55-
"--cpu=%s" % cpuchoice, "--thumb",
56-
"--dlib_config", join(IAR_PATH, "inc", "c", "DLib_Config_Full.h"),
54+
# flags_cmd are used only by our scripts, the project files have them already defined,
55+
# using this flags results in the errors (duplication)
56+
# asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core
57+
asm_flags_cmd = [
58+
"--cpu", cpuchoice
59+
]
60+
# custom c flags
61+
c_flags_cmd = [
62+
"--cpu", cpuchoice,
63+
"--thumb", "--dlib_config", join(IAR_PATH, "inc", "c", "DLib_Config_Full.h")
64+
]
65+
# custom c++ cmd flags
66+
cxx_flags_cmd = [
67+
"--c++", "--no_rtti", "--no_exceptions"
5768
]
58-
5969
if target.core == "Cortex-M7F":
60-
self.flags["common"].append("--fpu=VFPv5_sp")
70+
asm_flags_cmd += ["--fpu", "VFPv5_sp"]
71+
c_flags_cmd.append("--fpu=VFPv5_sp")
6172

6273
if "debug-info" in self.options:
63-
self.flags["common"].append("-r")
64-
self.flags["common"].append("-On")
74+
c_flags_cmd.append("-r")
75+
c_flags_cmd.append("-On")
6576
else:
66-
self.flags["common"].append("-Oh")
77+
c_flags_cmd.append("-Oh")
6778

6879
IAR_BIN = join(IAR_PATH, "bin")
6980
main_cc = join(IAR_BIN, "iccarm")
7081

71-
self.flags["asm"] += ["--cpu", cpuchoice]
72-
if target.core == "Cortex-M7F":
73-
self.flags["asm"] += ["--fpu", "VFPv5_sp"]
74-
self.asm = [join(IAR_BIN, "iasmarm")] + self.flags["asm"]
82+
self.asm = [join(IAR_BIN, "iasmarm")] + asm_flags_cmd + self.flags["asm"]
7583
if not "analyze" in self.options:
7684
self.cc = [main_cc]
7785
self.cppc = [main_cc]
7886
else:
7987
self.cc = [join(GOANNA_PATH, "goannacc"), '--with-cc="%s"' % main_cc.replace('\\', '/'), "--dialect=iar-arm", '--output-format="%s"' % self.GOANNA_FORMAT]
8088
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"]
89+
self.cc += self.flags["common"] + c_flags_cmd + self.flags["c"]
90+
self.cppc += self.flags["common"] + c_flags_cmd + cxx_flags_cmd + self.flags["cxx"]
8391
self.ld = join(IAR_BIN, "ilinkarm")
8492
self.ar = join(IAR_BIN, "iarchive")
8593
self.elf2bin = join(IAR_BIN, "ielftool")

0 commit comments

Comments
 (0)