First cut of ARMCC support for MESON.

Change-Id: I15d8258e84d392baaccb8f670e33eefcfe8cd49a
pull/3186/head
Bedarkar, Malhar 7 years ago
parent 7842bc03dd
commit a2ee76228e
  1. 8
      mesonbuild/backend/ninjabackend.py
  2. 5
      mesonbuild/build.py
  3. 3
      mesonbuild/compilers/__init__.py
  4. 57
      mesonbuild/compilers/c.py
  5. 51
      mesonbuild/compilers/compilers.py
  6. 13
      mesonbuild/environment.py
  7. 13
      mesonbuild/linkers.py
  8. 8
      mesonbuild/wrap/wrap.py

@ -1485,7 +1485,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
@ -1540,7 +1540,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
@ -1669,7 +1669,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 = {cross_args} $ARGS {output_args} {compile_only_args} $in\n'
@ -1730,7 +1730,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 = {cross_args} $ARGS {dep_args} {output_args} {compile_only_args} $in

@ -1178,7 +1178,10 @@ 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'):
self.suffix = 'axf'
else:
self.suffix = ''
self.filename = self.name
if self.suffix:
self.filename += '.' + self.suffix

@ -41,6 +41,8 @@ __all__ = [
'sanitizer_compile_args',
'sort_clike',
'ARMCompiler',
'ARMCCompiler',
'CCompiler',
'ClangCCompiler',
'ClangCompiler',
@ -115,6 +117,7 @@ from .compilers import (
IntelCompiler,
)
from .c import (
ARMCCompiler,
CCompiler,
ClangCCompiler,
GnuCCompiler,

@ -31,6 +31,7 @@ from .compilers import (
msvc_winlibs,
vs32_instruction_set_args,
vs64_instruction_set_args,
ARMCompiler,
ClangCompiler,
Compiler,
CompilerArgs,
@ -888,6 +889,62 @@ class GnuCCompiler(GnuCompiler, CCompiler):
return ['-fpch-preprocess', '-include', os.path.basename(header)]
class ARMCCompiler(ARMCompiler, CCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, defines=None, **kwargs):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
ARMCompiler.__init__(self, defines)
def sanity_check_impl(self, work_dir, environment, sname, code):
mlog.debug('Sanity testing disabled for armcc compiler')
return
def get_options(self):
opts = {'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
['none', 'c89', 'c99', 'c11'],
'none')}
return opts
def get_warn_args(self, level):
# ARMCC doesn't have warning levels
return []
def get_coverage_args(self):
return []
def get_coverage_link_args(self):
return []
# Override CCompiler.get_always_args
def get_always_args(self):
return []
def get_option_compile_args(self, options):
return []
def get_linker_exelist(self):
args = ['armlink']
return args
# 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_compile_only_args(self):
return ['-c']
class IntelCCompiler(IntelCompiler, CCompiler):
def __init__(self, exelist, version, icc_type, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)

@ -112,6 +112,12 @@ gnulike_buildtype_args = {'plain': [],
'debugoptimized': ['-O2', '-g'],
'release': ['-O3'],
'minsize': ['-Os', '-g']}
arm_buildtype_args = {'plain': [],
'debug': ['-O0', '-g'],
'debugoptimized': ['-O2', '-g'],
'release': ['-O2'],
'minsize': ['-Os', '-g'],
}
msvc_buildtype_args = {'plain': [],
'debug': ["/MDd", "/ZI", "/Ob0", "/Od", "/RTC1"],
@ -133,6 +139,12 @@ gnulike_buildtype_linker_args = {'plain': [],
'release': ['-Wl,-O1'],
'minsize': [],
}
arm_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
}
msvc_buildtype_linker_args = {'plain': [],
'debug': [],
@ -657,6 +669,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 []
@ -1075,6 +1093,39 @@ class GnuCompiler:
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, defines):
self.id = 'arm'
self.defines = defines or {}
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
'b_colorout', 'b_ndebug', 'b_staticpic']
# 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]
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 split_shlib_to_parts(self, fname):
return os.path.split(fname)[0], fname
class ClangCompiler:
def __init__(self, clang_type):

@ -38,6 +38,7 @@ from .compilers import (
is_source,
)
from .compilers import (
ARMCCompiler,
ClangCCompiler,
ClangCPPCompiler,
ClangObjCCompiler,
@ -492,7 +493,10 @@ class Environment:
continue
arg = '/?'
else:
arg = '--version'
if re.search('.*arm.*', compiler[0]):
arg = '--vsn'
else:
arg = '--version'
try:
p, out, err = Popen_safe(compiler + [arg])
except OSError as e:
@ -537,6 +541,8 @@ 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:
return ARMCCompiler(ccache + compiler, version, is_cross, exe_wrap, full_version=full_version)
self._handle_exceptions(popen_exceptions, compilers)
def detect_c_compiler(self, want_cross):
@ -791,7 +797,10 @@ class Environment:
if 'lib' in linker or 'lib.exe' in linker:
arg = '/?'
else:
arg = '--version'
if re.search('.*arm.*', linker[0]):
arg = '--vsn'
else:
arg = '--version'
try:
p, out, err = Popen_safe(linker + [arg])
except OSError as e:

@ -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 []

@ -203,15 +203,17 @@ class Resolver:
subprocess.call(['git', 'pull'], cwd=checkoutdir)
else:
if subprocess.call(['git', 'checkout', revno], cwd=checkoutdir) != 0:
subprocess.check_call(['git', 'fetch'], cwd=checkoutdir)
subprocess.check_call(['git', 'fetch', p.get('url'), revno], cwd=checkoutdir)
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
else:
subprocess.check_call(['git', 'clone', p.get('url'),
p.get('directory')], cwd=self.subdir_root)
if revno.lower() != 'head':
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
if subprocess.call(['git', 'checkout', revno], cwd=checkoutdir) != 0:
subprocess.check_call(['git', 'fetch', p.get('url'), revno], cwd=checkoutdir)
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
push_url = p.values.get('push-url')
if push_url:
subprocess.check_call(['git', 'remote', 'set-url',

Loading…
Cancel
Save