mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Fixed toolchain flags so exporters can use them
							parent
							
								
									75a18ff1a3
								
							
						
					
					
						commit
						51c10165ca
					
				| 
						 | 
					@ -21,6 +21,7 @@ from tools.toolchains import mbedToolchain
 | 
				
			||||||
from tools.settings import ARM_BIN, ARM_INC, ARM_LIB, MY_ARM_CLIB, ARM_CPPLIB, GOANNA_PATH
 | 
					from tools.settings import ARM_BIN, ARM_INC, ARM_LIB, MY_ARM_CLIB, ARM_CPPLIB, GOANNA_PATH
 | 
				
			||||||
from tools.hooks import hook_tool
 | 
					from tools.hooks import hook_tool
 | 
				
			||||||
from tools.utils import mkdir
 | 
					from tools.utils import mkdir
 | 
				
			||||||
 | 
					import copy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ARM(mbedToolchain):
 | 
					class ARM(mbedToolchain):
 | 
				
			||||||
    LINKER_EXT = '.sct'
 | 
					    LINKER_EXT = '.sct'
 | 
				
			||||||
| 
						 | 
					@ -30,6 +31,17 @@ class ARM(mbedToolchain):
 | 
				
			||||||
    DIAGNOSTIC_PATTERN  = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)')
 | 
					    DIAGNOSTIC_PATTERN  = re.compile('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)')
 | 
				
			||||||
    DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')
 | 
					    DEP_PATTERN = re.compile('\S+:\s(?P<file>.+)\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DEFAULT_FLAGS = {
 | 
				
			||||||
 | 
					        'common': ["-c", "--gnu",
 | 
				
			||||||
 | 
					            "-Otime", "--split_sections", "--apcs=interwork",
 | 
				
			||||||
 | 
					            "--brief_diagnostics", "--restrict", "--multibyte_chars", "-I", "\""+ARM_INC+"\""],
 | 
				
			||||||
 | 
					        'asm': [],
 | 
				
			||||||
 | 
					        'c': ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
 | 
				
			||||||
 | 
					        'cxx': ["--cpp", "--no_rtti"],
 | 
				
			||||||
 | 
					        'ld': [],
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
					    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
				
			||||||
        mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
					        mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,34 +55,25 @@ class ARM(mbedToolchain):
 | 
				
			||||||
            cpu = target.core
 | 
					            cpu = target.core
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        main_cc = join(ARM_BIN, "armcc")
 | 
					        main_cc = join(ARM_BIN, "armcc")
 | 
				
			||||||
        common = ["-c",
 | 
					 | 
				
			||||||
            "--cpu=%s" % cpu, "--gnu",
 | 
					 | 
				
			||||||
            "-Otime", "--split_sections", "--apcs=interwork",
 | 
					 | 
				
			||||||
            "--brief_diagnostics", "--restrict", "--multibyte_chars"
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.flags = copy.deepcopy(self.DEFAULT_FLAGS)
 | 
				
			||||||
 | 
					        self.flags['common'] += ["--cpu=%s" % cpu]
 | 
				
			||||||
        if "save-asm" in self.options:
 | 
					        if "save-asm" in self.options:
 | 
				
			||||||
            common.extend(["--asm", "--interleave"])
 | 
					            self.flags['common'].extend(["--asm", "--interleave"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "debug-info" in self.options:
 | 
					        if "debug-info" in self.options:
 | 
				
			||||||
            common.append("-O0")
 | 
					            self.flags['common'].append("-g")
 | 
				
			||||||
 | 
					            self.flags['c'].append("-O0")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            common.append("-O3")
 | 
					            self.flags['c'].append("-O3")
 | 
				
			||||||
        # add debug symbols for all builds
 | 
					 | 
				
			||||||
        common.append("-g")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        common_c = [
 | 
					        self.asm = [main_cc] + self.flags['common'] + self.flags['asm']
 | 
				
			||||||
            "--md", "--no_depend_system_headers",
 | 
					 | 
				
			||||||
            '-I%s' % ARM_INC
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        self.asm = [main_cc] + common + ['-I%s' % ARM_INC]
 | 
					 | 
				
			||||||
        if not "analyze" in self.options:
 | 
					        if not "analyze" in self.options:
 | 
				
			||||||
            self.cc = [main_cc] + common + common_c + ["--c99"]
 | 
					            self.cc = [main_cc] + self.flags['common'] + self.flags['c']
 | 
				
			||||||
            self.cppc = [main_cc] + common + common_c + ["--cpp", "--no_rtti"]
 | 
					            self.cppc = [main_cc] + self.flags['common'] + self.flags['c'] + self.flags['cxx']
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.cc  = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "--dialect=armcc", '--output-format="%s"' % self.GOANNA_FORMAT] + common + common_c + ["--c99"]
 | 
					            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'] 
 | 
				
			||||||
            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"]
 | 
					            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']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.ld = [join(ARM_BIN, "armlink")]
 | 
					        self.ld = [join(ARM_BIN, "armlink")]
 | 
				
			||||||
        self.sys_libs = []
 | 
					        self.sys_libs = []
 | 
				
			||||||
| 
						 | 
					@ -214,8 +217,11 @@ class ARM(mbedToolchain):
 | 
				
			||||||
class ARM_STD(ARM):
 | 
					class ARM_STD(ARM):
 | 
				
			||||||
    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
					    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
				
			||||||
        ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
					        ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
				
			||||||
        self.cc   += ["-D__ASSERT_MSG"]
 | 
					
 | 
				
			||||||
        self.cppc += ["-D__ASSERT_MSG"]
 | 
					        # Extend flags
 | 
				
			||||||
 | 
					        self.flags['ld'].extend(["--libpath", ARM_LIB])
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        # Run-time values
 | 
				
			||||||
        self.ld.extend(["--libpath", ARM_LIB])
 | 
					        self.ld.extend(["--libpath", ARM_LIB])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -225,18 +231,24 @@ class ARM_MICRO(ARM):
 | 
				
			||||||
    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
					    def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
 | 
				
			||||||
        ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
					        ARM.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Compiler
 | 
					        # Extend flags
 | 
				
			||||||
        self.asm  += ["-D__MICROLIB"]
 | 
					        self.flags['common'].extend(["-D__MICROLIB"])
 | 
				
			||||||
        self.cc   += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
 | 
					        self.flags['c'].extend(["--library_type=microlib"])
 | 
				
			||||||
        self.cppc += ["--library_type=microlib", "-D__MICROLIB", "-D__ASSERT_MSG"]
 | 
					        self.flags['ld'].extend(["--library_type=microlib"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Linker
 | 
					        # Run-time values
 | 
				
			||||||
        self.ld.append("--library_type=microlib")
 | 
					        self.asm  += ["-D__MICROLIB"]
 | 
				
			||||||
 | 
					        self.cc   += ["-D__MICROLIB", "--library_type=microlib"]
 | 
				
			||||||
 | 
					        self.cppc += ["-D__MICROLIB", "--library_type=microlib"]
 | 
				
			||||||
 | 
					        self.ld   += ["--library_type=microlib"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # We had to patch microlib to add C++ support
 | 
					        # We had to patch microlib to add C++ support
 | 
				
			||||||
        # In later releases this patch should have entered mainline
 | 
					        # In later releases this patch should have entered mainline
 | 
				
			||||||
        if ARM_MICRO.PATCHED_LIBRARY:
 | 
					        if ARM_MICRO.PATCHED_LIBRARY:
 | 
				
			||||||
            self.ld.append("--noscanlib")
 | 
					            # Run-time values
 | 
				
			||||||
 | 
					            self.flags['ld'].extend(["--noscanlib"])
 | 
				
			||||||
 | 
					            # Run-time values
 | 
				
			||||||
 | 
					            self.ld   += ["--noscanlib"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # System Libraries
 | 
					            # System Libraries
 | 
				
			||||||
            self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
 | 
					            self.sys_libs.extend([join(MY_ARM_CLIB, lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
 | 
				
			||||||
| 
						 | 
					@ -247,4 +259,7 @@ class ARM_MICRO(ARM):
 | 
				
			||||||
            elif target.core in ["Cortex-M0", "Cortex-M0+"]:
 | 
					            elif target.core in ["Cortex-M0", "Cortex-M0+"]:
 | 
				
			||||||
                self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ps", "cpprt_p"]])
 | 
					                self.sys_libs.extend([join(ARM_CPPLIB, lib+".l") for lib in ["cpp_ps", "cpprt_p"]])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
 | 
					            # Run-time values
 | 
				
			||||||
 | 
					            self.flags['ld'].extend(["--libpath", ARM_LIB])
 | 
				
			||||||
 | 
					            # Run-time values
 | 
				
			||||||
            self.ld.extend(["--libpath", ARM_LIB])
 | 
					            self.ld.extend(["--libpath", ARM_LIB])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,11 +74,10 @@ class GCC(mbedToolchain):
 | 
				
			||||||
            common_flags.append("-save-temps")
 | 
					            common_flags.append("-save-temps")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "debug-info" in self.options:
 | 
					        if "debug-info" in self.options:
 | 
				
			||||||
 | 
					            common_flags.append("-g")
 | 
				
			||||||
            common_flags.append("-O0")
 | 
					            common_flags.append("-O0")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            common_flags.append("-O2")
 | 
					            common_flags.append("-O2")
 | 
				
			||||||
        # add debug symbols for all builds
 | 
					 | 
				
			||||||
        common_flags.append("-g")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        main_cc = join(tool_path, "arm-none-eabi-gcc")
 | 
					        main_cc = join(tool_path, "arm-none-eabi-gcc")
 | 
				
			||||||
        main_cppc = join(tool_path, "arm-none-eabi-g++")
 | 
					        main_cppc = join(tool_path, "arm-none-eabi-g++")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,11 +53,10 @@ class IAR(mbedToolchain):
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "debug-info" in self.options:
 | 
					        if "debug-info" in self.options:
 | 
				
			||||||
 | 
					            c_flags.append("-r")
 | 
				
			||||||
            c_flags.append("-On")
 | 
					            c_flags.append("-On")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            c_flags.append("-Oh")
 | 
					            c_flags.append("-Oh")
 | 
				
			||||||
        # add debug symbols for all builds
 | 
					 | 
				
			||||||
        c_flags.append("-r")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IAR_BIN = join(IAR_PATH, "bin")
 | 
					        IAR_BIN = join(IAR_PATH, "bin")
 | 
				
			||||||
        main_cc = join(IAR_BIN, "iccarm")
 | 
					        main_cc = join(IAR_BIN, "iccarm")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue