Merge pull request #4952 from mensinda/cacheCompiles

Cache compilers.compile() in coredata
pull/5339/head
Dylan Baker 6 years ago committed by GitHub
commit c0aa89e57f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 63
      mesonbuild/compilers/c.py
  2. 96
      mesonbuild/compilers/compilers.py
  3. 11
      mesonbuild/compilers/cpp.py
  4. 5
      mesonbuild/compilers/cuda.py
  5. 4
      mesonbuild/compilers/d.py
  6. 20
      mesonbuild/compilers/fortran.py
  7. 4
      mesonbuild/compilers/vala.py
  8. 1
      mesonbuild/coredata.py
  9. 2
      mesonbuild/dependencies/boost.py
  10. 4
      mesonbuild/dependencies/misc.py
  11. 2
      mesonbuild/dependencies/ui.py
  12. 105
      mesonbuild/interpreter.py
  13. 2
      mesonbuild/modules/unstable_simd.py

@ -368,7 +368,7 @@ class CCompiler(Compiler):
return self.compiles(code.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies)
def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None):
def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None, disable_cache=False):
fargs = {'prefix': prefix, 'header': hname}
code = '''{prefix}
#ifdef __has_include
@ -379,7 +379,7 @@ class CCompiler(Compiler):
#include <{header}>
#endif'''
return self.compiles(code.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies, mode='preprocess')
dependencies=dependencies, mode='preprocess', disable_cache=disable_cache)
def has_header_symbol(self, hname, symbol, prefix, env, *, extra_args=None, dependencies=None):
fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}
@ -444,17 +444,19 @@ class CCompiler(Compiler):
args += extra_args
return args
def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile'):
with self._build_wrapper(code, env, extra_args, dependencies, mode) as p:
return p.returncode == 0
def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile', disable_cache=False):
with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p:
return p.returncode == 0, p.cached
def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False):
def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False, disable_cache=False):
args = self._get_compiler_check_args(env, extra_args, dependencies, mode)
return self.compile(code, args, mode, want_output=want_output)
if disable_cache or want_output:
return self.compile(code, extra_args=args, mode=mode, want_output=want_output)
return self.cached_compile(code, env.coredata, extra_args=args, mode=mode)
def links(self, code, env, *, extra_args=None, dependencies=None):
def links(self, code, env, *, extra_args=None, dependencies=None, disable_cache=False):
return self.compiles(code, env, extra_args=extra_args,
dependencies=dependencies, mode='link')
dependencies=dependencies, mode='link', disable_cache=disable_cache)
def run(self, code: str, env, *, extra_args=None, dependencies=None):
if self.is_cross and self.exe_wrapper is None:
@ -487,7 +489,7 @@ class CCompiler(Compiler):
{prefix}
int main() {{ static int a[1-2*!({expression})]; a[0]=0; return 0; }}'''
return self.compiles(t.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies)
dependencies=dependencies)[0]
def cross_compute_int(self, expression, low, high, guess, prefix, env, extra_args, dependencies):
# Try user's guess first
@ -567,7 +569,7 @@ class CCompiler(Compiler):
{type} something;
}}'''
if not self.compiles(t.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies):
dependencies=dependencies)[0]:
return -1
return self.cross_compute_int('sizeof(%s)' % typename, None, None, None, prefix, env, extra_args, dependencies)
@ -602,7 +604,7 @@ class CCompiler(Compiler):
{type} something;
}}'''
if not self.compiles(t.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies):
dependencies=dependencies)[0]:
return -1
t = '''#include <stddef.h>
{prefix}
@ -641,7 +643,7 @@ class CCompiler(Compiler):
raise EnvironmentException('Could not determine alignment of %s. Sorry. You might want to file a bug.' % typename)
return align
def get_define(self, dname, prefix, env, extra_args, dependencies):
def get_define(self, dname, prefix, env, extra_args, dependencies, disable_cache=False):
delim = '"MESON_GET_DEFINE_DELIMITER"'
fargs = {'prefix': prefix, 'define': dname, 'delim': delim}
code = '''
@ -652,13 +654,17 @@ class CCompiler(Compiler):
{delim}\n{define}'''
args = self._get_compiler_check_args(env, extra_args, dependencies,
mode='preprocess').to_native()
with self.compile(code.format(**fargs), args, 'preprocess') as p:
func = lambda: self.cached_compile(code.format(**fargs), env.coredata, extra_args=args, mode='preprocess')
if disable_cache:
func = lambda: self.compile(code.format(**fargs), extra_args=args, mode='preprocess')
with func() as p:
cached = p.cached
if p.returncode != 0:
raise EnvironmentException('Could not get define {!r}'.format(dname))
# Get the preprocessed value after the delimiter,
# minus the extra newline at the end and
# merge string literals.
return CCompiler.concatenate_string_literals(p.stdo.split(delim + '\n')[-1][:-1])
return CCompiler.concatenate_string_literals(p.stdo.split(delim + '\n')[-1][:-1]), cached
def get_return_value(self, fname, rtype, prefix, env, extra_args, dependencies):
if rtype == 'string':
@ -762,7 +768,7 @@ class CCompiler(Compiler):
val = env.properties.host.get(varname, None)
if val is not None:
if isinstance(val, bool):
return val
return val, False
raise EnvironmentException('Cross variable {0} is not a boolean.'.format(varname))
fargs = {'prefix': prefix, 'func': funcname}
@ -792,13 +798,14 @@ class CCompiler(Compiler):
head, main = self._no_prototype_templ()
templ = head + stubs_fail + main
if self.links(templ.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies):
return True
res, cached = self.links(templ.format(**fargs), env, extra_args=extra_args,
dependencies=dependencies)
if res:
return True, cached
# MSVC does not have compiler __builtin_-s.
if self.get_id() == 'msvc':
return False
return False, False
# Detect function as a built-in
#
@ -1020,7 +1027,7 @@ class CCompiler(Compiler):
libname in self.internal_libs):
args = ['-l' + libname]
largs = self.linker_to_compiler_args(self.get_allow_undefined_link_args())
if self.links(code, env, extra_args=(args + largs)):
if self.links(code, env, extra_args=(args + largs), disable_cache=True)[0]:
return args
# Don't do a manual search for internal libs
if libname in self.internal_libs:
@ -1109,7 +1116,7 @@ class CCompiler(Compiler):
# then we must also pass -L/usr/lib to pick up libSystem.dylib
extra_args = [] if allow_system else ['-Z', '-L/usr/lib']
link_args += ['-framework', name]
if self.links(code, env, extra_args=(extra_args + link_args)):
if self.links(code, env, extra_args=(extra_args + link_args), disable_cache=True)[0]:
return link_args
def find_framework_impl(self, name, env, extra_dirs, allow_system):
@ -1176,7 +1183,7 @@ class CCompiler(Compiler):
fatal_warnings_args = ['-Wl,--fatal-warnings']
if self.has_fatal_warnings_link_arg is None:
self.has_fatal_warnings_link_arg = False
self.has_fatal_warnings_link_arg = self.has_multi_link_arguments(fatal_warnings_args, env)
self.has_fatal_warnings_link_arg = self.has_multi_link_arguments(fatal_warnings_args, env)[0]
if self.has_fatal_warnings_link_arg:
args = fatal_warnings_args + args
@ -1201,7 +1208,7 @@ class CCompiler(Compiler):
if not (for_windows(env.is_cross_build(), env) or
for_cygwin(env.is_cross_build(), env)):
if name in ['dllimport', 'dllexport']:
return False
return False, False
# Clang and GCC both return warnings if the __attribute__ is undefined,
# so set -Werror
@ -1348,7 +1355,7 @@ class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler):
# So we should explicitly fail at this case.
def has_function(self, funcname, prefix, env, *, extra_args=None, dependencies=None):
if funcname == 'lchmod':
return False
return False, False
else:
return super().has_function(funcname, prefix, env,
extra_args=extra_args,
@ -1609,8 +1616,8 @@ class VisualStudioCCompiler(CCompiler):
args = args + ['-Werror=unknown-argument']
with self._build_wrapper(code, env, extra_args=args, mode=mode) as p:
if p.returncode != 0:
return False
return not(warning_text in p.stde or warning_text in p.stdo)
return False, p.cached
return not(warning_text in p.stde or warning_text in p.stdo), p.cached
def get_compile_debugfile_args(self, rel_obj, pch=False):
pdbarr = rel_obj.split('.')[:-1]
@ -1706,7 +1713,7 @@ class VisualStudioCCompiler(CCompiler):
def has_func_attribute(self, name, env):
# MSVC doesn't have __attribute__ like Clang and GCC do, so just return
# false without compiling anything
return name in ['dllimport', 'dllexport']
return name in ['dllimport', 'dllexport'], False
def get_argument_syntax(self):
return 'msvc'

@ -875,8 +875,6 @@ class Compiler:
# Libraries that are internal compiler implementations, and must not be
# manually searched.
internal_libs = ()
# Cache for the result of compiler checks which can be cached
compiler_check_cache = {}
def __init__(self, exelist, version, **kwargs):
if isinstance(exelist, str):
@ -903,7 +901,7 @@ class Compiler:
return repr_str.format(self.__class__.__name__, self.version,
' '.join(self.exelist))
def can_compile(self, src):
def can_compile(self, src) -> bool:
if hasattr(src, 'fname'):
src = src.fname
suffix = os.path.splitext(src)[1].lower()
@ -911,40 +909,40 @@ class Compiler:
return True
return False
def get_id(self):
def get_id(self) -> str:
return self.id
def get_version_string(self):
def get_version_string(self) -> str:
details = [self.id, self.version]
if self.full_version:
details += ['"%s"' % (self.full_version)]
return '(%s)' % (' '.join(details))
def get_language(self):
def get_language(self) -> str:
return self.language
def get_display_language(self):
def get_display_language(self) -> str:
return self.language.capitalize()
def get_default_suffix(self):
def get_default_suffix(self) -> str:
return self.default_suffix
def get_define(self, dname, prefix, env, extra_args, dependencies):
def get_define(self, dname, prefix, env, extra_args, dependencies) -> Tuple[str, bool]:
raise EnvironmentException('%s does not support get_define ' % self.get_id())
def compute_int(self, expression, low, high, guess, prefix, env, extra_args, dependencies):
def compute_int(self, expression, low, high, guess, prefix, env, extra_args, dependencies) -> int:
raise EnvironmentException('%s does not support compute_int ' % self.get_id())
def compute_parameters_with_absolute_paths(self, parameter_list, build_dir):
raise EnvironmentException('%s does not support compute_parameters_with_absolute_paths ' % self.get_id())
def has_members(self, typename, membernames, prefix, env, *, extra_args=None, dependencies=None):
def has_members(self, typename, membernames, prefix, env, *, extra_args=None, dependencies=None) -> Tuple[bool, bool]:
raise EnvironmentException('%s does not support has_member(s) ' % self.get_id())
def has_type(self, typename, prefix, env, extra_args, *, dependencies=None):
def has_type(self, typename, prefix, env, extra_args, *, dependencies=None) -> Tuple[bool, bool]:
raise EnvironmentException('%s does not support has_type ' % self.get_id())
def symbols_have_underscore_prefix(self, env):
def symbols_have_underscore_prefix(self, env) -> bool:
raise EnvironmentException('%s does not support symbols_have_underscore_prefix ' % self.get_id())
def get_exelist(self):
@ -1087,31 +1085,31 @@ class Compiler:
def get_option_link_args(self, options):
return []
def check_header(self, *args, **kwargs):
def check_header(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header checks.' % self.get_display_language())
def has_header(self, *args, **kwargs):
def has_header(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header checks.' % self.get_display_language())
def has_header_symbol(self, *args, **kwargs):
def has_header_symbol(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header symbol checks.' % self.get_display_language())
def compiles(self, *args, **kwargs):
def compiles(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support compile checks.' % self.get_display_language())
def links(self, *args, **kwargs):
def links(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support link checks.' % self.get_display_language())
def run(self, *args, **kwargs):
def run(self, *args, **kwargs) -> RunResult:
raise EnvironmentException('Language %s does not support run checks.' % self.get_display_language())
def sizeof(self, *args, **kwargs):
def sizeof(self, *args, **kwargs) -> int:
raise EnvironmentException('Language %s does not support sizeof checks.' % self.get_display_language())
def alignment(self, *args, **kwargs):
def alignment(self, *args, **kwargs) -> int:
raise EnvironmentException('Language %s does not support alignment checks.' % self.get_display_language())
def has_function(self, *args, **kwargs):
def has_function(self, *args, **kwargs) -> Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support function checks.' % self.get_display_language())
@classmethod
@ -1125,12 +1123,12 @@ class Compiler:
def get_library_dirs(self, *args, **kwargs):
return ()
def has_multi_arguments(self, args, env):
def has_multi_arguments(self, args, env) -> Tuple[bool, bool]:
raise EnvironmentException(
'Language {} does not support has_multi_arguments.'.format(
self.get_display_language()))
def has_multi_link_arguments(self, args, env):
def has_multi_link_arguments(self, args, env) -> Tuple[bool, bool]:
raise EnvironmentException(
'Language {} does not support has_multi_link_arguments.'.format(
self.get_display_language()))
@ -1150,21 +1148,7 @@ class Compiler:
@contextlib.contextmanager
def compile(self, code, extra_args=None, mode='link', want_output=False):
if extra_args is None:
textra_args = None
extra_args = []
else:
textra_args = tuple(extra_args)
key = (code, textra_args, mode)
if not want_output:
if key in self.compiler_check_cache:
p = self.compiler_check_cache[key]
mlog.debug('Using cached compile:')
mlog.debug('Cached command line: ', ' '.join(p.commands), '\n')
mlog.debug('Code:\n', code)
mlog.debug('Cached compiler stdout:\n', p.stdo)
mlog.debug('Cached compiler stderr:\n', p.stde)
yield p
return
try:
with tempfile.TemporaryDirectory() as tmpdirname:
if isinstance(code, str):
@ -1206,8 +1190,7 @@ class Compiler:
p.input_name = srcname
if want_output:
p.output_name = output
else:
self.compiler_check_cache[key] = p
p.cached = False # Make sure that the cached attribute always exists
yield p
except (PermissionError, OSError):
# On Windows antivirus programs and the like hold on to files so
@ -1215,6 +1198,39 @@ class Compiler:
# catch OSError because the directory is then no longer empty.
pass
@contextlib.contextmanager
def cached_compile(self, code, cdata: coredata.CoreData, extra_args=None, mode: str = 'link'):
assert(isinstance(cdata, coredata.CoreData))
# Calculate the key
textra_args = tuple(extra_args) if extra_args is not None else None
key = (tuple(self.exelist), self.version, code, textra_args, mode)
# Check if not cached
if key not in cdata.compiler_check_cache:
with self.compile(code, extra_args=extra_args, mode=mode, want_output=False) as p:
# Remove all attributes except the following
# This way the object can be serialized
tokeep = ['args', 'commands', 'input_name', 'output_name',
'pid', 'returncode', 'stdo', 'stde', 'text_mode']
todel = [x for x in vars(p).keys() if x not in tokeep]
for i in todel:
delattr(p, i)
p.cached = False
cdata.compiler_check_cache[key] = p
yield p
return
# Return cached
p = cdata.compiler_check_cache[key]
p.cached = True
mlog.debug('Using cached compile:')
mlog.debug('Cached command line: ', ' '.join(p.commands), '\n')
mlog.debug('Code:\n', code)
mlog.debug('Cached compiler stdout:\n', p.stdo)
mlog.debug('Cached compiler stderr:\n', p.stde)
yield p
def get_colorout_args(self, colortype):
return []

@ -64,10 +64,11 @@ class CPPCompiler(CCompiler):
def has_header_symbol(self, hname, symbol, prefix, env, *, extra_args=None, dependencies=None):
# Check if it's a C-like symbol
if super().has_header_symbol(hname, symbol, prefix, env,
extra_args=extra_args,
dependencies=dependencies):
return True
found, cached = super().has_header_symbol(hname, symbol, prefix, env,
extra_args=extra_args,
dependencies=dependencies)
if found:
return True, cached
# Check if it's a class or a template
if extra_args is None:
extra_args = []
@ -263,7 +264,7 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
# So we should explicitly fail at this case.
def has_function(self, funcname, prefix, env, *, extra_args=None, dependencies=None):
if funcname == 'lchmod':
return False
return False, False
else:
return super().has_function(funcname, prefix, env,
extra_args=extra_args,

@ -146,8 +146,9 @@ class CudaCompiler(Compiler):
return super().get_compiler_check_args() + []
def has_header_symbol(self, hname, symbol, prefix, env, extra_args=None, dependencies=None):
if super().has_header_symbol(hname, symbol, prefix, env, extra_args, dependencies):
return True
result, cached = super().has_header_symbol(hname, symbol, prefix, env, extra_args, dependencies)
if result:
return True, cached
if extra_args is None:
extra_args = []
fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}

@ -326,8 +326,8 @@ class DCompiler(Compiler):
def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile'):
args = self._get_compiler_check_args(env, extra_args, dependencies, mode)
with self.compile(code, args, mode) as p:
return p.returncode == 0
with self.cached_compile(code, env.coredata, extra_args=args, mode=mode) as p:
return p.returncode == 0, p.cached
def has_multi_arguments(self, args, env):
return self.compiles('int i;\n', env, extra_args=args)

@ -250,16 +250,16 @@ class FortranCompiler(Compiler):
def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'):
return CCompiler._get_compiler_check_args(self, env, extra_args, dependencies, mode=mode)
def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile'):
def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile', disable_cache=False):
return CCompiler.compiles(self, code, env, extra_args=extra_args,
dependencies=dependencies, mode=mode)
dependencies=dependencies, mode=mode, disable_cache=disable_cache)
def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False):
return CCompiler._build_wrapper(self, code, env, extra_args, dependencies, mode, want_output)
def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False, disable_cache=False):
return CCompiler._build_wrapper(self, code, env, extra_args, dependencies, mode, want_output, disable_cache=disable_cache)
def links(self, code, env, *, extra_args=None, dependencies=None):
def links(self, code, env, *, extra_args=None, dependencies=None, disable_cache=False):
return CCompiler.links(self, code, env, extra_args=extra_args,
dependencies=dependencies)
dependencies=dependencies, disable_cache=disable_cache)
def run(self, code, env, *, extra_args=None, dependencies=None):
return CCompiler.run(self, code, env, extra_args=extra_args, dependencies=dependencies)
@ -297,11 +297,11 @@ class FortranCompiler(Compiler):
def has_multi_arguments(self, args, env):
return CCompiler.has_multi_arguments(self, args, env)
def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None):
return CCompiler.has_header(self, hname, prefix, env, extra_args=extra_args, dependencies=dependencies)
def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None, disable_cache=False):
return CCompiler.has_header(self, hname, prefix, env, extra_args=extra_args, dependencies=dependencies, disable_cache=disable_cache)
def get_define(self, dname, prefix, env, extra_args, dependencies):
return CCompiler.get_define(self, dname, prefix, env, extra_args, dependencies)
def get_define(self, dname, prefix, env, extra_args, dependencies, disable_cache=False):
return CCompiler.get_define(self, dname, prefix, env, extra_args, dependencies, disable_cache=disable_cache)
@classmethod
def _get_trials_from_pattern(cls, pattern, directory, libname):

