Merged Arm CC support.

pull/3246/head
Jussi Pakkanen 7 years ago
commit c58dd64f8e
  1. 20
      cross/armcc.txt
  2. 1
      docs/markdown/Reference-tables.md
  3. 15
      docs/markdown/snippets/armcc-cross.md
  4. 8
      mesonbuild/backend/ninjabackend.py
  5. 6
      mesonbuild/build.py
  6. 2
      mesonbuild/compilers/__init__.py
  7. 20
      mesonbuild/compilers/c.py
  8. 90
      mesonbuild/compilers/compilers.py
  9. 28
      mesonbuild/compilers/cpp.py
  10. 7
      mesonbuild/environment.py
  11. 13
      mesonbuild/linkers.py

@ -0,0 +1,20 @@
# This file assumes that path to the arm compiler toolchain is added
# to the environment(PATH) variable, so that Meson can find
# the armcc, armlink and armar while building.
[binaries]
c = 'armcc'
cpp = 'armcc'
ar = 'armar'
strip = 'armar'
[properties]
# The '--cpu' option with the appropriate target type should be mentioned
# to cross compile c/c++ code with armcc,.
c_args = ['--cpu=Cortex-M0plus']
cpp_args = ['--cpu=Cortex-M0plus']
[host_machine]
system = 'bare metal' # Update with your system name - bare metal/OS.
cpu_family = 'arm'
cpu = 'Cortex-M0+'
endian = 'little'

@ -22,6 +22,7 @@ These are return values of the `get_id` method in a compiler object.
| open64 | The Open64 Fortran Compiler |
| nagfor | The NAG Fortran compiler |
| lcc | Elbrus C/C++/Fortran Compiler |
| arm | ARM compiler |
## Script environment variables

@ -0,0 +1,15 @@
## ARM compiler for C and CPP
Cross-compilation is now supported for ARM targets using ARM compiler - ARMCC.
The current implementation does not support shareable libraries.
The default extension of the output is .axf.
The environment path should be set properly for the ARM compiler executables.
The '--cpu' option with the appropriate target type should be mentioned
in the cross file as shown in the snippet below.
```
[properties]
c_args = ['--cpu=Cortex-M0plus']
cpp_args = ['--cpu=Cortex-M0plus']
```

