Skip to content

Parse Errors and Warnings from Arm Compiler 6 #10276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 59 additions & 13 deletions tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
from builtins import str # noqa: F401

import re
import os
from copy import copy
from os.path import join, dirname, splitext, basename, exists, isfile, split
from os.path import join, dirname, splitext, basename, exists, isfile
from os import makedirs, write, remove
from tempfile import mkstemp
from shutil import rmtree
from distutils.version import LooseVersion

from tools.targets import CORE_ARCH
from tools.toolchains.mbed_toolchain import mbedToolchain, TOOLCHAIN_PATHS
from tools.utils import mkdir, NotSupportedException, ToolException, run_cmd
from tools.utils import mkdir, NotSupportedException, run_cmd

ARMC5_MIGRATION_WARNING = (
"Warning: We noticed that you are using Arm Compiler 5. "
Expand All @@ -38,6 +37,7 @@
"please visit https://os.mbed.com/docs/mbed-os/latest/tools/index.html"
)


class ARM(mbedToolchain):
LINKER_EXT = '.sct'
LIBRARY_EXT = '.ar'
Expand Down Expand Up @@ -184,7 +184,7 @@ def parse_dependencies(self, dep_path):
def parse_output(self, output):
msg = None
for line in output.splitlines():
match = ARM.DIAGNOSTIC_PATTERN.match(line)
match = self.DIAGNOSTIC_PATTERN.match(line)
if match is not None:
if msg is not None:
self.notify.cc_info(msg)
Expand Down Expand Up @@ -306,7 +306,14 @@ def correct_scatter_shebang(self, scatter_file, cur_dir_name=None):

return new_scatter

def get_link_command(self, output, objects, libraries, lib_dirs, scatter_file):
def get_link_command(
self,
output,
objects,
libraries,
lib_dirs,
scatter_file
):
base, _ = splitext(output)
map_file = base + ".map"
args = ["-o", output, "--info=totals", "--map", "--list=%s" % map_file]
Expand Down Expand Up @@ -378,6 +385,7 @@ def redirect_symbol(source, sync, build_dir):
write(handle, "RESOLVE %s AS %s\n" % (source, sync))
return "--edit=%s" % filename


class ARM_STD(ARM):

OFFICIALLY_SUPPORTED = True
Expand All @@ -399,9 +407,11 @@ def __init__(
build_profile=build_profile
)
if int(target.build_tools_metadata["version"]) > 0:
#check only for ARMC5 because ARM_STD means using ARMC5, and thus
# check only for ARMC5 because ARM_STD means using ARMC5, and thus
# supported_toolchains must include ARMC5
if not set(target.supported_toolchains).intersection(set(("ARMC5", "ARM"))):
if not set(target.supported_toolchains).intersection(
set(("ARMC5", "ARM"))
):
raise NotSupportedException(
"ARM compiler 5 support is required for ARM build"
)
Expand All @@ -413,6 +423,7 @@ def __init__(
"ARM/uARM compiler support is required for ARM build"
)


class ARM_MICRO(ARM):

PATCHED_LIBRARY = False
Expand All @@ -434,7 +445,7 @@ def __init__(
# At this point we already know that we want to use ARMC5+Microlib
# so check for if they are supported For, AC6+Microlib we still
# use ARMC6 class
if not set(("ARMC5","uARM")).issubset(set(
if not set(("ARMC5", "uARM")).issubset(set(
target.supported_toolchains
)):
raise NotSupportedException(
Expand Down Expand Up @@ -469,6 +480,10 @@ class ARMC6(ARM_STD):
"Cortex-A9"
]
ARMCC_RANGE = (LooseVersion("6.10"), LooseVersion("7.0"))
LD_DIAGNOSTIC_PATTERN = re.compile(
'(?P<severity>Warning|Error): (?P<message>.+)'
)
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')

@staticmethod
def check_executable():
Expand Down Expand Up @@ -586,9 +601,9 @@ def __init__(self, target, *args, **kwargs):
self.ar = join(TOOLCHAIN_PATHS["ARMC6"], "armar")
self.elf2bin = join(TOOLCHAIN_PATHS["ARMC6"], "fromelf")

# Adding this for safety since this inherits the `version_check` function
# but does not call the constructor of ARM_STD, so the `product_name` variable
# is not initialized.
# Adding this for safety since this inherits the `version_check`
# function but does not call the constructor of ARM_STD, so the
# `product_name` variable is not initialized.
self.product_name = None

def _get_toolchain_labels(self):
Expand All @@ -608,7 +623,31 @@ def is_not_supported_error(self, output):
return "#error [NOT_SUPPORTED]" in output

def parse_output(self, output):
pass
for line in output.splitlines():
match = self.LD_DIAGNOSTIC_PATTERN.match(line)
if match is not None:
self.notify.cc_info({
'severity': match.group('severity').lower(),
'message': match.group('message'),
'text': '',
'target_name': self.target.name,
'toolchain_name': self.name,
'col': 0,
'file': "",
'line': 0
})
match = self.DIAGNOSTIC_PATTERN.search(line)
if match is not None:
self.notify.cc_info({
'severity': match.group('severity').lower(),
'file': match.group('file'),
'line': match.group('line'),
'col': match.group('col'),
'message': match.group('message'),
'text': '',
'target_name': self.target.name,
'toolchain_name': self.name
})

def get_config_option(self, config_header):
return ["-include", config_header]
Expand Down Expand Up @@ -660,7 +699,14 @@ def compile(self, cc, source, object, includes):
cmd.extend(["-o", object, source])
return [cmd]

def get_link_command(self, output, objects, libraries, lib_dirs, scatter_file):
def get_link_command(
self,
output,
objects,
libraries,
lib_dirs,
scatter_file
):
cmd = ARM.get_link_command(
self, output, objects, libraries, lib_dirs, scatter_file
)
Expand Down
1 change: 1 addition & 0 deletions tools/toolchains/mbed_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def default_cmd(self, command):
)
self.notify.debug("Return: %s" % rc)

self.parse_output(stderr)
for output_line in stdout.splitlines():
self.notify.debug("Output: %s" % output_line)
for error_line in stderr.splitlines():
Expand Down