@ -96,7 +96,7 @@ class ValaCompiler(Compiler):
extra_flags += self.get_compile_only_args()
else:
extra_flags += environment.coredata.get_external_link_args(for_machine, self.language)
with self.compile(code, extra_flags, 'compile') as p:
with self.cached_compile(code, environment.coredata, extra_args=extra_flags, mode='compile') as p:
if p.returncode != 0:
msg = 'Vala compiler {!r} can not compile programs' \
''.format(self.name_string())
@ -121,7 +121,7 @@ class ValaCompiler(Compiler):
args = env.coredata.get_external_args(for_machine, self.language)
vapi_args = ['--pkg', libname]
args += vapi_args
with self.compile(code, args, 'compile') as p:
with self.cached_compile(code, env.coredata, extra_args=args, mode='compile') as p:
if p.returncode == 0:
return vapi_args
# Not found? Try to find the vapi file itself.

@ -247,6 +247,7 @@ class CoreData:
self.compilers = OrderedDict()
self.cross_compilers = OrderedDict()
self.deps = OrderedDict()
self.compiler_check_cache = OrderedDict()
# Only to print a warning if it changes between Meson invocations.
self.config_files = self.__load_config_files(options.native_file, 'native')
self.libdir_cross_fixup()

@ -250,7 +250,7 @@ class BoostDependency(ExternalDependency):
def detect_headers_and_version(self):
try:
version = self.clib_compiler.get_define('BOOST_LIB_VERSION', '#include <boost/version.hpp>', self.env, self.get_compile_args(), [])
version = self.clib_compiler.get_define('BOOST_LIB_VERSION', '#include <boost/version.hpp>', self.env, self.get_compile_args(), [], disable_cache=True)[0]
except mesonlib.EnvironmentException:
return
except TypeError:

