Fix outdated cross-compilation checks

0.54
Ole André Vadla Ravnås 5 years ago committed by Nirbheek Chauhan
parent 7f4202112c
commit 72f263cddb
  1. 2
      mesonbuild/backend/backends.py
  2. 5
      mesonbuild/compilers/mixins/clike.py
  3. 4
      mesonbuild/coredata.py
  4. 20
      mesonbuild/environment.py

@ -734,7 +734,7 @@ class Backend:
# E.g. an external verifier or simulator program run on a generated executable.
# Can always be run without a wrapper.
test_for_machine = MachineChoice.BUILD
is_cross = not self.environment.machines.matches_build_machine(test_for_machine)
is_cross = self.environment.is_cross_build(test_for_machine)
if is_cross and self.environment.need_exe_wrapper():
exe_wrapper = self.environment.get_exe_wrapper()
else:

@ -369,7 +369,8 @@ class CLikeCompiler:
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:
need_exe_wrapper = env.need_exe_wrapper(self.for_machine)
if need_exe_wrapper and self.exe_wrapper is None:
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:
@ -377,7 +378,7 @@ class CLikeCompiler:
p.input_name,
p.returncode))
return compilers.RunResult(False)
if self.is_cross:
if need_exe_wrapper:
cmdlist = self.exe_wrapper + [p.output_name]
else:
cmdlist = p.output_name

@ -665,7 +665,9 @@ class CoreData:
if type(oldval) != type(value):
self.user_options[name] = value
def is_cross_build(self) -> bool:
def is_cross_build(self, when_building_for: MachineChoice = MachineChoice.HOST) -> bool:
if when_building_for == MachineChoice.BUILD:
return False
return len(self.cross_files) > 0
def strip_build_option_names(self, options):

@ -637,8 +637,8 @@ class Environment:
self.coredata.meson_command = mesonlib.meson_command
self.first_invocation = True
def is_cross_build(self) -> bool:
return self.coredata.is_cross_build()
def is_cross_build(self, when_building_for: MachineChoice = MachineChoice.HOST) -> bool:
return self.coredata.is_cross_build(when_building_for)
def dump_coredata(self):
return coredata.save(self.coredata, self.get_build_dir())
@ -901,7 +901,7 @@ class Environment:
def _detect_c_or_cpp_compiler(self, lang: str, for_machine: MachineChoice) -> Compiler:
popen_exceptions = {}
compilers, ccache, exe_wrap = self._get_compilers(lang, for_machine)
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
for compiler in compilers:
@ -1151,7 +1151,7 @@ class Environment:
def detect_cuda_compiler(self, for_machine):
popen_exceptions = {}
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
compilers, ccache, exe_wrap = self._get_compilers('cuda', for_machine)
info = self.machines[for_machine]
for compiler in compilers:
@ -1191,7 +1191,7 @@ class Environment:
def detect_fortran_compiler(self, for_machine: MachineChoice):
popen_exceptions = {}
compilers, ccache, exe_wrap = self._get_compilers('fortran', for_machine)
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
for compiler in compilers:
if isinstance(compiler, str):
@ -1310,7 +1310,7 @@ class Environment:
def _detect_objc_or_objcpp_compiler(self, for_machine: MachineInfo, objc: bool) -> 'Compiler':
popen_exceptions = {}
compilers, ccache, exe_wrap = self._get_compilers('objc' if objc else 'objcpp', for_machine)
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
for compiler in compilers:
@ -1401,7 +1401,7 @@ class Environment:
def detect_vala_compiler(self, for_machine):
exelist = self.lookup_binary_entry(for_machine, 'vala')
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
if exelist is None:
# TODO support fallback
@ -1421,7 +1421,7 @@ class Environment:
def detect_rust_compiler(self, for_machine):
popen_exceptions = {}
compilers, ccache, exe_wrap = self._get_compilers('rust', for_machine)
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
cc = self.detect_c_compiler(for_machine)
@ -1512,7 +1512,7 @@ class Environment:
arch = 'x86_mscoff'
popen_exceptions = {}
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
results, ccache, exe_wrap = self._get_compilers('d', for_machine)
for exelist in results:
# Search for a D compiler.
@ -1603,7 +1603,7 @@ class Environment:
def detect_swift_compiler(self, for_machine):
exelist = self.lookup_binary_entry(for_machine, 'swift')
is_cross = not self.machines.matches_build_machine(for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
if exelist is None:
# TODO support fallback

Loading…
Cancel
Save