Validate the passed CPU family (US: backport) and turn the upstream warning to an error (US: inappropriate). Upstream-Status: Backport Signed-off-by: Ross Burton From 456f7ea48503731d50a2b7287a0f198b73b4fe61 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Wed, 20 Jun 2018 13:45:44 +0100 Subject: [PATCH 1/2] Validate cpu_family (#3753) * environment: validate cpu_family in cross file * run_unittests: add unittest to ensure CPU family list in docs and environment matches * run_unittests: skip compiler options test if not in a git repository * environment: validate the detected cpu_family * docs: add 32-bit PowerPC and 32/64-bit MIPS to CPU Families table Names gathered by booting Linux in Qemu and running: $ python3 import platform; platform.machine() Partial fix for #3751 --- mesonbuild/environment.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 6920b8d6..091d92dc 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -72,6 +72,22 @@ from .compilers import ( build_filename = 'meson.build' +known_cpu_families = ( + 'aarch64', + 'arm', + 'e2k', + 'ia64', + 'mips', + 'mips64', + 'parisc', + 'ppc', + 'ppc64', + 'ppc64le', + 'sparc64', + 'x86', + 'x86_64' +) + # Environment variables that each lang uses. cflags_mapping = {'c': 'CFLAGS', 'cpp': 'CXXFLAGS', @@ -210,6 +226,10 @@ def detect_cpu_family(compilers): pass return 'x86_64' # Add fixes here as bugs are reported. + + if trial not in known_cpu_families: + mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) + return trial def detect_cpu(compilers): @@ -1021,6 +1041,10 @@ class CrossBuildInfo: res = eval(value, {'__builtins__': None}, {'true': True, 'false': False}) except Exception: raise EnvironmentException('Malformed value in cross file variable %s.' % entry) + + if entry == 'cpu_family' and res not in known_cpu_families: + mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % value) + if self.ok_type(res): self.config[s][entry] = res elif isinstance(res, list): -- 2.11.0 From 202e0199d3ffd2637f4dbee08f8351520f7dde3b Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Tue, 3 Jul 2018 13:59:09 +0100 Subject: [PATCH 2/2] Make CPU family warnings fatal --- mesonbuild/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 091d92dc..67177c1f 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -228,7 +228,7 @@ def detect_cpu_family(compilers): # Add fixes here as bugs are reported. if trial not in known_cpu_families: - mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % trial) + raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % trial) return trial @@ -1043,7 +1043,7 @@ class CrossBuildInfo: raise EnvironmentException('Malformed value in cross file variable %s.' % entry) if entry == 'cpu_family' and res not in known_cpu_families: - mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % value) + raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % value) if self.ok_type(res): self.config[s][entry] = res -- 2.11.0