From 7140afc0a86f2aae0689617fca985ef209a7c097 Mon Sep 17 00:00:00 2001 From: Vasu Penugonda <34339497+sompen@users.noreply.github.com> Date: Thu, 21 Jun 2018 03:25:39 +0530 Subject: Added ARMCLANG compiler support for C/C++ (#3717) --- mesonbuild/compilers/__init__.py | 6 ++- mesonbuild/compilers/c.py | 29 ++++++++++++++ mesonbuild/compilers/compilers.py | 80 +++++++++++++++++++++++++++++++++++++++ mesonbuild/compilers/cpp.py | 29 ++++++++++++++ 4 files changed, 142 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers') diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 217357b..9070a9f 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -126,8 +126,9 @@ from .compilers import ( IntelCompiler, ) from .c import ( - ArmCCompiler, CCompiler, + ArmCCompiler, + ArmclangCCompiler, ClangCCompiler, GnuCCompiler, ElbrusCCompiler, @@ -135,8 +136,9 @@ from .c import ( VisualStudioCCompiler, ) from .cpp import ( - ArmCPPCompiler, CPPCompiler, + ArmCPPCompiler, + ArmclangCPPCompiler, ClangCPPCompiler, GnuCPPCompiler, ElbrusCPPCompiler, diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index cd3aad1..b63dce4 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -32,6 +32,7 @@ from .compilers import ( vs32_instruction_set_args, vs64_instruction_set_args, ArmCompiler, + ArmclangCompiler, ClangCompiler, Compiler, CompilerArgs, @@ -979,6 +980,34 @@ class ClangCCompiler(ClangCompiler, CCompiler): return basic +class ArmclangCCompiler(ArmclangCompiler, CCompiler): + def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) + ArmclangCompiler.__init__(self) + default_warn_args = ['-Wall', '-Winvalid-pch'] + self.warn_args = {'1': default_warn_args, + '2': default_warn_args + ['-Wextra'], + '3': default_warn_args + ['-Wextra', '-Wpedantic']} + + def get_options(self): + opts = CCompiler.get_options(self) + opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use', + ['none', 'c90', 'c99', 'c11', + 'gnu90', 'gnu99', 'gnu11'], + 'none')}) + return opts + + def get_option_compile_args(self, options): + args = [] + std = options['c_std'] + if std.value != 'none': + args.append('-std=' + std.value) + return args + + def get_option_link_args(self, options): + return [] + + class GnuCCompiler(GnuCompiler, CCompiler): def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None, **kwargs): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 45caf55..21aab11 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -131,6 +131,12 @@ gnulike_buildtype_args = {'plain': [], 'release': ['-O3'], 'minsize': ['-Os', '-g']} +armclang_buildtype_args = {'plain': [], + 'debug': ['-O0', '-g'], + 'debugoptimized': ['-O1', '-g'], + 'release': ['-Os'], + 'minsize': ['-Oz']} + arm_buildtype_args = {'plain': [], 'debug': ['-O0', '--debug'], 'debugoptimized': ['-O1', '--debug'], @@ -1414,6 +1420,80 @@ class ClangCompiler: return [] +class ArmclangCompiler: + def __init__(self): + if not self.is_cross: + raise EnvironmentException('armclang supports only cross-compilation.') + # Check whether 'armlink.exe' is available in path + self.linker_exe = 'armlink.exe' + args = '--vsn' + try: + p, stdo, stderr = Popen_safe(self.linker_exe, args) + except OSError as e: + err_msg = 'Unknown linker\nRunning "{0}" gave \n"{1}"'.format(' '.join([self.linker_exe] + [args]), e) + raise EnvironmentException(err_msg) + # Verify the armlink version + ver_str = re.search('.*Component.*', stdo) + if ver_str: + ver_str = ver_str.group(0) + else: + EnvironmentException('armlink version string not found') + # Using the regular expression from environment.search_version, + # which is used for searching compiler version + version_regex = '(?