|
|
|
@ -288,7 +288,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
def _sanity_check_impl(self, work_dir: str, environment: 'Environment', |
|
|
|
|
sname: str, code: str) -> None: |
|
|
|
|
mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist)) |
|
|
|
|
mlog.debug('Is cross compiler: %s.' % str(self.is_cross)) |
|
|
|
|
mlog.debug(f'Is cross compiler: {self.is_cross!s}.') |
|
|
|
|
|
|
|
|
|
source_name = os.path.join(work_dir, sname) |
|
|
|
|
binname = sname.rsplit('.', 1)[0] |
|
|
|
@ -336,7 +336,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
try: |
|
|
|
|
pe = subprocess.Popen(cmdlist) |
|
|
|
|
except Exception as e: |
|
|
|
|
raise mesonlib.EnvironmentException('Could not invoke sanity test executable: %s.' % str(e)) |
|
|
|
|
raise mesonlib.EnvironmentException(f'Could not invoke sanity test executable: {e!s}.') |
|
|
|
|
pe.wait() |
|
|
|
|
if pe.returncode != 0: |
|
|
|
|
raise mesonlib.EnvironmentException(f'Executables created by {self.language} compiler {self.name_string()} are not runnable.') |
|
|
|
@ -473,9 +473,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
raise compilers.CrossNoRunException('Can not run test applications in this cross environment.') |
|
|
|
|
with self._build_wrapper(code, env, extra_args, dependencies, mode='link', want_output=True) as p: |
|
|
|
|
if p.returncode != 0: |
|
|
|
|
mlog.debug('Could not compile test file %s: %d\n' % ( |
|
|
|
|
p.input_name, |
|
|
|
|
p.returncode)) |
|
|
|
|
mlog.debug(f'Could not compile test file {p.input_name}: {p.returncode}\n') |
|
|
|
|
return compilers.RunResult(False) |
|
|
|
|
if need_exe_wrapper: |
|
|
|
|
cmdlist = self.exe_wrapper.get_command() + [p.output_name] |
|
|
|
@ -508,16 +506,16 @@ class CLikeCompiler(Compiler): |
|
|
|
|
dependencies: T.Optional[T.List['Dependency']] = None) -> int: |
|
|
|
|
# Try user's guess first |
|
|
|
|
if isinstance(guess, int): |
|
|
|
|
if self._compile_int('%s == %d' % (expression, guess), prefix, env, extra_args, dependencies): |
|
|
|
|
if self._compile_int(f'{expression} == {guess}', prefix, env, extra_args, dependencies): |
|
|
|
|
return guess |
|
|
|
|
|
|
|
|
|
# If no bounds are given, compute them in the limit of int32 |
|
|
|
|
maxint = 0x7fffffff |
|
|
|
|
minint = -0x80000000 |
|
|
|
|
if not isinstance(low, int) or not isinstance(high, int): |
|
|
|
|
if self._compile_int('%s >= 0' % (expression), prefix, env, extra_args, dependencies): |
|
|
|
|
if self._compile_int(f'{expression} >= 0', prefix, env, extra_args, dependencies): |
|
|
|
|
low = cur = 0 |
|
|
|
|
while self._compile_int('%s > %d' % (expression, cur), prefix, env, extra_args, dependencies): |
|
|
|
|
while self._compile_int(f'{expression} > {cur}', prefix, env, extra_args, dependencies): |
|
|
|
|
low = cur + 1 |
|
|
|
|
if low > maxint: |
|
|
|
|
raise mesonlib.EnvironmentException('Cross-compile check overflowed') |
|
|
|
@ -527,7 +525,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
high = cur |
|
|
|
|
else: |
|
|
|
|
high = cur = -1 |
|
|
|
|
while self._compile_int('%s < %d' % (expression, cur), prefix, env, extra_args, dependencies): |
|
|
|
|
while self._compile_int(f'{expression} < {cur}', prefix, env, extra_args, dependencies): |
|
|
|
|
high = cur - 1 |
|
|
|
|
if high < minint: |
|
|
|
|
raise mesonlib.EnvironmentException('Cross-compile check overflowed') |
|
|
|
@ -539,14 +537,14 @@ class CLikeCompiler(Compiler): |
|
|
|
|
# Sanity check limits given by user |
|
|
|
|
if high < low: |
|
|
|
|
raise mesonlib.EnvironmentException('high limit smaller than low limit') |
|
|
|
|
condition = '%s <= %d && %s >= %d' % (expression, high, expression, low) |
|
|
|
|
condition = f'{expression} <= {high} && {expression} >= {low}' |
|
|
|
|
if not self._compile_int(condition, prefix, env, extra_args, dependencies): |
|
|
|
|
raise mesonlib.EnvironmentException('Value out of given range') |
|
|
|
|
|
|
|
|
|
# Binary search |
|
|
|
|
while low != high: |
|
|
|
|
cur = low + int((high - low) / 2) |
|
|
|
|
if self._compile_int('%s <= %d' % (expression, cur), prefix, env, extra_args, dependencies): |
|
|
|
|
if self._compile_int(f'{expression} <= {cur}', prefix, env, extra_args, dependencies): |
|
|
|
|
high = cur |
|
|
|
|
else: |
|
|
|
|
low = cur + 1 |
|
|
|
@ -589,7 +587,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
if not self.compiles(t, env, extra_args=extra_args, |
|
|
|
|
dependencies=dependencies)[0]: |
|
|
|
|
return -1 |
|
|
|
|
return self.cross_compute_int('sizeof(%s)' % typename, None, None, None, prefix, env, extra_args, dependencies) |
|
|
|
|
return self.cross_compute_int(f'sizeof({typename})', None, None, None, prefix, env, extra_args, dependencies) |
|
|
|
|
|
|
|
|
|
def sizeof(self, typename: str, prefix: str, env: 'Environment', *, |
|
|
|
|
extra_args: T.Optional[T.List[str]] = None, |
|
|
|
@ -662,7 +660,7 @@ class CLikeCompiler(Compiler): |
|
|
|
|
raise mesonlib.EnvironmentException('Could not run alignment test binary.') |
|
|
|
|
align = int(res.stdout) |
|
|
|
|
if align == 0: |
|
|
|
|
raise mesonlib.EnvironmentException('Could not determine alignment of %s. Sorry. You might want to file a bug.' % typename) |
|
|
|
|
raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.') |
|
|
|
|
return align |
|
|
|
|
|
|
|
|
|
def get_define(self, dname: str, prefix: str, env: 'Environment', |
|
|
|
|