diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index fe5a9ca14..2d70d7279 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -653,12 +653,13 @@ class CCompiler(Compiler): args = self._get_compiler_check_args(env, extra_args, dependencies, mode='preprocess').to_native() with self.compile(code.format(**fargs), args, 'preprocess', cdata=env.coredata) 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': @@ -1202,7 +1203,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 @@ -1707,7 +1708,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' diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 21fa4984f..51a1300f9 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -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} diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index e8257d345..a5f72d856 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -327,7 +327,7 @@ class DCompiler(Compiler): args = self._get_compiler_check_args(env, extra_args, dependencies, mode) with self.compile(code, args, mode, cdata=env.coredata) as p: - return p.returncode == 0 + return p.returncode == 0, p.cached def has_multi_arguments(self, args, env): return self.compiles('int i;\n', env, extra_args=args) diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 381824c79..6e06847e3 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -250,7 +250,7 @@ class BoostDependency(ExternalDependency): def detect_headers_and_version(self): try: - version = self.clib_compiler.get_define('BOOST_LIB_VERSION', '#include ', self.env, self.get_compile_args(), []) + version = self.clib_compiler.get_define('BOOST_LIB_VERSION', '#include ', self.env, self.get_compile_args(), [])[0] except mesonlib.EnvironmentException: return except TypeError: diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index d266a3737..77ea6ef05 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -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])[0] except mesonlib.EnvironmentException as e: mlog.debug('OpenMP support not available in the compiler') mlog.debug(e) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index b0311a4b9..c4092f224 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1309,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({