@ -1473,7 +1473,7 @@ int dummy;
# gcc-ar blindly pass the --plugin argument to `ar` and you cannot pass
# options as arguments while using the @file.rsp syntax.
# See: https://github.com/mesonbuild/meson/issues/1646
if mesonlib.is_windows() and not isinstance(static_linker, ArLinker):
if static_linker.can_linker_accept_rsp():
command_template = ''' command = {executable} @$out.rsp
rspfile = $out.rsp
rspfile_content = $LINK_ARGS {output_args} $in
@ -1528,7 +1528,7 @@ int dummy;
except KeyError:
pass
rule = 'rule %s%s_LINKER\n' % (langname, crstr)
if mesonlib.is_windows():
if compiler.can_linker_accept_rsp():
command_template = ''' command = {executable} @$out.rsp
rspfile = $out.rsp
rspfile_content = $ARGS {output_args} $in $LINK_ARGS {cross_args} $aliasing
@ -1657,7 +1657,7 @@ rule FORTRAN_DEP_HACK
if getattr(self, 'created_llvm_ir_rule', False):
return
rule = 'rule llvm_ir{}_COMPILER\n'.format('_CROSS' if is_cross else '')
if mesonlib.is_windows():
if compiler.can_linker_accept_rsp():
command_template = ' command = {executable} @$out.rsp\n' \
' rspfile = $out.rsp\n' \
' rspfile_content = $ARGS{cross_args} {output_args} {compile_only_args} $in\n'
@ -1718,7 +1718,7 @@ rule FORTRAN_DEP_HACK
d = quote_func(d)
quoted_depargs.append(d)
cross_args = self.get_cross_info_lang_args(langname, is_cross)
if mesonlib.is_windows():
if compiler.can_linker_accept_rsp():
command_template = ''' command = {executable} @$out.rsp
rspfile = $out.rsp
rspfile_content = $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in

@ -1209,7 +1209,11 @@ class Executable(BuildTarget):
for_cygwin(is_cross, environment) or 'cs' in self.compilers):
self.suffix = 'exe'
else:
self.suffix = ''
if ('c' in self.compilers and self.compilers['c'].get_id().startswith('arm') or
'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('arm')):
self.suffix = 'axf'
else:
self.suffix = ''
self.filename = self.name
if self.suffix:
self.filename += '.' + self.suffix

@ -118,6 +118,7 @@ from .compilers import (
IntelCompiler,
)
from .c import (
ArmCCompiler,
CCompiler,
ClangCCompiler,
GnuCCompiler,
@ -126,6 +127,7 @@ from .c import (
VisualStudioCCompiler,
)
from .cpp import (
ArmCPPCompiler,
CPPCompiler,
ClangCPPCompiler,
GnuCPPCompiler,

@ -31,6 +31,7 @@ from .compilers import (
msvc_winlibs,
vs32_instruction_set_args,
vs64_instruction_set_args,
ArmCompiler,
ClangCompiler,
Compiler,
CompilerArgs,
@ -1221,3 +1222,22 @@ class VisualStudioCCompiler(CCompiler):
if 'INCLUDE' not in os.environ:
return []
return os.environ['INCLUDE'].split(os.pathsep)
class ArmCCompiler(ArmCompiler, CCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ArmCompiler.__init__(self)
def get_options(self):
opts = {'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
['none', 'c90', 'c99'],
'none')}
return opts
def get_option_compile_args(self, options):
args = []
std = options['c_std']
if std.value != 'none':
args.append('--' + std.value)
return args

@ -116,6 +116,13 @@ gnulike_buildtype_args = {'plain': [],
'release': ['-O3'],
'minsize': ['-Os', '-g']}
arm_buildtype_args = {'plain': [],
'debug': ['-O0', '--debug'],
'debugoptimized': ['-O1', '--debug'],
'release': ['-O3', '-Otime'],
'minsize': ['-O3', '-Ospace'],
}
msvc_buildtype_args = {'plain': [],
'debug': ["/MDd", "/ZI", "/Ob0", "/Od", "/RTC1"],
'debugoptimized': ["/MD", "/Zi", "/O2", "/Ob1"],
@ -137,6 +144,13 @@ gnulike_buildtype_linker_args = {'plain': [],
'minsize': [],
}
arm_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
}
msvc_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
@ -671,6 +685,12 @@ class Compiler:
def get_always_args(self):
return []
def can_linker_accept_rsp(self):
"""
Determines whether the linker can accept arguments using the @rsp syntax.
"""
return mesonlib.is_windows()
def get_linker_always_args(self):
return []
@ -1311,3 +1331,73 @@ class IntelCompiler:
def get_default_include_dirs(self):
return gnulike_default_include_dirs(self.exelist, self.language)
class ArmCompiler:
# Functionality that is common to all ARM family compilers.
def __init__(self):
if not self.is_cross:
raise EnvironmentException('armcc supports only cross-compilation.')
self.id = 'arm'
default_warn_args = []
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + [],
'3': default_warn_args + []}
# Assembly
self.can_compile_suffixes.add('s')
def can_linker_accept_rsp(self):
return False
def get_pic_args(self):
# FIXME: Add /ropi, /rwpi, /fpic etc. qualifiers to --apcs
return []
def get_buildtype_args(self, buildtype):
return arm_buildtype_args[buildtype]
def get_buildtype_linker_args(self, buildtype):
return arm_buildtype_linker_args[buildtype]
# Override CCompiler.get_always_args
def get_always_args(self):
return []
# Override CCompiler.get_dependency_gen_args
def get_dependency_gen_args(self, outtarget, outfile):
return []
# Override CCompiler.get_std_shared_lib_link_args
def get_std_shared_lib_link_args(self):
return []
def get_pch_use_args(self, pch_dir, header):
# FIXME: Add required arguments
# NOTE from armcc user guide:
# "Support for Precompiled Header (PCH) files is deprecated from ARM Compiler 5.05
# onwards on all platforms. Note that ARM Compiler on Windows 8 never supported
# PCH files."
return []
def get_pch_suffix(self):
# NOTE from armcc user guide:
# "Support for Precompiled Header (PCH) files is deprecated from ARM Compiler 5.05
# onwards on all platforms. Note that ARM Compiler on Windows 8 never supported
# PCH files."
return 'pch'
def thread_flags(self, env):
return []
def thread_link_flags(self, env):
return []
def get_linker_exelist(self):
args = ['armlink']
return args
def get_coverage_args(self):
return []
def get_coverage_link_args(self):
return []

@ -27,6 +27,7 @@ from .compilers import (
GnuCompiler,
ElbrusCompiler,
IntelCompiler,
ArmCompiler,
)
class CPPCompiler(CCompiler):
@ -239,3 +240,30 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
# Visual Studio C++ compiler doesn't support -fpermissive,
# so just use the plain C args.
return super(VisualStudioCCompiler, self).get_compiler_check_args()
class ArmCPPCompiler(ArmCompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap=None, **kwargs):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)
ArmCompiler.__init__(self)
def get_options(self):
opts = {'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++03', 'c++11'],
'none')}
return opts
def get_option_compile_args(self, options):
args = []
std = options['cpp_std']
if std.value == 'c++11':
args.append('--cpp11')
elif std.value == 'c++03':
args.append('--cpp')
return args
def get_option_link_args(self, options):
return []
def get_compiler_check_args(self):
return []

@ -38,6 +38,8 @@ from .compilers import (
is_source,
)
from .compilers import (
ArmCCompiler,
ArmCPPCompiler,
ClangCCompiler,
ClangCPPCompiler,
ClangObjCCompiler,
@ -519,6 +521,8 @@ class Environment:
if found_cl in watcom_cls:
continue
arg = '/?'
elif 'armcc' in compiler[0]:
arg = '--vsn'
else:
arg = '--version'
try:
@ -577,6 +581,9 @@ class Environment:
inteltype = ICC_STANDARD
cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler
return cls(ccache + compiler, version, inteltype, is_cross, exe_wrap, full_version=full_version)
if 'ARM' in out:
cls = ArmCCompiler if lang == 'c' else ArmCPPCompiler
return cls(ccache + compiler, version, is_cross, exe_wrap, full_version=full_version)
self._handle_exceptions(popen_exceptions, compilers)
def detect_c_compiler(self, want_cross):

@ -13,9 +13,14 @@
# limitations under the License.
from .mesonlib import Popen_safe
from . import mesonlib
class StaticLinker:
pass
def can_linker_accept_rsp(self):
"""
Determines whether the linker can accept arguments using the @rsp syntax.
"""
return mesonlib.is_windows()
class VisualStudioLinker(StaticLinker):
@ -75,6 +80,12 @@ class ArLinker(StaticLinker):
self.std_args = ['csrD']
else:
self.std_args = ['csr']
# For 'armar' the options should be prefixed with '-'.
if 'armar' in stdo:
self.std_args = ['-csr']
def can_linker_accept_rsp(self):
return False
def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
return []

Loading…
Cancel
Save