Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: toolchains/gcc.py
- Revision:
- 31:8ea194f6145b
- Parent:
- 30:f12ce67666d0
- Child:
- 35:da9c89f8be7d
--- a/toolchains/gcc.py Mon Aug 29 11:56:59 2016 +0100
+++ b/toolchains/gcc.py Wed Jan 04 11:58:24 2017 -0600
@@ -15,7 +15,7 @@
limitations under the License.
"""
import re
-from os.path import join, basename, splitext, dirname, exists
+from os.path import join, basename, splitext
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool
@@ -28,22 +28,23 @@
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')
INDEX_PATTERN = re.compile('(?P<col>\s*)\^')
- DEFAULT_FLAGS = {
- 'common': ["-c", "-Wall", "-Wextra",
- "-Wno-unused-parameter", "-Wno-missing-field-initializers",
- "-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
- "-ffunction-sections", "-fdata-sections", "-funsigned-char",
- "-MMD", "-fno-delete-null-pointer-checks", "-fomit-frame-pointer"
- ],
- 'asm': ["-x", "assembler-with-cpp"],
- 'c': ["-std=gnu99"],
- 'cxx': ["-std=gnu++98", "-fno-rtti", "-Wvla"],
- 'ld': ["-Wl,--gc-sections", "-Wl,--wrap,main",
- "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r"],
- }
+ def __init__(self, target, notify=None, macros=None,
+ silent=False, tool_path="", extra_verbose=False,
+ build_profile=None):
+ mbedToolchain.__init__(self, target, notify, macros, silent,
+ extra_verbose=extra_verbose,
+ build_profile=build_profile)
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
- mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
+ # Add flags for current size setting
+ default_lib = "std"
+ if hasattr(target, "default_lib"):
+ default_lib = target.default_lib
+ elif hasattr(target, "default_build"): # Legacy
+ default_lib = target.default_build
+
+ if default_lib == "small":
+ self.flags["common"].append("-DMBED_RTOS_SINGLE_THREAD")
+ self.flags["ld"].append("--specs=nano.specs")
if target.core == "Cortex-M0+":
cpu = "cortex-m0plus"
@@ -71,8 +72,6 @@
self.cpu.append("-mfpu=fpv5-d16")
self.cpu.append("-mfloat-abi=softfp")
-
-
if target.core == "Cortex-A9":
self.cpu.append("-mthumb-interwork")
self.cpu.append("-marm")
@@ -81,20 +80,8 @@
self.cpu.append("-mfloat-abi=hard")
self.cpu.append("-mno-unaligned-access")
-
- # Note: We are using "-O2" instead of "-Os" to avoid this known GCC bug:
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46762
self.flags["common"] += self.cpu
- if "save-asm" in self.options:
- self.flags["common"].append("-save-temps")
-
- if "debug-info" in self.options:
- self.flags["common"].append("-g")
- self.flags["common"].append("-O0")
- else:
- self.flags["common"].append("-Os")
-
main_cc = join(tool_path, "arm-none-eabi-gcc")
main_cppc = join(tool_path, "arm-none-eabi-g++")
self.asm = [main_cc] + self.flags['asm'] + self.flags["common"]
@@ -138,10 +125,11 @@
# The warning/error notification is multiline
msg = None
for line in output.splitlines():
- match = GCC.DIAGNOSTIC_PATTERN.match(line)
+ match = GCC.DIAGNOSTIC_PATTERN.search(line)
if match is not None:
if msg is not None:
self.cc_info(msg)
+ msg = None
msg = {
'severity': match.group('severity').lower(),
'file': match.group('file'),
@@ -162,6 +150,9 @@
else:
msg['text'] += line+"\n"
+ if msg is not None:
+ self.cc_info(msg)
+
def get_dep_option(self, object):
base, _ = splitext(object)
dep_path = base + '.d'
@@ -269,33 +260,35 @@
class GCC_ARM(GCC):
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
- GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose)
+ @staticmethod
+ def check_executable():
+ """Returns True if the executable (arm-none-eabi-gcc) location
+ specified by the user exists OR the executable can be found on the PATH.
+ Returns False otherwise."""
+ return mbedToolchain.generic_check_executable("GCC_ARM", 'arm-none-eabi-gcc', 1)
- # Use latest gcc nanolib
- if "big-build" in self.options:
- use_nano = False
- elif "small-build" in self.options:
- use_nano = True
- elif target.default_build == "standard":
- use_nano = False
- elif target.default_build == "small":
- use_nano = True
- else:
- use_nano = False
+ def __init__(self, target, notify=None, macros=None,
+ silent=False, extra_verbose=False, build_profile=None):
+ GCC.__init__(self, target, notify, macros, silent,
+ TOOLCHAIN_PATHS['GCC_ARM'], extra_verbose=extra_verbose,
+ build_profile=build_profile)
- if use_nano:
- self.ld.append("--specs=nano.specs")
- self.flags['ld'].append("--specs=nano.specs")
- self.cc += ["-DMBED_RTOS_SINGLE_THREAD"]
- self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"]
- self.macros.extend(["MBED_RTOS_SINGLE_THREAD"])
self.sys_libs.append("nosys")
class GCC_CR(GCC):
- def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
- GCC.__init__(self, target, options, notify, macros, silent, TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose)
+ @staticmethod
+ def check_executable():
+ """Returns True if the executable (arm-none-eabi-gcc) location
+ specified by the user exists OR the executable can be found on the PATH.
+ Returns False otherwise."""
+ return mbedToolchain.generic_check_executable("GCC_CR", 'arm-none-eabi-gcc', 1)
+
+ def __init__(self, target, notify=None, macros=None,
+ silent=False, extra_verbose=False, build_profile=None):
+ GCC.__init__(self, target, notify, macros, silent,
+ TOOLCHAIN_PATHS['GCC_CR'], extra_verbose=extra_verbose,
+ build_profile=build_profile)
additional_compiler_flags = [
"-D__NEWLIB__", "-D__CODE_RED", "-D__USE_CMSIS", "-DCPP_USE_HEAP",
