From 2bf3082bae3d04b4c0a839ba58f8eef65c1bdad8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 2 Oct 2024 14:17:44 +0100 Subject: [PATCH] env2mfile: Don't hard-code Debian as always being Linux All official Debian release architectures use the Linux kernel, but unofficial ports like hurd-i386 and kfreebsd-amd64 use the Hurd and FreeBSD kernel, respectively. Map Linux to 'linux' and kFreeBSD ports to 'freebsd' as per the reference tables in Meson's documentation. For now, use the Debian system name such as 'hurd' for anything else. Signed-off-by: Simon McVittie --- mesonbuild/scripts/env2mfile.py | 8 +++++++- unittests/internaltests.py | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mesonbuild/scripts/env2mfile.py b/mesonbuild/scripts/env2mfile.py index b3d5963bbbfa..d06b97112660 100755 --- a/mesonbuild/scripts/env2mfile.py +++ b/mesonbuild/scripts/env2mfile.py @@ -189,6 +189,11 @@ def get_args_from_envvars(infos: MachineInfo) -> None: 'hurd': 'gnu', } +# map from DEB_HOST_ARCH_OS to Meson machine.kernel() +deb_kernel_map = { + 'kfreebsd': 'freebsd', +} + def deb_detect_cmake(infos: MachineInfo, data: T.Dict[str, str]) -> None: system_name_map = {'linux': 'Linux', 'kfreebsd': 'kFreeBSD', 'hurd': 'GNU'} system_processor_map = {'arm': 'armv7l', 'mips64el': 'mips64', 'powerpc64le': 'ppc64le'} @@ -232,7 +237,8 @@ def dpkg_architecture_to_machine_info(output: str, options: T.Any) -> MachineInf host_os = deb_os_map.get(data['DEB_HOST_ARCH_OS'], data['DEB_HOST_ARCH_OS']) host_subsystem = host_os - host_kernel = 'linux' + host_kernel = deb_kernel_map.get(data['DEB_HOST_ARCH_OS'], + data['DEB_HOST_ARCH_OS']) host_cpu_family = deb_cpu_family_map.get(data['DEB_HOST_GNU_CPU'], data['DEB_HOST_GNU_CPU']) host_cpu = deb_cpu_map.get(data['DEB_HOST_ARCH'], diff --git a/unittests/internaltests.py b/unittests/internaltests.py index 8c5ec10a2fa7..0e250d20346f 100644 --- a/unittests/internaltests.py +++ b/unittests/internaltests.py @@ -1976,7 +1976,9 @@ def locate_path(program: str) -> T.List[str]: }, system='gnu', subsystem='gnu', - # TODO: Currently linux, but should be gnu/hurd/mach? + # TODO: Currently hurd; should match whatever happens + # during native builds, but at the moment native builds + # fail when kernel() is called. # https://github.com/mesonbuild/meson/issues/13740 kernel='TODO', # TODO: Currently hurd-i386, but should be i686 @@ -2034,8 +2036,7 @@ def locate_path(program: str) -> T.List[str]: }, system='kfreebsd', subsystem='kfreebsd', - # TODO: Currently linux but should be freebsd - kernel='TODO', + kernel='freebsd', # TODO: Currently kfreebsd-amd64 but should be x86_64 cpu='TODO', cpu_family='x86_64',