@ -368,7 +368,7 @@ class OpenMPDependency(ExternalDependency):
self.is_found = False
try:
openmp_date = self.clib_compiler.get_define(
'_OPENMP', '', self.env, self.clib_compiler.openmp_flags(), [self])
'_OPENMP', '', self.env, self.clib_compiler.openmp_flags(), [self], disable_cache=True)[0]
except mesonlib.EnvironmentException as e:
mlog.debug('OpenMP support not available in the compiler')
mlog.debug(e)
@ -376,7 +376,7 @@ class OpenMPDependency(ExternalDependency):
if openmp_date:
self.version = self.VERSIONS[openmp_date]
if self.clib_compiler.has_header('omp.h', '', self.env, dependencies=[self]):
if self.clib_compiler.has_header('omp.h', '', self.env, dependencies=[self], disable_cache=True)[0]:
self.is_found = True
self.compile_args = self.link_args = self.clib_compiler.openmp_flags()
else:

@ -641,7 +641,7 @@ class VulkanDependency(ExternalDependency):
else:
# simply try to guess it, usually works on linux
libs = self.clib_compiler.find_library('vulkan', environment, [])
if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', environment):
if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', environment, disable_cache=True)[0]:
self.type_name = 'system'
self.is_found = True
for lib in libs:

