Skip to content

Commit 51c1016

Browse files
committed
Fixed toolchain flags so exporters can use them
1 parent 75a18ff commit 51c1016

File tree

3 files changed

+46
-33
lines changed

3 files changed

+46
-33
lines changed

tools/toolchains/arm.py

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from tools.settings import ARM_BIN, ARM_INC, ARM_LIB, MY_ARM_CLIB, ARM_CPPLIB, GOANNA_PATH
2222
from tools.hooks import hook_tool
2323
from tools.utils import mkdir
24+
import copy
2425

2526
class ARM(mbedToolchain):
2627
LINKER_EXT = '.sct'
@@ -30,6 +31,17 @@ class ARM(mbedToolchain):
3031
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)')
3132
DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')
3233

34+
35+
DEFAULT_FLAGS = {
36+
'common': ["-c", "--gnu",
37+
"-Otime", "--split_sections", "--apcs=interwork",
38+
"--brief_diagnostics", "--restrict", "--multibyte_chars", "-I", "\""+ARM_INC+"\""],
39+
'asm': [],
40+
'c': ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
41+
'cxx': ["--cpp", "--no_rtti"],
42+
'ld': [],
43+
}
44+
3345
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
3446
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
3547

@@ -43,34 +55,25 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
4355
cpu = target.core
4456

4557
main_cc = join(ARM_BIN, "armcc")
46-
common = ["-c",
47-
"--cpu=%s" % cpu, "--gnu",
48-
"-Otime", "--split_sections", "--apcs=interwork",
49-
"--brief_diagnostics", "--restrict", "--multibyte_chars"
50-
]
5158

59+
self.flags = copy.deepcopy(self.DEFAULT_FLAGS)
60+
self.flags['common'] += ["--cpu=%s" % cpu]
5261
if "save-asm" in self.options:
53-
common.extend(["--asm", "--interleave"])
62+
self.flags['common'].extend(["--asm", "--interleave"])
5463

5564
if "debug-info" in self.options:
56-
common.append("-O0")
65+
self.flags['common'].append("-g")
66+
self.flags['c'].append("-O0")
5767
else:
58-
common.append("-O3")
59-
# add debug symbols for all builds
60-
common.append("-g")
61-
62-
common_c = [
63-
"--md", "--no_depend_system_headers",
64-
'-I%s' % ARM_INC
65-
]
68+
self.flags['c'].append("-O3")
6669

67-
self.asm = [main_cc] + common + ['-I%s' % ARM_INC]
70+
self.asm = [main_cc] + self.flags['common'] + self.flags['asm']
6871
if not "analyze" in self.options:
69-
self.cc = [main_cc] + common + common_c + ["--c99"]
70-
self.cppc = [main_cc] + common + common_c + ["--cpp", "--no_rtti"]
72+
self.cc = [main_cc] + self.flags['common'] + self.flags['c']
73+
self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
7174
else:
72-
self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--c99"]
73-
self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--cpp", "--no_rtti"]
75+
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']
76+
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']
7477

7578
self.ld = [join(ARM_BIN, "armlink")]
7679
self.sys_libs = []
@@ -214,8 +217,11 @@ def binary(self, resources, elf, bin):
214217
class ARM_STD(ARM):
215218
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
216219
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
217-
self.cc += ["-D__ASSERT_MSG"]
218-
self.cppc += ["-D__ASSERT_MSG"]
220+
221+
# Extend flags
222+
self.flags['ld'].extend(["--libpath", ARM_LIB])
223+
224+
# Run-time values
219225
self.ld.extend(["--libpath", ARM_LIB])
220226

221227

@@ -225,18 +231,24 @@ class ARM_MICRO(ARM):
225231
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
226232
ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
227233

228-
# Compiler
229-
self.asm += ["-D__MICROLIB"]
230-
self.cc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
231-
self.cppc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
234+
# Extend flags
235+
self.flags['common'].extend(["-D__MICROLIB"])
236+
self.flags['c'].extend(["--library_type=microlib"])
237+
self.flags['ld'].extend(["--library_type=microlib"])
232238

233-
# Linker
234-
self.ld.append("--library_type=microlib")
239+
# Run-time values
240+
self.asm += ["-D__MICROLIB"]
241+
self.cc += ["-D__MICROLIB", "--library_type=microlib"]
242+
self.cppc += ["-D__MICROLIB", "--library_type=microlib"]
243+
self.ld += ["--library_type=microlib"]
235244

236245
# We had to patch microlib to add C++ support
237246
# In later releases this patch should have entered mainline
238247
if ARM_MICRO.PATCHED_LIBRARY:
239-
self.ld.append("--noscanlib")
248+
# Run-time values
249+
self.flags['ld'].extend(["--noscanlib"])
250+
# Run-time values
251+
self.ld += ["--noscanlib"]
240252

241253
# System Libraries
242254
self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
@@ -247,4 +259,7 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
247259
elif target.core in ["Cortex-M0", "Cortex-M0+"]:
248260
self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ps", "cpprt_p"]])
249261
else:
262+
# Run-time values
263+
self.flags['ld'].extend(["--libpath", ARM_LIB])
264+
# Run-time values
250265
self.ld.extend(["--libpath", ARM_LIB])

tools/toolchains/gcc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
7474
common_flags.append("-save-temps")
7575

7676
if "debug-info" in self.options:
77+
common_flags.append("-g")
7778
common_flags.append("-O0")
7879
else:
7980
common_flags.append("-O2")
80-
# add debug symbols for all builds
81-
common_flags.append("-g")
8281

8382
main_cc = join(tool_path, "arm-none-eabi-gcc")
8483
main_cppc = join(tool_path, "arm-none-eabi-g++")

tools/toolchains/iar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
5353

5454

5555
if "debug-info" in self.options:
56+
c_flags.append("-r")
5657
c_flags.append("-On")
5758
else:
5859
c_flags.append("-Oh")
59-
# add debug symbols for all builds
60-
c_flags.append("-r")
6160

6261
IAR_BIN = join(IAR_PATH, "bin")
6362
main_cc = join(IAR_BIN, "iccarm")

0 commit comments

Comments
 (0)