Clone of official tools
toolchains/gcc.py@0:66f3b5499f7f, 2016-05-19 (annotated)
- Committer:
- screamer
- Date:
- Thu May 19 19:44:41 2016 +0100
- Revision:
- 0:66f3b5499f7f
- Child:
- 2:07730b0f452c
Initial revision
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 | 0:66f3b5499f7f | 20 | from tools.toolchains import mbedToolchain |
screamer | 0:66f3b5499f7f | 21 | from tools.settings import GCC_ARM_PATH, GCC_CR_PATH |
screamer | 0:66f3b5499f7f | 22 | from tools.settings import GOANNA_PATH |
screamer | 0:66f3b5499f7f | 23 | from tools.hooks import hook_tool |
screamer | 0:66f3b5499f7f | 24 | |
screamer | 0:66f3b5499f7f | 25 | class GCC(mbedToolchain): |
screamer | 0:66f3b5499f7f | 26 | LINKER_EXT = '.ld' |
screamer | 0:66f3b5499f7f | 27 | LIBRARY_EXT = '.a' |
screamer | 0:66f3b5499f7f | 28 | |
screamer | 0:66f3b5499f7f | 29 | STD_LIB_NAME = "lib%s.a" |
screamer | 0:66f3b5499f7f | 30 | CIRCULAR_DEPENDENCIES = True |
screamer | 0:66f3b5499f7f | 31 | DIAGNOSTIC_PATTERN = re.compile('((?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)') |
screamer | 0:66f3b5499f7f | 32 | |
screamer | 0:66f3b5499f7f | 33 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False): |
screamer | 0:66f3b5499f7f | 34 | mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 35 | |
screamer | 0:66f3b5499f7f | 36 | if target.core == "Cortex-M0+": |
screamer | 0:66f3b5499f7f | 37 | cpu = "cortex-m0plus" |
screamer | 0:66f3b5499f7f | 38 | elif target.core == "Cortex-M4F": |
screamer | 0:66f3b5499f7f | 39 | cpu = "cortex-m4" |
screamer | 0:66f3b5499f7f | 40 | elif target.core == "Cortex-M7F": |
screamer | 0:66f3b5499f7f | 41 | cpu = "cortex-m7" |
screamer | 0:66f3b5499f7f | 42 | else: |
screamer | 0:66f3b5499f7f | 43 | cpu = target.core.lower() |
screamer | 0:66f3b5499f7f | 44 | |
screamer | 0:66f3b5499f7f | 45 | self.cpu = ["-mcpu=%s" % cpu] |
screamer | 0:66f3b5499f7f | 46 | if target.core.startswith("Cortex"): |
screamer | 0:66f3b5499f7f | 47 | self.cpu.append("-mthumb") |
screamer | 0:66f3b5499f7f | 48 | |
screamer | 0:66f3b5499f7f | 49 | if target.core == "Cortex-M4F": |
screamer | 0:66f3b5499f7f | 50 | self.cpu.append("-mfpu=fpv4-sp-d16") |
screamer | 0:66f3b5499f7f | 51 | self.cpu.append("-mfloat-abi=softfp") |
screamer | 0:66f3b5499f7f | 52 | elif target.core == "Cortex-M7F": |
screamer | 0:66f3b5499f7f | 53 | self.cpu.append("-mfpu=fpv5-d16") |
screamer | 0:66f3b5499f7f | 54 | self.cpu.append("-mfloat-abi=softfp") |
screamer | 0:66f3b5499f7f | 55 | |
screamer | 0:66f3b5499f7f | 56 | if target.core == "Cortex-A9": |
screamer | 0:66f3b5499f7f | 57 | self.cpu.append("-mthumb-interwork") |
screamer | 0:66f3b5499f7f | 58 | self.cpu.append("-marm") |
screamer | 0:66f3b5499f7f | 59 | self.cpu.append("-march=armv7-a") |
screamer | 0:66f3b5499f7f | 60 | self.cpu.append("-mfpu=vfpv3") |
screamer | 0:66f3b5499f7f | 61 | self.cpu.append("-mfloat-abi=hard") |
screamer | 0:66f3b5499f7f | 62 | self.cpu.append("-mno-unaligned-access") |
screamer | 0:66f3b5499f7f | 63 | |
screamer | 0:66f3b5499f7f | 64 | |
screamer | 0:66f3b5499f7f | 65 | # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug: |
screamer | 0:66f3b5499f7f | 66 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762 |
screamer | 0:66f3b5499f7f | 67 | common_flags = ["-c", "-Wall", "-Wextra", |
screamer | 0:66f3b5499f7f | 68 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", |
screamer | 0:66f3b5499f7f | 69 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", |
screamer | 0:66f3b5499f7f | 70 | "-ffunction-sections", "-fdata-sections", |
screamer | 0:66f3b5499f7f | 71 | "-fno-delete-null-pointer-checks", "-fomit-frame-pointer" |
screamer | 0:66f3b5499f7f | 72 | ] + self.cpu |
screamer | 0:66f3b5499f7f | 73 | |
screamer | 0:66f3b5499f7f | 74 | if "save-asm" in self.options: |
screamer | 0:66f3b5499f7f | 75 | common_flags.append("-save-temps") |
screamer | 0:66f3b5499f7f | 76 | |
screamer | 0:66f3b5499f7f | 77 | if "debug-info" in self.options: |
screamer | 0:66f3b5499f7f | 78 | common_flags.append("-O0") |
screamer | 0:66f3b5499f7f | 79 | else: |
screamer | 0:66f3b5499f7f | 80 | common_flags.append("-O2") |
screamer | 0:66f3b5499f7f | 81 | # add debug symbols for all builds |
screamer | 0:66f3b5499f7f | 82 | common_flags.append("-g") |
screamer | 0:66f3b5499f7f | 83 | |
screamer | 0:66f3b5499f7f | 84 | main_cc = join(tool_path, "arm-none-eabi-gcc") |
screamer | 0:66f3b5499f7f | 85 | main_cppc = join(tool_path, "arm-none-eabi-g++") |
screamer | 0:66f3b5499f7f | 86 | self.asm = [main_cc, "-x", "assembler-with-cpp"] + common_flags |
screamer | 0:66f3b5499f7f | 87 | if not "analyze" in self.options: |
screamer | 0:66f3b5499f7f | 88 | self.cc = [main_cc, "-std=gnu99"] + common_flags |
screamer | 0:66f3b5499f7f | 89 | self.cppc =[main_cppc, "-std=gnu++98", "-fno-rtti"] + common_flags |
screamer | 0:66f3b5499f7f | 90 | else: |
screamer | 0:66f3b5499f7f | 91 | self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags |
screamer | 0:66f3b5499f7f | 92 | self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "-fno-rtti", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags |
screamer | 0:66f3b5499f7f | 93 | |
screamer | 0:66f3b5499f7f | 94 | self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu |
screamer | 0:66f3b5499f7f | 95 | self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] |
screamer | 0:66f3b5499f7f | 96 | |
screamer | 0:66f3b5499f7f | 97 | self.ar = join(tool_path, "arm-none-eabi-ar") |
screamer | 0:66f3b5499f7f | 98 | self.elf2bin = join(tool_path, "arm-none-eabi-objcopy") |
screamer | 0:66f3b5499f7f | 99 | |
screamer | 0:66f3b5499f7f | 100 | def parse_dependencies(self, dep_path): |
screamer | 0:66f3b5499f7f | 101 | dependencies = [] |
screamer | 0:66f3b5499f7f | 102 | buff = open(dep_path).readlines() |
screamer | 0:66f3b5499f7f | 103 | buff[0] = re.sub('^(.*?)\: ', '', buff[0]) |
screamer | 0:66f3b5499f7f | 104 | for line in buff: |
screamer | 0:66f3b5499f7f | 105 | file = line.replace('\\\n', '').strip() |
screamer | 0:66f3b5499f7f | 106 | if file: |
screamer | 0:66f3b5499f7f | 107 | # GCC might list more than one dependency on a single line, in this case |
screamer | 0:66f3b5499f7f | 108 | # the dependencies are separated by a space. However, a space might also |
screamer | 0:66f3b5499f7f | 109 | # indicate an actual space character in a dependency path, but in this case |
screamer | 0:66f3b5499f7f | 110 | # the space character is prefixed by a backslash. |
screamer | 0:66f3b5499f7f | 111 | # Temporary replace all '\ ' with a special char that is not used (\a in this |
screamer | 0:66f3b5499f7f | 112 | # case) to keep them from being interpreted by 'split' (they will be converted |
screamer | 0:66f3b5499f7f | 113 | # back later to a space char) |
screamer | 0:66f3b5499f7f | 114 | file = file.replace('\\ ', '\a') |
screamer | 0:66f3b5499f7f | 115 | if file.find(" ") == -1: |
screamer | 0:66f3b5499f7f | 116 | dependencies.append(file.replace('\a', ' ')) |
screamer | 0:66f3b5499f7f | 117 | else: |
screamer | 0:66f3b5499f7f | 118 | dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")] |
screamer | 0:66f3b5499f7f | 119 | return dependencies |
screamer | 0:66f3b5499f7f | 120 | |
screamer | 0:66f3b5499f7f | 121 | def is_not_supported_error(self, output): |
screamer | 0:66f3b5499f7f | 122 | return "error: #error [NOT_SUPPORTED]" in output |
screamer | 0:66f3b5499f7f | 123 | |
screamer | 0:66f3b5499f7f | 124 | def parse_output(self, output): |
screamer | 0:66f3b5499f7f | 125 | # The warning/error notification is multiline |
screamer | 0:66f3b5499f7f | 126 | WHERE, WHAT = 0, 1 |
screamer | 0:66f3b5499f7f | 127 | state, file, message = WHERE, None, None |
screamer | 0:66f3b5499f7f | 128 | for line in output.splitlines(): |
screamer | 0:66f3b5499f7f | 129 | match = self.goanna_parse_line(line) |
screamer | 0:66f3b5499f7f | 130 | if match is not None: |
screamer | 0:66f3b5499f7f | 131 | self.cc_info( |
screamer | 0:66f3b5499f7f | 132 | match.group('severity').lower(), |
screamer | 0:66f3b5499f7f | 133 | match.group('file'), |
screamer | 0:66f3b5499f7f | 134 | match.group('line'), |
screamer | 0:66f3b5499f7f | 135 | match.group('message'), |
screamer | 0:66f3b5499f7f | 136 | target_name=self.target.name, |
screamer | 0:66f3b5499f7f | 137 | toolchain_name=self.name |
screamer | 0:66f3b5499f7f | 138 | ) |
screamer | 0:66f3b5499f7f | 139 | continue |
screamer | 0:66f3b5499f7f | 140 | |
screamer | 0:66f3b5499f7f | 141 | # Each line should start with the file information: "filepath: ..." |
screamer | 0:66f3b5499f7f | 142 | # i should point past the file path ^ |
screamer | 0:66f3b5499f7f | 143 | # avoid the first column in Windows (C:\) |
screamer | 0:66f3b5499f7f | 144 | i = line.find(':', 2) |
screamer | 0:66f3b5499f7f | 145 | if i == -1: continue |
screamer | 0:66f3b5499f7f | 146 | |
screamer | 0:66f3b5499f7f | 147 | if state == WHERE: |
screamer | 0:66f3b5499f7f | 148 | file = line[:i] |
screamer | 0:66f3b5499f7f | 149 | message = line[i+1:].strip() + ' ' |
screamer | 0:66f3b5499f7f | 150 | state = WHAT |
screamer | 0:66f3b5499f7f | 151 | |
screamer | 0:66f3b5499f7f | 152 | elif state == WHAT: |
screamer | 0:66f3b5499f7f | 153 | match = GCC.DIAGNOSTIC_PATTERN.match(line[i+1:]) |
screamer | 0:66f3b5499f7f | 154 | if match is None: |
screamer | 0:66f3b5499f7f | 155 | state = WHERE |
screamer | 0:66f3b5499f7f | 156 | continue |
screamer | 0:66f3b5499f7f | 157 | |
screamer | 0:66f3b5499f7f | 158 | self.cc_info( |
screamer | 0:66f3b5499f7f | 159 | match.group('severity'), |
screamer | 0:66f3b5499f7f | 160 | file, match.group('line'), |
screamer | 0:66f3b5499f7f | 161 | message + match.group('message') |
screamer | 0:66f3b5499f7f | 162 | ) |
screamer | 0:66f3b5499f7f | 163 | |
screamer | 0:66f3b5499f7f | 164 | def get_dep_option(self, object): |
screamer | 0:66f3b5499f7f | 165 | base, _ = splitext(object) |
screamer | 0:66f3b5499f7f | 166 | dep_path = base + '.d' |
screamer | 0:66f3b5499f7f | 167 | return ["-MD", "-MF", dep_path] |
screamer | 0:66f3b5499f7f | 168 | |
screamer | 0:66f3b5499f7f | 169 | def get_compile_options(self, defines, includes): |
screamer | 0:66f3b5499f7f | 170 | return ['-D%s' % d for d in defines] + ['@%s' % self.get_inc_file(includes)] |
screamer | 0:66f3b5499f7f | 171 | |
screamer | 0:66f3b5499f7f | 172 | @hook_tool |
screamer | 0:66f3b5499f7f | 173 | def assemble(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 174 | # Build assemble command |
screamer | 0:66f3b5499f7f | 175 | cmd = self.asm + self.get_compile_options(self.get_symbols(), includes) + ["-o", object, source] |
screamer | 0:66f3b5499f7f | 176 | |
screamer | 0:66f3b5499f7f | 177 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 178 | cmd = self.hook.get_cmdline_assembler(cmd) |
screamer | 0:66f3b5499f7f | 179 | |
screamer | 0:66f3b5499f7f | 180 | # Return command array, don't execute |
screamer | 0:66f3b5499f7f | 181 | return [cmd] |
screamer | 0:66f3b5499f7f | 182 | |
screamer | 0:66f3b5499f7f | 183 | @hook_tool |
screamer | 0:66f3b5499f7f | 184 | def compile(self, cc, source, object, includes): |
screamer | 0:66f3b5499f7f | 185 | # Build compile command |
screamer | 0:66f3b5499f7f | 186 | cmd = cc + self.get_compile_options(self.get_symbols(), includes) |
screamer | 0:66f3b5499f7f | 187 | |
screamer | 0:66f3b5499f7f | 188 | cmd.extend(self.get_dep_option(object)) |
screamer | 0:66f3b5499f7f | 189 | |
screamer | 0:66f3b5499f7f | 190 | cmd.extend(["-o", object, source]) |
screamer | 0:66f3b5499f7f | 191 | |
screamer | 0:66f3b5499f7f | 192 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 193 | cmd = self.hook.get_cmdline_compiler(cmd) |
screamer | 0:66f3b5499f7f | 194 | |
screamer | 0:66f3b5499f7f | 195 | return [cmd] |
screamer | 0:66f3b5499f7f | 196 | |
screamer | 0:66f3b5499f7f | 197 | def compile_c(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 198 | return self.compile(self.cc, source, object, includes) |
screamer | 0:66f3b5499f7f | 199 | |
screamer | 0:66f3b5499f7f | 200 | def compile_cpp(self, source, object, includes): |
screamer | 0:66f3b5499f7f | 201 | return self.compile(self.cppc, source, object, includes) |
screamer | 0:66f3b5499f7f | 202 | |
screamer | 0:66f3b5499f7f | 203 | @hook_tool |
screamer | 0:66f3b5499f7f | 204 | def link(self, output, objects, libraries, lib_dirs, mem_map): |
screamer | 0:66f3b5499f7f | 205 | libs = [] |
screamer | 0:66f3b5499f7f | 206 | for l in libraries: |
screamer | 0:66f3b5499f7f | 207 | name, _ = splitext(basename(l)) |
screamer | 0:66f3b5499f7f | 208 | libs.append("-l%s" % name[3:]) |
screamer | 0:66f3b5499f7f | 209 | libs.extend(["-l%s" % l for l in self.sys_libs]) |
screamer | 0:66f3b5499f7f | 210 | |
screamer | 0:66f3b5499f7f | 211 | # NOTE: There is a circular dependency between the mbed library and the clib |
screamer | 0:66f3b5499f7f | 212 | # We could define a set of week symbols to satisfy the clib dependencies in "sys.o", |
screamer | 0:66f3b5499f7f | 213 | # but if an application uses only clib symbols and not mbed symbols, then the final |
screamer | 0:66f3b5499f7f | 214 | # image is not correctly retargeted |
screamer | 0:66f3b5499f7f | 215 | if self.CIRCULAR_DEPENDENCIES: |
screamer | 0:66f3b5499f7f | 216 | libs.extend(libs) |
screamer | 0:66f3b5499f7f | 217 | |
screamer | 0:66f3b5499f7f | 218 | # Build linker command |
screamer | 0:66f3b5499f7f | 219 | cmd = self.ld + ["-o", output] + objects |
screamer | 0:66f3b5499f7f | 220 | |
screamer | 0:66f3b5499f7f | 221 | if mem_map: |
screamer | 0:66f3b5499f7f | 222 | cmd.extend(['-T', mem_map]) |
screamer | 0:66f3b5499f7f | 223 | |
screamer | 0:66f3b5499f7f | 224 | for L in lib_dirs: |
screamer | 0:66f3b5499f7f | 225 | cmd.extend(['-L', L]) |
screamer | 0:66f3b5499f7f | 226 | cmd.extend(libs) |
screamer | 0:66f3b5499f7f | 227 | |
screamer | 0:66f3b5499f7f | 228 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 229 | cmd = self.hook.get_cmdline_linker(cmd) |
screamer | 0:66f3b5499f7f | 230 | |
screamer | 0:66f3b5499f7f | 231 | # Split link command to linker executable + response file |
screamer | 0:66f3b5499f7f | 232 | link_files = join(dirname(output), ".link_files.txt") |
screamer | 0:66f3b5499f7f | 233 | with open(link_files, "wb") as f: |
screamer | 0:66f3b5499f7f | 234 | cmd_linker = cmd[0] |
screamer | 0:66f3b5499f7f | 235 | cmd_list = [] |
screamer | 0:66f3b5499f7f | 236 | for c in cmd[1:]: |
screamer | 0:66f3b5499f7f | 237 | if c: |
screamer | 0:66f3b5499f7f | 238 | cmd_list.append(('"%s"' % c) if not c.startswith('-') else c) |
screamer | 0:66f3b5499f7f | 239 | string = " ".join(cmd_list).replace("\\", "/") |
screamer | 0:66f3b5499f7f | 240 | f.write(string) |
screamer | 0:66f3b5499f7f | 241 | |
screamer | 0:66f3b5499f7f | 242 | # Exec command |
screamer | 0:66f3b5499f7f | 243 | self.default_cmd([cmd_linker, "@%s" % link_files]) |
screamer | 0:66f3b5499f7f | 244 | |
screamer | 0:66f3b5499f7f | 245 | @hook_tool |
screamer | 0:66f3b5499f7f | 246 | def archive(self, objects, lib_path): |
screamer | 0:66f3b5499f7f | 247 | archive_files = join(dirname(lib_path), ".archive_files.txt") |
screamer | 0:66f3b5499f7f | 248 | with open(archive_files, "wb") as f: |
screamer | 0:66f3b5499f7f | 249 | o_list = [] |
screamer | 0:66f3b5499f7f | 250 | for o in objects: |
screamer | 0:66f3b5499f7f | 251 | o_list.append('"%s"' % o) |
screamer | 0:66f3b5499f7f | 252 | string = " ".join(o_list).replace("\\", "/") |
screamer | 0:66f3b5499f7f | 253 | f.write(string) |
screamer | 0:66f3b5499f7f | 254 | |
screamer | 0:66f3b5499f7f | 255 | # Exec command |
screamer | 0:66f3b5499f7f | 256 | self.default_cmd([self.ar, 'rcs', lib_path, "@%s" % archive_files]) |
screamer | 0:66f3b5499f7f | 257 | |
screamer | 0:66f3b5499f7f | 258 | @hook_tool |
screamer | 0:66f3b5499f7f | 259 | def binary(self, resources, elf, bin): |
screamer | 0:66f3b5499f7f | 260 | # Build binary command |
screamer | 0:66f3b5499f7f | 261 | cmd = [self.elf2bin, "-O", "binary", elf, bin] |
screamer | 0:66f3b5499f7f | 262 | |
screamer | 0:66f3b5499f7f | 263 | # Call cmdline hook |
screamer | 0:66f3b5499f7f | 264 | cmd = self.hook.get_cmdline_binary(cmd) |
screamer | 0:66f3b5499f7f | 265 | |
screamer | 0:66f3b5499f7f | 266 | # Exec command |
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 | 0:66f3b5499f7f | 271 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
screamer | 0:66f3b5499f7f | 272 | GCC.__init__(self, target, options, notify, macros, silent, GCC_ARM_PATH, extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 273 | |
screamer | 0:66f3b5499f7f | 274 | # Use latest gcc nanolib |
screamer | 0:66f3b5499f7f | 275 | self.ld.append("--specs=nano.specs") |
screamer | 0:66f3b5499f7f | 276 | if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: |
screamer | 0:66f3b5499f7f | 277 | self.ld.extend(["-u _printf_float", "-u _scanf_float"]) |
screamer | 0:66f3b5499f7f | 278 | elif target.name in ["RZ_A1H", "ARCH_MAX", "DISCO_F407VG", "DISCO_F429ZI", "DISCO_F469NI", "NUCLEO_F401RE", "NUCLEO_F410RB", "NUCLEO_F411RE", "NUCLEO_F446RE", "ELMO_F411RE", "MTS_MDOT_F411RE", "MTS_DRAGONFLY_F411RE", "DISCO_F746NG"]: |
screamer | 0:66f3b5499f7f | 279 | self.ld.extend(["-u_printf_float", "-u_scanf_float"]) |
screamer | 0:66f3b5499f7f | 280 | |
screamer | 0:66f3b5499f7f | 281 | self.sys_libs.append("nosys") |
screamer | 0:66f3b5499f7f | 282 | |
screamer | 0:66f3b5499f7f | 283 | |
screamer | 0:66f3b5499f7f | 284 | class GCC_CR(GCC): |
screamer | 0:66f3b5499f7f | 285 | def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False): |
screamer | 0:66f3b5499f7f | 286 | GCC.__init__(self, target, options, notify, macros, silent, GCC_CR_PATH, extra_verbose=extra_verbose) |
screamer | 0:66f3b5499f7f | 287 | |
screamer | 0:66f3b5499f7f | 288 | additional_compiler_flags = [ |
screamer | 0:66f3b5499f7f | 289 | "-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP", |
screamer | 0:66f3b5499f7f | 290 | ] |
screamer | 0:66f3b5499f7f | 291 | self.cc += additional_compiler_flags |
screamer | 0:66f3b5499f7f | 292 | self.cppc += additional_compiler_flags |
screamer | 0:66f3b5499f7f | 293 | |
screamer | 0:66f3b5499f7f | 294 | # Use latest gcc nanolib |
screamer | 0:66f3b5499f7f | 295 | self.ld.append("--specs=nano.specs") |
screamer | 0:66f3b5499f7f | 296 | if target.name in ["LPC1768", "LPC4088", "LPC4088_DM", "LPC4330", "UBLOX_C027", "LPC2368"]: |
screamer | 0:66f3b5499f7f | 297 | self.ld.extend(["-u _printf_float", "-u _scanf_float"]) |
screamer | 0:66f3b5499f7f | 298 | self.ld += ["-nostdlib"] |
screamer | 0:66f3b5499f7f | 299 |