Clone of official tools
toolchains/gcc.py@24:25bff2709c20, 2016-08-01 (annotated)
- Committer:
- screamer
- Date:
- Mon Aug 01 09:10:17 2016 +0100
- Revision:
- 24:25bff2709c20
- Parent:
- 22:9e85236d8716
- Child:
- 29:1210849dba19
Major update to tools from ARMmbed/mbed-os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:66f3b5499f7f | 1 | """ |
screamer | 0:66f3b5499f7f | 2 | mbed SDK |
screamer | 0:66f3b5499f7f | 3 | Copyright (c) 2011-2013 ARM Limited |
screamer | 0:66f3b5499f7f | 4 | |
screamer | 0:66f3b5499f7f | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
screamer | 0:66f3b5499f7f | 6 | you may not use this file except in compliance with the License. |
screamer | 0:66f3b5499f7f | 7 | You may obtain a copy of the License at |
screamer | 0:66f3b5499f7f | 8 | |
screamer | 0:66f3b5499f7f | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
screamer | 0:66f3b5499f7f | 10 | |
screamer | 0:66f3b5499f7f | 11 | Unless required by applicable law or agreed to in writing, software |
screamer | 0:66f3b5499f7f | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
screamer | 0:66f3b5499f7f | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
screamer | 0:66f3b5499f7f | 14 | See the License for the specific language governing permissions and |
screamer | 0:66f3b5499f7f | 15 | limitations under the License. |
screamer | 0:66f3b5499f7f | 16 | """ |
screamer | 0:66f3b5499f7f | 17 | import re |
screamer | 0:66f3b5499f7f | 18 | from os.path import join, basename, splitext, dirname, exists |
screamer | 0:66f3b5499f7f | 19 | |
screamer | 20:835f6355470d | 20 | from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS |
screamer | 0:66f3b5499f7f | 21 | from tools.hooks import hook_tool |
screamer | 0:66f3b5499f7f | 22 | |
screamer | 0:66f3b5499f7f | 23 | class GCC(mbedToolchain): |
screamer | 0:66f3b5499f7f | 24 | LINKER_EXT = '.ld' |
screamer | 0:66f3b5499f7f | 25 | LIBRARY_EXT = '.a' |
screamer | 0:66f3b5499f7f | 26 | |
screamer | 0:66f3b5499f7f | 27 | STD_LIB_NAME = "lib%s.a" |
screamer | 13:ab47a20b66f0 | 28 | DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)') |
screamer | 21:4fdf0dd04f6f | 29 | INDEX_PATTERN = re.compile('(?P<col>\s*)\^') |
screamer | 0:66f3b5499f7f | 30 | |
screamer | 13:ab47a20b66f0 | 31 | DEFAULT_FLAGS = { |
screamer | 13:ab47a20b66f0 | 32 | 'common': ["-c", "-Wall", "-Wextra", |
screamer | 13:ab47a20b66f0 | 33 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", |
screamer | 13:ab47a20b66f0 | 34 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", |
screamer | 13:ab47a20b66f0 | 35 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", |
screamer | 13:ab47a20b66f0 | 36 | "-MMD", "-fno-delete-null-pointer-checks", "-fomit-frame-pointer" |
screamer | 13:ab47a20b66f0 | 37 | ], |
screamer | 13:ab47a20b66f0 | 38 | 'asm': ["-x", "assembler-with-cpp"], |
screamer | 13:ab47a20b66f0 | 39 | 'c': ["-std=gnu99"], |
screamer | 13:ab47a20b66f0 | 40 | 'cxx': ["-std=gnu++98", "-fno-rtti", "-Wvla"], |
screamer | 13:ab47a20b66f0 | 41 | 'ld': ["-Wl,--gc-sections", "-Wl,--wrap,main", |
screamer | 13:ab47a20b66f0 | 42 | "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r"], |
screamer | 13:ab47a20b66f0 | 43 | } |
screamer | 13:ab47a20b66f0 | 44 | |
screamer | 13:ab47a20b66f0 | 45 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False): |
screamer | 13:ab47a20b66f0 | 46 | mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 47 | |
screamer | 0:66f3b5499f7f | 48 | if target.core == "Cortex-M0+": |
screamer | 0:66f3b5499f7f | 49 | cpu = "cortex-m0plus" |
screamer | 0:66f3b5499f7f | 50 | elif target.core == "Cortex-M4F": |
screamer | 0:66f3b5499f7f | 51 | cpu = "cortex-m4" |
screamer | 0:66f3b5499f7f | 52 | elif target.core == "Cortex-M7F": |
screamer | 0:66f3b5499f7f | 53 | cpu = "cortex-m7" |
screamer | 13:ab47a20b66f0 | 54 | elif target.core == "Cortex-M7FD": |
screamer | 13:ab47a20b66f0 | 55 | cpu = "cortex-m7" |
screamer | 0:66f3b5499f7f | 56 | else: |
screamer | 0:66f3b5499f7f | 57 | cpu = target.core.lower() |
screamer | 0:66f3b5499f7f | 58 | |
screamer | 0:66f3b5499f7f | 59 | self.cpu = ["-mcpu=%s" % cpu] |
screamer | 0:66f3b5499f7f | 60 | if target.core.startswith("Cortex"): |
screamer | 0:66f3b5499f7f | 61 | self.cpu.append("-mthumb") |
screamer | 0:66f3b5499f7f | 62 | |
screamer | 13:ab47a20b66f0 | 63 | # FPU handling, M7 possibly to have double FPU |
screamer | 0:66f3b5499f7f | 64 | if target.core == "Cortex-M4F": |
screamer | 0:66f3b5499f7f | 65 | self.cpu.append("-mfpu=fpv4-sp-d16") |
screamer | 0:66f3b5499f7f | 66 | self.cpu.append("-mfloat-abi=softfp") |
screamer | 0:66f3b5499f7f | 67 | elif target.core == "Cortex-M7F": |
screamer | 13:ab47a20b66f0 | 68 | self.cpu.append("-mfpu=fpv5-sp-d16") |
screamer | 13:ab47a20b66f0 | 69 | self.cpu.append("-mfloat-abi=softfp") |
screamer | 13:ab47a20b66f0 | 70 | elif target.core == "Cortex-M7FD": |
screamer | 0:66f3b5499f7f | 71 | self.cpu.append("-mfpu=fpv5-d16") |
screamer | 0:66f3b5499f7f | 72 | self.cpu.append("-mfloat-abi=softfp") |
screamer | 0:66f3b5499f7f | 73 | |
screamer | 13:ab47a20b66f0 | 74 | |
screamer | 13:ab47a20b66f0 | 75 | |
screamer | 0:66f3b5499f7f | 76 | if target.core == "Cortex-A9": |
screamer | 0:66f3b5499f7f | 77 | self.cpu.append("-mthumb-interwork") |
screamer | 0:66f3b5499f7f | 78 | self.cpu.append("-marm") |
screamer | 0:66f3b5499f7f | 79 | self.cpu.append("-march=armv7-a") |
screamer | 0:66f3b5499f7f | 80 | self.cpu.append("-mfpu=vfpv3") |
screamer | 0:66f3b5499f7f | 81 | self.cpu.append("-mfloat-abi=hard") |
screamer | 0:66f3b5499f7f | 82 | self.cpu.append("-mno-unaligned-access") |
screamer | 0:66f3b5499f7f | 83 | |
screamer | 13:ab47a20b66f0 | 84 | |
screamer | 0:66f3b5499f7f | 85 | # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug: |
screamer | 0:66f3b5499f7f | 86 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762 |
screamer | 13:ab47a20b66f0 | 87 | self.flags["common"] += self.cpu |
screamer | 0:66f3b5499f7f | 88 | |
screamer | 0:66f3b5499f7f | 89 | if "save-asm" in self.options: |
screamer | 13:ab47a20b66f0 | 90 | self.flags["common"].append("-save-temps") |
screamer | 13:ab47a20b66f0 | 91 | |
screamer | 0:66f3b5499f7f | 92 | if "debug-info" in self.options: |
screamer | 13:ab47a20b66f0 | 93 | self.flags["common"].append("-g") |
screamer | 13:ab47a20b66f0 | 94 | self.flags["common"].append("-O0") |
screamer | 13:ab47a20b66f0 | 95 | else: |
screamer | 24:25bff2709c20 | 96 | self.flags["common"].append("-Os") |
screamer | 2:07730b0f452c | 97 | |
screamer | 13:ab47a20b66f0 | 98 | main_cc = join(tool_path, "arm-none-eabi-gcc") |
screamer | 13:ab47a20b66f0 | 99 | main_cppc = join(tool_path, "arm-none-eabi-g++") |
screamer | 13:ab47a20b66f0 | 100 | self.asm = [main_cc] + self.flags['asm'] + self.flags["common"] |
screamer | 21:4fdf0dd04f6f | 101 | self.cc = [main_cc] |
screamer | 21:4fdf0dd04f6f | 102 | self.cppc =[main_cppc] |
screamer | 13:ab47a20b66f0 | 103 | self.cc += self.flags['c'] + self.flags['common'] |
screamer | 13:ab47a20b66f0 | 104 | self.cppc += self.flags['cxx'] + self.flags['common'] |
screamer | 0:66f3b5499f7f | 105 | |
screamer | 13:ab47a20b66f0 | 106 | self.flags['ld'] += self.cpu |
screamer | 13:ab47a20b66f0 | 107 | self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld'] |
screamer | 0:66f3b5499f7f | 108 | self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] |
screamer | 0:66f3b5499f7f | 109 | |
screamer | 0:66f3b5499f7f | 110 | self.ar = join(tool_path, "arm-none-eabi-ar") |
screamer | 0:66f3b5499f7f | 111 | self.elf2bin = join(tool_path, "arm-none-eabi-objcopy") |
screamer | 0:66f3b5499f7f | 112 | |
screamer | 0:66f3b5499f7f | 113 | def parse_dependencies(self, dep_path): |
screamer | 0:66f3b5499f7f | 114 | dependencies = [] |
screamer | 0:66f3b5499f7f | 115 | buff = open(dep_path).readlines() |
screamer | 0:66f3b5499f7f | 116 | buff[0] = re.sub('^(.*?)\: ', '', buff[0]) |
screamer | 0:66f3b5499f7f | 117 | for line in buff: |
screamer | 0:66f3b5499f7f | 118 | file = line.replace('\\\n', '').strip() |
screamer | 0:66f3b5499f7f | 119 | if file: |
screamer | 0:66f3b5499f7f | 120 | # GCC might list more than one dependency on a single line, in this case |
screamer | 0:66f3b5499f7f | 121 | # the dependencies are separated by a space. However, a space might also |
screamer | 0:66f3b5499f7f | 122 | # indicate an actual space character in a dependency path, but in this case |
screamer | 0:66f3b5499f7f | 123 | # the space character is prefixed by a backslash. |
screamer | 0:66f3b5499f7f | 124 | # Temporary replace all '\ ' with a special char that is not used (\a in this |
screamer | 0:66f3b5499f7f | 125 | # case) to keep them from being interpreted by 'split' (they will be converted |
screamer | 0:66f3b5499f7f | 126 | # back later to a space char) |
screamer | 0:66f3b5499f7f | 127 | file = file.replace('\\ ', '\a') |
screamer | 0:66f3b5499f7f | 128 | if file.find(" ") == -1: |
screamer | 21:4fdf0dd04f6f | 129 | dependencies.append((self.CHROOT if self.CHROOT else '') + file.replace('\a', ' ')) |
screamer | 0:66f3b5499f7f | 130 | else: |
screamer | 21:4fdf0dd04f6f | 131 | dependencies = dependencies + [(self.CHROOT if self.CHROOT else '') + f.replace('\a', ' ') for f in file.split(" ")] |
screamer | 0:66f3b5499f7f | 132 | return dependencies |
screamer | 0:66f3b5499f7f | 133 | |
screamer | 0:66f3b5499f7f | 134 | def is_not_supported_error(self, output): |
screamer | 0:66f3b5499f7f | 135 | return "error: #error [NOT_SUPPORTED]" in output |
screamer | 0:66f3b5499f7f | 136 | |
screamer | 0:66f3b5499f7f | 137 | def parse_output(self, output): |
screamer | 0:66f3b5499f7f | 138 | # The warning/error notification is multiline |
screamer | 21:4fdf0dd04f6f | 139 | msg = None |
screamer | 0:66f3b5499f7f | 140 | for line in output.splitlines(): |
screamer | 13:ab47a20b66f0 | 141 | match = GCC.DIAGNOSTIC_PATTERN.match(line) |
screamer | 13:ab47a20b66f0 | 142 | if match is not None: |
screamer | 21:4fdf0dd04f6f | 143 | if msg is not None: |
screamer | 21:4fdf0dd04f6f | 144 | self.cc_info(msg) |
screamer | 21:4fdf0dd04f6f | 145 | msg = { |
screamer | 21:4fdf0dd04f6f | 146 | 'severity': match.group('severity').lower(), |
screamer | 21:4fdf0dd04f6f | 147 | 'file': match.group('file'), |
screamer | 21:4fdf0dd04f6f | 148 | 'line': match.group('line'), |
screamer | 21:4fdf0dd04f6f | 149 | 'col': 0, |
screamer | 21:4fdf0dd04f6f | 150 | 'message': match.group('message'), |
screamer | 21:4fdf0dd04f6f | 151 | 'text': '', |
screamer | 21:4fdf0dd04f6f | 152 | 'target_name': self.target.name, |
screamer | 21:4fdf0dd04f6f | 153 | 'toolchain_name': self.name |
screamer | 21:4fdf0dd04f6f | 154 | } |
screamer | 21:4fdf0dd04f6f | 155 | elif msg is not None: |
screamer | 24:25bff2709c20 | 156 | # Determine the warning/error column by calculating the ^ position |
screamer | 21:4fdf0dd04f6f | 157 | match = GCC.INDEX_PATTERN.match(line) |
screamer | 21:4fdf0dd04f6f | 158 | if match is not None: |
screamer | 21:4fdf0dd04f6f | 159 | msg['col'] = len(match.group('col')) |
screamer | 21:4fdf0dd04f6f | 160 | self.cc_info(msg) |
screamer | 21:4fdf0dd04f6f | 161 | msg = None |
screamer | 21:4fdf0dd04f6f | 162 | else: |
screamer | 21:4fdf0dd04f6f | 163 | msg['text'] += line+"\n" |
screamer | 0:66f3b5499f7f | 164 | |
screamer | 0:66f3b5499f7f | 165 | def get_dep_option(self, object): |
screamer | 0:66f3b5499f7f | 166 | base, _ = splitext(object) |
screamer | 0:66f3b5499f7f | 167 | dep_path = base + '.d' |
screamer | 0:66f3b5499f7f | 168 | return ["-MD", "-MF", dep_path] |
screamer | 0:66f3b5499f7f | 169 | |
screamer | 13:ab47a20b66f0 | 170 | def get_config_option(self, config_header): |
screamer | 13:ab47a20b66f0 | 171 | return ['-include', config_header] |
screamer | 13:ab47a20b66f0 | 172 | |
screamer | 0:66f3b5499f7f | 173 | def get_compile_options(self, defines, includes): |
screamer | 21:4fdf0dd04f6f | 174 | opts = ['-D%s' % d for d in defines] |
screamer | 21:4fdf0dd04f6f | 175 | if self.RESPONSE_FILES: |
screamer | 21:4fdf0dd04f6f | 176 | opts += ['@%s' % self.get_inc_file(includes)] |
screamer | 21:4fdf0dd04f6f | 177 | else: |
screamer | 21:4fdf0dd04f6f | 178 | opts += ["-I%s" % i for i in includes] |
screamer | 21:4fdf0dd04f6f | 179 | |
screamer | 13:ab47a20b66f0 | 180 | config_header = self.get_config_header() |
screamer | 13:ab47a20b66f0 | 181 | if config_header is not None: |
screamer | 13:ab47a20b66f0 | 182 | opts = opts + self.get_config_option(config_header) |
screamer | 13:ab47a20b66f0 | 183 | return opts |
screamer | 0:66f3b5499f7f | 184 | |
screamer | 0:66f3b5499f7f | 185 | @hook_tool |
screamer | 0:66f3b5499f7f | 186 | def assemble(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 187 | # Build assemble command |
screamer | 0:66f3b5499f7f | 188 | cmd = self.asm + self.get_compile_options(self.get_symbols(), includes) + ["-o", object, source] |
screamer | 0:66f3b5499f7f | 189 | |
screamer | 0:66f3b5499f7f | 190 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 191 | cmd = self.hook.get_cmdline_assembler(cmd) |
screamer | 0:66f3b5499f7f | 192 | |
screamer | 0:66f3b5499f7f | 193 | # Return command array, don't execute |
screamer | 0:66f3b5499f7f | 194 | return [cmd] |
screamer | 0:66f3b5499f7f | 195 | |
screamer | 0:66f3b5499f7f | 196 | @hook_tool |
screamer | 0:66f3b5499f7f | 197 | def compile(self, cc, source, object, includes): |
screamer | 0:66f3b5499f7f | 198 | # Build compile command |
screamer | 0:66f3b5499f7f | 199 | cmd = cc + self.get_compile_options(self.get_symbols(), includes) |
screamer | 0:66f3b5499f7f | 200 | |
screamer | 0:66f3b5499f7f | 201 | cmd.extend(self.get_dep_option(object)) |
screamer | 0:66f3b5499f7f | 202 | |
screamer | 0:66f3b5499f7f | 203 | cmd.extend(["-o", object, source]) |
screamer | 13:ab47a20b66f0 | 204 | |
screamer | 0:66f3b5499f7f | 205 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 206 | cmd = self.hook.get_cmdline_compiler(cmd) |
screamer | 0:66f3b5499f7f | 207 | |
screamer | 0:66f3b5499f7f | 208 | return [cmd] |
screamer | 0:66f3b5499f7f | 209 | |
screamer | 0:66f3b5499f7f | 210 | def compile_c(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 211 | return self.compile(self.cc, source, object, includes) |
screamer | 0:66f3b5499f7f | 212 | |
screamer | 0:66f3b5499f7f | 213 | def compile_cpp(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 214 | return self.compile(self.cppc, source, object, includes) |
screamer | 0:66f3b5499f7f | 215 | |
screamer | 0:66f3b5499f7f | 216 | @hook_tool |
screamer | 0:66f3b5499f7f | 217 | def link(self, output, objects, libraries, lib_dirs, mem_map): |
screamer | 0:66f3b5499f7f | 218 | libs = [] |
screamer | 0:66f3b5499f7f | 219 | for l in libraries: |
screamer | 0:66f3b5499f7f | 220 | name, _ = splitext(basename(l)) |
screamer | 0:66f3b5499f7f | 221 | libs.append("-l%s" % name[3:]) |
screamer | 0:66f3b5499f7f | 222 | libs.extend(["-l%s" % l for l in self.sys_libs]) |
screamer | 0:66f3b5499f7f | 223 | |
screamer | 0:66f3b5499f7f | 224 | # Build linker command |
screamer | 7:5af61d55adbe | 225 | map_file = splitext(output)[0] + ".map" |
screamer | 13:ab47a20b66f0 | 226 | cmd = self.ld + ["-o", output, "-Wl,-Map=%s" % map_file] + objects + ["-Wl,--start-group"] + libs + ["-Wl,--end-group"] |
screamer | 0:66f3b5499f7f | 227 | if mem_map: |
screamer | 0:66f3b5499f7f | 228 | cmd.extend(['-T', mem_map]) |
screamer | 13:ab47a20b66f0 | 229 | |
screamer | 0:66f3b5499f7f | 230 | for L in lib_dirs: |
screamer | 0:66f3b5499f7f | 231 | cmd.extend(['-L', L]) |
screamer | 0:66f3b5499f7f | 232 | cmd.extend(libs) |
screamer | 0:66f3b5499f7f | 233 | |
screamer | 0:66f3b5499f7f | 234 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 235 | cmd = self.hook.get_cmdline_linker(cmd) |
screamer | 0:66f3b5499f7f | 236 | |
screamer | 21:4fdf0dd04f6f | 237 | if self.RESPONSE_FILES: |
screamer | 21:4fdf0dd04f6f | 238 | # Split link command to linker executable + response file |
screamer | 21:4fdf0dd04f6f | 239 | cmd_linker = cmd[0] |
screamer | 21:4fdf0dd04f6f | 240 | link_files = self.get_link_file(cmd[1:]) |
screamer | 21:4fdf0dd04f6f | 241 | cmd = [cmd_linker, "@%s" % link_files] |
screamer | 0:66f3b5499f7f | 242 | |
screamer | 0:66f3b5499f7f | 243 | # Exec command |
screamer | 21:4fdf0dd04f6f | 244 | self.cc_verbose("Link: %s" % ' '.join(cmd)) |
screamer | 21:4fdf0dd04f6f | 245 | self.default_cmd(cmd) |
screamer | 0:66f3b5499f7f | 246 | |
screamer | 0:66f3b5499f7f | 247 | @hook_tool |
screamer | 0:66f3b5499f7f | 248 | def archive(self, objects, lib_path): |
screamer | 21:4fdf0dd04f6f | 249 | if self.RESPONSE_FILES: |
screamer | 22:9e85236d8716 | 250 | param = ["@%s" % self.get_arch_file(objects)] |
screamer | 21:4fdf0dd04f6f | 251 | else: |
screamer | 21:4fdf0dd04f6f | 252 | param = objects |
screamer | 0:66f3b5499f7f | 253 | |
screamer | 0:66f3b5499f7f | 254 | # Exec command |
screamer | 21:4fdf0dd04f6f | 255 | self.default_cmd([self.ar, 'rcs', lib_path] + param) |
screamer | 0:66f3b5499f7f | 256 | |
screamer | 0:66f3b5499f7f | 257 | @hook_tool |
screamer | 0:66f3b5499f7f | 258 | def binary(self, resources, elf, bin): |
screamer | 0:66f3b5499f7f | 259 | # Build binary command |
screamer | 0:66f3b5499f7f | 260 | cmd = [self.elf2bin, "-O", "binary", elf, bin] |
screamer | 0:66f3b5499f7f | 261 | |
screamer | 0:66f3b5499f7f | 262 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 263 | cmd = self.hook.get_cmdline_binary(cmd) |
screamer | 0:66f3b5499f7f | 264 | |
screamer | 0:66f3b5499f7f | 265 | # Exec command |
screamer | 21:4fdf0dd04f6f | 266 | self.cc_verbose("FromELF: %s" % ' '.join(cmd)) |
screamer | 0:66f3b5499f7f | 267 | self.default_cmd(cmd) |
screamer | 0:66f3b5499f7f | 268 | |
screamer | 0:66f3b5499f7f | 269 | |
screamer | 0:66f3b5499f7f | 270 | class GCC_ARM(GCC): |
screamer | 13:ab47a20b66f0 | 271 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
screamer | 20:835f6355470d | 272 | GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 273 | |
screamer | 0:66f3b5499f7f | 274 | # Use latest gcc nanolib |
screamer | 13:ab47a20b66f0 | 275 | if "big-build" in self.options: |
screamer | 13:ab47a20b66f0 | 276 | use_nano = False |
screamer | 13:ab47a20b66f0 | 277 | elif "small-build" in self.options: |
screamer | 13:ab47a20b66f0 | 278 | use_nano = True |
screamer | 13:ab47a20b66f0 | 279 | elif target.default_build == "standard": |
screamer | 13:ab47a20b66f0 | 280 | use_nano = False |
screamer | 13:ab47a20b66f0 | 281 | elif target.default_build == "small": |
screamer | 13:ab47a20b66f0 | 282 | use_nano = True |
screamer | 13:ab47a20b66f0 | 283 | else: |
screamer | 13:ab47a20b66f0 | 284 | use_nano = False |
screamer | 13:ab47a20b66f0 | 285 | |
screamer | 13:ab47a20b66f0 | 286 | if use_nano: |
screamer | 13:ab47a20b66f0 | 287 | self.ld.append("--specs=nano.specs") |
screamer | 13:ab47a20b66f0 | 288 | self.flags['ld'].append("--specs=nano.specs") |
screamer | 13:ab47a20b66f0 | 289 | self.cc += ["-DMBED_RTOS_SINGLE_THREAD"] |
screamer | 13:ab47a20b66f0 | 290 | self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"] |
screamer | 13:ab47a20b66f0 | 291 | self.macros.extend(["MBED_RTOS_SINGLE_THREAD"]) |
screamer | 0:66f3b5499f7f | 292 | self.sys_libs.append("nosys") |
screamer | 0:66f3b5499f7f | 293 | |
screamer | 0:66f3b5499f7f | 294 | |
screamer | 0:66f3b5499f7f | 295 | class GCC_CR(GCC): |
screamer | 13:ab47a20b66f0 | 296 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
screamer | 20:835f6355470d | 297 | GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 298 | |
screamer | 0:66f3b5499f7f | 299 | additional_compiler_flags = [ |
screamer | 0:66f3b5499f7f | 300 | "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP", |
screamer | 0:66f3b5499f7f | 301 | ] |
screamer | 0:66f3b5499f7f | 302 | self.cc += additional_compiler_flags |
screamer | 0:66f3b5499f7f | 303 | self.cppc += additional_compiler_flags |
screamer | 0:66f3b5499f7f | 304 | |
screamer | 0:66f3b5499f7f | 305 | # Use latest gcc nanolib |
screamer | 0:66f3b5499f7f | 306 | self.ld.append("--specs=nano.specs") |
screamer | 0:66f3b5499f7f | 307 | if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: |
screamer | 0:66f3b5499f7f | 308 | self.ld.extend(["-u _printf_float", "-u _scanf_float"]) |
screamer | 0:66f3b5499f7f | 309 | self.ld += ["-nostdlib"] |