@ -1134,16 +1134,17 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of has_member must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
had = self.compiler.has_members(typename, [membername], prefix,
self.environment,
extra_args=extra_args,
dependencies=deps)
had, cached = self.compiler.has_members(typename, [membername], prefix,
self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
if had:
hadtxt = mlog.green('YES')
else:
hadtxt = mlog.red('NO')
mlog.log('Checking whether type', mlog.bold(typename, True),
'has member', mlog.bold(membername, True), msg, hadtxt)
'has member', mlog.bold(membername, True), msg, hadtxt, cached)
return had
@permittedKwargs({
@ -1163,17 +1164,18 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of has_members must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
had = self.compiler.has_members(typename, membernames, prefix,
self.environment,
extra_args=extra_args,
dependencies=deps)
had, cached = self.compiler.has_members(typename, membernames, prefix,
self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
if had:
hadtxt = mlog.green('YES')
else:
hadtxt = mlog.red('NO')
members = mlog.bold(', '.join(['"{}"'.format(m) for m in membernames]))
mlog.log('Checking whether type', mlog.bold(typename, True),
'has members', members, msg, hadtxt)
'has members', members, msg, hadtxt, cached)
return had
@permittedKwargs({
@ -1193,14 +1195,15 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of has_function must be a string.')
extra_args = self.determine_args(kwargs)
deps, msg = self.determine_dependencies(kwargs)
had = self.compiler.has_function(funcname, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
had, cached = self.compiler.has_function(funcname, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
if had:
hadtxt = mlog.green('YES')
else:
hadtxt = mlog.red('NO')
mlog.log('Checking for function', mlog.bold(funcname, True), msg, hadtxt)
mlog.log('Checking for function', mlog.bold(funcname, True), msg, hadtxt, cached)
return had
@permittedKwargs({
@ -1220,13 +1223,14 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of has_type must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
had = self.compiler.has_type(typename, prefix, self.environment,
extra_args=extra_args, dependencies=deps)
had, cached = self.compiler.has_type(typename, prefix, self.environment,
extra_args=extra_args, dependencies=deps)
cached = '(cached)' if cached else ''
if had:
hadtxt = mlog.green('YES')
else:
hadtxt = mlog.red('NO')
mlog.log('Checking for type', mlog.bold(typename, True), msg, hadtxt)
mlog.log('Checking for type', mlog.bold(typename, True), msg, hadtxt, cached)
return had
@FeatureNew('compiler.compute_int', '0.40.0')
@ -1305,10 +1309,11 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of get_define() must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
value = self.compiler.get_define(element, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
mlog.log('Fetching value of define', mlog.bold(element, True), msg, value)
value, cached = self.compiler.get_define(element, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
mlog.log('Fetching value of define', mlog.bold(element, True), msg, value, cached)
return value
@permittedKwargs({
@ -1332,15 +1337,16 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Testname argument must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs, endl=None)
result = self.compiler.compiles(code, self.environment,
extra_args=extra_args,
dependencies=deps)
result, cached = self.compiler.compiles(code, self.environment,
extra_args=extra_args,
dependencies=deps)
if len(testname) > 0:
if result:
h = mlog.green('YES')
else:
h = mlog.red('NO')
mlog.log('Checking if', mlog.bold(testname, True), msg, 'compiles:', h)
cached = '(cached)' if cached else ''
mlog.log('Checking if', mlog.bold(testname, True), msg, 'compiles:', h, cached)
return result
@permittedKwargs({
@ -1364,15 +1370,16 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Testname argument must be a string.')
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs, endl=None)
result = self.compiler.links(code, self.environment,
extra_args=extra_args,
dependencies=deps)
result, cached = self.compiler.links(code, self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
if len(testname) > 0:
if result:
h = mlog.green('YES')
else:
h = mlog.red('NO')
mlog.log('Checking if', mlog.bold(testname, True), msg, 'links:', h)
mlog.log('Checking if', mlog.bold(testname, True), msg, 'links:', h, cached)
return result
@FeatureNew('compiler.check_header', '0.47.0')
@ -1392,16 +1399,17 @@ class CompilerHolder(InterpreterObject):
return False
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
haz = self.compiler.check_header(hname, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
haz, cached = self.compiler.check_header(hname, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
cached = '(cached)' if cached else ''
if required and not haz:
raise InterpreterException('{} header {!r} not usable'.format(self.compiler.get_display_language(), hname))
elif haz:
h = mlog.green('YES')
else:
h = mlog.red('NO')
mlog.log('Check usable header', mlog.bold(hname, True), msg, h)
mlog.log('Check usable header', mlog.bold(hname, True), msg, h, cached)
return haz
@FeatureNewKwargs('compiler.has_header', '0.50.0', ['required'])
@ -1420,15 +1428,16 @@ class CompilerHolder(InterpreterObject):
return False
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
haz = self.compiler.has_header(hname, prefix, self.environment,
extra_args=extra_args, dependencies=deps)
haz, cached = self.compiler.has_header(hname, prefix, self.environment,
extra_args=extra_args, dependencies=deps)
cached = '(cached)' if cached else ''
if required and not haz:
raise InterpreterException('{} header {!r} not found'.format(self.compiler.get_display_language(), hname))
elif haz:
h = mlog.green('YES')
else:
h = mlog.red('NO')
mlog.log('Has header', mlog.bold(hname, True), msg, h)
mlog.log('Has header', mlog.bold(hname, True), msg, h, cached)
return haz
@FeatureNewKwargs('compiler.has_header_symbol', '0.50.0', ['required'])
@ -1447,16 +1456,17 @@ class CompilerHolder(InterpreterObject):
return False
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
haz = self.compiler.has_header_symbol(hname, symbol, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
haz, cached = self.compiler.has_header_symbol(hname, symbol, prefix, self.environment,
extra_args=extra_args,
dependencies=deps)
if required and not haz:
raise InterpreterException('{} symbol {} not found in header {}'.format(self.compiler.get_display_language(), symbol, hname))
elif haz:
h = mlog.green('YES')
else:
h = mlog.red('NO')
mlog.log('Header <{0}> has symbol'.format(hname), mlog.bold(symbol, True), msg, h)
cached = '(cached)' if cached else ''
mlog.log('Header <{0}> has symbol'.format(hname), mlog.bold(symbol, True), msg, h, cached)
return haz
def notfound_library(self, libname):
@ -1518,15 +1528,16 @@ class CompilerHolder(InterpreterObject):
@permittedKwargs({})
def has_multi_arguments_method(self, args, kwargs):
args = mesonlib.stringlistify(args)
result = self.compiler.has_multi_arguments(args, self.environment)
result, cached = self.compiler.has_multi_arguments(args, self.environment)
if result:
h = mlog.green('YES')
else:
h = mlog.red('NO')
cached = '(cached)' if cached else ''
mlog.log(
'Compiler for {} supports arguments {}:'.format(
self.compiler.get_display_language(), ' '.join(args)),
h)
h, cached)
return result
@FeatureNew('compiler.get_supported_arguments', '0.43.0')
@ -1560,7 +1571,8 @@ class CompilerHolder(InterpreterObject):
@permittedKwargs({})
def has_multi_link_arguments_method(self, args, kwargs):
args = mesonlib.stringlistify(args)
result = self.compiler.has_multi_link_arguments(args, self.environment)
result, cached = self.compiler.has_multi_link_arguments(args, self.environment)
cached = '(cached)' if cached else ''
if result:
h = mlog.green('YES')
else:
@ -1568,7 +1580,7 @@ class CompilerHolder(InterpreterObject):
mlog.log(
'Compiler for {} supports link arguments {}:'.format(
self.compiler.get_display_language(), ' '.join(args)),
h)
h, cached)
return result
@FeatureNew('compiler.get_supported_link_arguments_method', '0.46.0')
@ -1597,9 +1609,10 @@ class CompilerHolder(InterpreterObject):
args = mesonlib.stringlistify(args)
if len(args) != 1:
raise InterpreterException('has_func_attribute takes exactly one argument.')
result = self.compiler.has_func_attribute(args[0], self.environment)
result, cached = self.compiler.has_func_attribute(args[0], self.environment)
cached = '(cached)' if cached else ''
h = mlog.green('YES') if result else mlog.red('NO')
mlog.log('Compiler for {} supports function attribute {}:'.format(self.compiler.get_display_language(), args[0]), h)
mlog.log('Compiler for {} supports function attribute {}:'.format(self.compiler.get_display_language(), args[0]), h, cached)
return result
@FeatureNew('compiler.get_supported_function_attributes', '0.48.0')

@ -66,7 +66,7 @@ class SimdModule(ExtensionModule):
mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
continue
if args:
if not compiler.has_multi_arguments(args, state.environment):
if not compiler.has_multi_arguments(args, state.environment)[0]:
mlog.log('Compiler supports %s:' % iset, mlog.red('NO'))
continue
mlog.log('Compiler supports %s:' % iset, mlog.green('YES'))

Loading…
Cancel
Save