From 42c68291c4c2512de04de31a90cb1c408d75a277 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 29 Jun 2023 13:50:52 -0700 Subject: [PATCH] environment: separate illumos and Solaris kernels in Machines While both kernels are derived from the OpenSolaris project of Sun, they have diverged and code that works with one may not work with the other. As such, we should provide different values for them. This was requested by both Oracle and the illumos upstreams. Fixes: #11922 --- docs/markdown/Reference-tables.md | 3 ++- mesonbuild/environment.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index b553832eb..377b36286 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -175,7 +175,8 @@ Native names as returned by the `.kernel()` method. | netbsd | | | nt | | | xnu | Kernel of various Apple OSes | -| sunos | | +| illumos | Kernel derived from OpenSolaris by community efforts | +| solaris | Kernel derived from OpenSolaris by Oracle | | dragonfly | | | haiku| | | none | For e.g. bare metal embedded | diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 688070f4a..ff7ae3ae9 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -403,12 +403,23 @@ KERNEL_MAPPINGS: T.Mapping[str, str] = {'freebsd': 'freebsd', 'linux': 'linux', 'cygwin': 'nt', 'darwin': 'xnu', - 'sunos': 'sunos', 'dragonfly': 'dragonfly', 'haiku': 'haiku', } def detect_kernel(system: str) -> T.Optional[str]: + if system == 'sunos': + # This needs to be /usr/bin/uname because gnu-uname could be installed and + # won't provide the necessary information + p, out, _ = Popen_safe(['/usr/bin/uname', '-o']) + if p.returncode != 0: + raise MesonException('Failed to run "/usr/bin/uname -o"') + out = out.lower().strip() + if out not in {'illumos', 'solaris'}: + mlog.warning(f'Got an unexpected value for kernel on a SunOS derived platform, expcted either "illumos" or "solaris", but got "{out}".' + "Please open a Meson issue with the OS you're running and the value detected for your kernel.") + return None + return out return KERNEL_MAPPINGS.get(system, None) def detect_subsystem(system: str) -> T.Optional[str]: