env2mfile: Base cpu on DEB_HOST_GNU_CPU unless DEB_HOST_ARCH is special

`DEB_HOST_ARCH` encodes both the CPU family and the OS, so using it to
get the CPU type gives the wrong answer for non-Linux ports.

However, `DEB_HOST_GNU_CPU` gives less detailed information about the
CPU: it's `arm` for all 32-bit ARM CPUs, and doesn't distinguish between
the differing baselines of `armel` (ARMv5 softfloat) and `armhf`
(ARMv7 hardfloat).

When cross-compiling for x86_64 Linux, this changes the `cpu()` from
`amd64` to `x86_64`, which is consistent with the answer we get during
native builds on that architecture.

When cross-compiling for `ppc64el`, this changes the `cpu()` from
`ppc64el` to `ppc64`, which is a reasonable change but is still not
consistent with what we see during native builds (which is `ppc64le`):
see #13741 for that.

Resolves: https://github.com/mesonbuild/meson/issues/13742
Signed-off-by: Simon McVittie <smcv@debian.org>
pull/13866/head
Simon McVittie 7 months ago committed by Jussi Pakkanen
parent 114a3e2914
commit 9d0de83368
  1. 11
      mesonbuild/scripts/env2mfile.py
  2. 13
      unittests/internaltests.py

@ -130,14 +130,20 @@ def get_args_from_envvars(infos: MachineInfo) -> None:
if objcpp_link_args: if objcpp_link_args:
infos.link_args['objcpp'] = objcpp_link_args infos.link_args['objcpp'] = objcpp_link_args
# map from DEB_HOST_GNU_CPU to Meson machine.cpu_family()
deb_cpu_family_map = { deb_cpu_family_map = {
'mips64el': 'mips64', 'mips64el': 'mips64',
'i686': 'x86', 'i686': 'x86',
'powerpc64le': 'ppc64', 'powerpc64le': 'ppc64',
} }
deb_cpu_map = { # map from DEB_HOST_ARCH to Meson machine.cpu()
deb_arch_cpu_map = {
'armhf': 'arm7hlf', 'armhf': 'arm7hlf',
}
# map from DEB_HOST_GNU_CPU to Meson machine.cpu()
deb_cpu_map = {
'mips64el': 'mips64', 'mips64el': 'mips64',
'powerpc64le': 'ppc64', 'powerpc64le': 'ppc64',
} }
@ -202,7 +208,8 @@ def dpkg_architecture_to_machine_info(output: str, options: T.Any) -> MachineInf
host_subsystem = host_os host_subsystem = host_os
host_kernel = replace_special_cases(deb_kernel_map, data['DEB_HOST_ARCH_OS']) host_kernel = replace_special_cases(deb_kernel_map, data['DEB_HOST_ARCH_OS'])
host_cpu_family = replace_special_cases(deb_cpu_family_map, data['DEB_HOST_GNU_CPU']) host_cpu_family = replace_special_cases(deb_cpu_family_map, data['DEB_HOST_GNU_CPU'])
host_cpu = replace_special_cases(deb_cpu_map, data['DEB_HOST_ARCH']) host_cpu = deb_arch_cpu_map.get(data['DEB_HOST_ARCH'],
replace_special_cases(deb_cpu_map, data['DEB_HOST_GNU_CPU']))
host_endian = data['DEB_HOST_ARCH_ENDIAN'] host_endian = data['DEB_HOST_ARCH_ENDIAN']
compilerstems = [('c', 'gcc'), compilerstems = [('c', 'gcc'),

@ -1835,9 +1835,7 @@ class InternalTests(unittest.TestCase):
system='linux', system='linux',
subsystem='linux', subsystem='linux',
kernel='linux', kernel='linux',
# TODO: In native builds we get x86_64, but in cpu='x86_64',
# cross-builds it's amd64
cpu='TODO',
cpu_family='x86_64', cpu_family='x86_64',
endian='little', endian='little',
), ),
@ -1940,8 +1938,7 @@ class InternalTests(unittest.TestCase):
# fail when kernel() is called. # fail when kernel() is called.
# https://github.com/mesonbuild/meson/issues/13740 # https://github.com/mesonbuild/meson/issues/13740
kernel='TODO', kernel='TODO',
# TODO: Currently hurd-i386, but should be i686 cpu='i686',
cpu='TODO',
cpu_family='x86', cpu_family='x86',
endian='little', endian='little',
), ),
@ -1980,8 +1977,7 @@ class InternalTests(unittest.TestCase):
system='kfreebsd', system='kfreebsd',
subsystem='kfreebsd', subsystem='kfreebsd',
kernel='freebsd', kernel='freebsd',
# TODO: Currently kfreebsd-amd64 but should be x86_64 cpu='x86_64',
cpu='TODO',
cpu_family='x86_64', cpu_family='x86_64',
endian='little', endian='little',
), ),
@ -2059,8 +2055,7 @@ class InternalTests(unittest.TestCase):
system='linux', system='linux',
subsystem='linux', subsystem='linux',
kernel='linux', kernel='linux',
# TODO: Currently ppc64el, but native builds have ppc64le, # TODO: Currently ppc64, but native builds have ppc64le
# and maybe it should be ppc64 in both cases?
# https://github.com/mesonbuild/meson/issues/13741 # https://github.com/mesonbuild/meson/issues/13741
cpu='TODO', cpu='TODO',
cpu_family='ppc64', cpu_family='ppc64',

Loading…
Cancel
Save