From 5794b18cd22bd0f51ed17731abc1a55dedaa73d8 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Wed, 15 Nov 2023 18:54:35 +0100 Subject: [PATCH] meson: backport version 1.0.1 from yocto 4.2 This is required to build the new version of gstreamer used by NXP for the ccimx93 and integrated in following commits. Signed-off-by: Javier Viguera --- ...for-clang-before-guessing-gcc-or-lcc.patch | 56 +++++++ .../0001-Make-CPU-family-warnings-fatal.patch | 45 +++++ ...-not-manipulate-the-environment-when.patch | 37 +++++ ...pport-building-allarch-recipes-again.patch | 28 ++++ .../meson/meson/meson-setup.py | 43 +++++ .../meson/meson/meson-wrapper | 31 ++++ .../recipes-devtools/meson/meson_1.0.1.bb | 157 ++++++++++++++++++ 7 files changed, 397 insertions(+) create mode 100644 meta-digi-dey/recipes-devtools/meson/meson/0001-Check-for-clang-before-guessing-gcc-or-lcc.patch create mode 100644 meta-digi-dey/recipes-devtools/meson/meson/0001-Make-CPU-family-warnings-fatal.patch create mode 100644 meta-digi-dey/recipes-devtools/meson/meson/0001-python-module-do-not-manipulate-the-environment-when.patch create mode 100644 meta-digi-dey/recipes-devtools/meson/meson/0002-Support-building-allarch-recipes-again.patch create mode 100755 meta-digi-dey/recipes-devtools/meson/meson/meson-setup.py create mode 100755 meta-digi-dey/recipes-devtools/meson/meson/meson-wrapper create mode 100644 meta-digi-dey/recipes-devtools/meson/meson_1.0.1.bb diff --git a/meta-digi-dey/recipes-devtools/meson/meson/0001-Check-for-clang-before-guessing-gcc-or-lcc.patch b/meta-digi-dey/recipes-devtools/meson/meson/0001-Check-for-clang-before-guessing-gcc-or-lcc.patch new file mode 100644 index 000000000..58fa11943 --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/0001-Check-for-clang-before-guessing-gcc-or-lcc.patch @@ -0,0 +1,56 @@ +From 8739e1c3bef653415ad4b9b9c318ccfa76c43da6 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 31 Mar 2022 15:00:24 -0700 +Subject: [PATCH] Check for clang before guessing gcc or lcc + +clang --version can yield a string like below when its installed into +such a directory + +clang version 14.0.0 (https://github.com/llvm/llvm-project 3f43d803382d57e3fc010ca19833077d1023e9c9) +Target: aarch64-yoe-linux +Thread model: posix +InstalledDir: /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/gnome-text-editor/42.0-r0/recipe-sysroot-native/usr/bin/aarch64-yoe-linux + +as you can see InstallDir has 'xt-' subtring and this trips the check to +guess gcc + +if 'Free Software Foundation' in out or 'xt-' in out: + +Therefore, check if compiler is clang then there is no point of running +this check anyway. + +Upstream-Status: Submitted [https://github.com/mesonbuild/meson/pull/10218] +Signed-off-by: Khem Raj +--- + mesonbuild/compilers/detect.py | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py +index 53948b01a..ba335cf39 100644 +--- a/mesonbuild/compilers/detect.py ++++ b/mesonbuild/compilers/detect.py +@@ -427,13 +427,14 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin + version = search_version(out) + + guess_gcc_or_lcc: T.Optional[str] = None +- if 'Free Software Foundation' in out or 'xt-' in out: +- guess_gcc_or_lcc = 'gcc' +- if 'e2k' in out and 'lcc' in out: +- guess_gcc_or_lcc = 'lcc' +- if 'Microchip Technology' in out: +- # this output has "Free Software Foundation" in its version +- guess_gcc_or_lcc = None ++ if not 'clang' in compiler_name: ++ if 'Free Software Foundation' in out or 'xt-' in out: ++ guess_gcc_or_lcc = 'gcc' ++ if 'e2k' in out and 'lcc' in out: ++ guess_gcc_or_lcc = 'lcc' ++ if 'Microchip Technology' in out: ++ # this output has "Free Software Foundation" in its version ++ guess_gcc_or_lcc = None + + if guess_gcc_or_lcc: + defines = _get_gnu_compiler_defines(compiler) +-- +2.35.1 + diff --git a/meta-digi-dey/recipes-devtools/meson/meson/0001-Make-CPU-family-warnings-fatal.patch b/meta-digi-dey/recipes-devtools/meson/meson/0001-Make-CPU-family-warnings-fatal.patch new file mode 100644 index 000000000..848dccfbe --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/0001-Make-CPU-family-warnings-fatal.patch @@ -0,0 +1,45 @@ +From 6c4eef1d92e9e42fdbc888365cab3c95fb33c605 Mon Sep 17 00:00:00 2001 +From: Ross Burton +Date: Tue, 3 Jul 2018 13:59:09 +0100 +Subject: [PATCH] Make CPU family warnings fatal + +Upstream-Status: Inappropriate [OE specific] +Signed-off-by: Ross Burton + +--- + mesonbuild/envconfig.py | 2 +- + mesonbuild/environment.py | 4 +--- + 2 files changed, 2 insertions(+), 4 deletions(-) + +Index: meson-0.60.2/mesonbuild/envconfig.py +=================================================================== +--- meson-0.60.2.orig/mesonbuild/envconfig.py ++++ meson-0.60.2/mesonbuild/envconfig.py +@@ -266,8 +266,8 @@ class MachineInfo(HoldableObject): + 'but is missing {}.'.format(minimum_literal - set(literal))) + + cpu_family = literal['cpu_family'] +- if cpu_family not in known_cpu_families: +- mlog.warning(f'Unknown CPU family {cpu_family}, please report this at https://github.com/mesonbuild/meson/issues/new') ++ if cpu_family not in known_cpu_families and cpu_family != "riscv": ++ raise EnvironmentException('Unknown CPU family {}, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.'.format(cpu_family)) + + endian = literal['endian'] + if endian not in ('little', 'big'): +Index: meson-0.60.2/mesonbuild/environment.py +=================================================================== +--- meson-0.60.2.orig/mesonbuild/environment.py ++++ meson-0.60.2/mesonbuild/environment.py +@@ -354,10 +354,8 @@ def detect_cpu_family(compilers: Compile + if any_compiler_has_define(compilers, '__64BIT__'): + trial = 'ppc64' + +- if trial not in known_cpu_families: +- mlog.warning(f'Unknown CPU family {trial!r}, please report this at ' +- 'https://github.com/mesonbuild/meson/issues/new with the ' +- 'output of `uname -a` and `cat /proc/cpuinfo`') ++ if trial not in known_cpu_families and trail != "riscv": ++ raise EnvironmentException('Unknown CPU family %s, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.' % trial) + + return trial + diff --git a/meta-digi-dey/recipes-devtools/meson/meson/0001-python-module-do-not-manipulate-the-environment-when.patch b/meta-digi-dey/recipes-devtools/meson/meson/0001-python-module-do-not-manipulate-the-environment-when.patch new file mode 100644 index 000000000..f01a66781 --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/0001-python-module-do-not-manipulate-the-environment-when.patch @@ -0,0 +1,37 @@ +From 2e9582167bf9d3273004edb2637310531f0155ab Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Mon, 19 Nov 2018 14:24:26 +0100 +Subject: [PATCH] python module: do not manipulate the environment when calling + pkg-config + +Upstream-Status: Inappropriate [oe-core specific] +Signed-off-by: Alexander Kanavin + +--- + mesonbuild/modules/python.py | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py +index 3bbccd1..fda7a25 100644 +--- a/mesonbuild/modules/python.py ++++ b/mesonbuild/modules/python.py +@@ -277,9 +277,6 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice', + # there is no LIBPC, so we can't search in it + return NotFoundDependency('python', env) + +- old_pkg_libdir = os.environ.pop('PKG_CONFIG_LIBDIR', None) +- old_pkg_path = os.environ.pop('PKG_CONFIG_PATH', None) +- os.environ['PKG_CONFIG_LIBDIR'] = pkg_libdir + try: + return PythonPkgConfigDependency(name, env, kwargs, installation, True) + finally: +@@ -288,8 +285,7 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice', + os.environ[name] = value + elif name in os.environ: + del os.environ[name] +- set_env('PKG_CONFIG_LIBDIR', old_pkg_libdir) +- set_env('PKG_CONFIG_PATH', old_pkg_path) ++ pass + + candidates.append(functools.partial(wrap_in_pythons_pc_dir, pkg_name, env, kwargs, installation)) + # We only need to check both, if a python install has a LIBPC. It might point to the wrong location, diff --git a/meta-digi-dey/recipes-devtools/meson/meson/0002-Support-building-allarch-recipes-again.patch b/meta-digi-dey/recipes-devtools/meson/meson/0002-Support-building-allarch-recipes-again.patch new file mode 100644 index 000000000..dcc1ce9c2 --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/0002-Support-building-allarch-recipes-again.patch @@ -0,0 +1,28 @@ +From 656bf55fed01df2d2e2ad6d9d9887173cb16b85c Mon Sep 17 00:00:00 2001 +From: Peter Kjellerstedt +Date: Thu, 26 Jul 2018 16:32:49 +0200 +Subject: [PATCH 2/2] Support building allarch recipes again + +This registers "allarch" as a known CPU family. + +Upstream-Status: Inappropriate [OE specific] +Signed-off-by: Peter Kjellerstedt +--- + mesonbuild/envconfig.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py +index 4d58c91..ff01ad1 100644 +--- a/mesonbuild/envconfig.py ++++ b/mesonbuild/envconfig.py +@@ -36,6 +36,7 @@ from pathlib import Path + + + known_cpu_families = ( ++ 'allarch', + 'aarch64', + 'alpha', + 'arc', +-- +2.24.0 + diff --git a/meta-digi-dey/recipes-devtools/meson/meson/meson-setup.py b/meta-digi-dey/recipes-devtools/meson/meson/meson-setup.py new file mode 100755 index 000000000..daaa551de --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/meson-setup.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import os +import string +import sys + +class Template(string.Template): + delimiter = "@" + +class Environ(): + def __getitem__(self, name): + val = os.environ[name] + val = val.split() + if len(val) > 1: + val = ["'%s'" % x for x in val] + val = ', '.join(val) + val = '[%s]' % val + elif val: + val = "'%s'" % val.pop() + return val + +try: + sysroot = os.environ['OECORE_NATIVE_SYSROOT'] +except KeyError: + print("Not in environment setup, bailing") + sys.exit(1) + +template_file = os.path.join(sysroot, 'usr/share/meson/meson.cross.template') +cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ["TARGET_PREFIX"]) +native_template_file = os.path.join(sysroot, 'usr/share/meson/meson.native.template') +native_file = os.path.join(sysroot, 'usr/share/meson/meson.native') + +with open(template_file) as in_file: + template = in_file.read() + output = Template(template).substitute(Environ()) + with open(cross_file, "w") as out_file: + out_file.write(output) + +with open(native_template_file) as in_file: + template = in_file.read() + output = Template(template).substitute({'OECORE_NATIVE_SYSROOT': os.environ['OECORE_NATIVE_SYSROOT']}) + with open(native_file, "w") as out_file: + out_file.write(output) diff --git a/meta-digi-dey/recipes-devtools/meson/meson/meson-wrapper b/meta-digi-dey/recipes-devtools/meson/meson/meson-wrapper new file mode 100755 index 000000000..745598529 --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson/meson-wrapper @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ -z "$OECORE_NATIVE_SYSROOT" ]; then + exec "meson.real" "$@" +fi + +if [ -z "$SSL_CERT_DIR" ]; then + export SSL_CERT_DIR="$OECORE_NATIVE_SYSROOT/etc/ssl/certs/" +fi + +# If these are set to a cross-compile path, meson will get confused and try to +# use them as native tools. Unset them to prevent this, as all the cross-compile +# config is already in meson.cross. +unset CC CXX CPP LD AR NM STRIP + +case "$1" in +setup|configure|dist|install|introspect|init|test|wrap|subprojects|rewrite|compile|devenv|env2mfile|help) MESON_CMD="$1" ;; +*) echo meson-wrapper: Implicit setup command assumed; MESON_CMD=setup ;; +esac + +if [ "$MESON_CMD" = "setup" ]; then + MESON_SETUP_OPTS=" \ + --cross-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/${TARGET_PREFIX}meson.cross" \ + --native-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.native" \ + " + echo meson-wrapper: Running meson with setup options: \"$MESON_SETUP_OPTS\" +fi + +exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \ + "$@" \ + $MESON_SETUP_OPTS diff --git a/meta-digi-dey/recipes-devtools/meson/meson_1.0.1.bb b/meta-digi-dey/recipes-devtools/meson/meson_1.0.1.bb new file mode 100644 index 000000000..6ff0b0745 --- /dev/null +++ b/meta-digi-dey/recipes-devtools/meson/meson_1.0.1.bb @@ -0,0 +1,157 @@ +HOMEPAGE = "http://mesonbuild.com" +SUMMARY = "A high performance build system" +DESCRIPTION = "Meson is a build system designed to increase programmer \ +productivity. It does this by providing a fast, simple and easy to use \ +interface for modern software development tools and practices." + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57" + +GITHUB_BASE_URI = "https://github.com/mesonbuild/meson/releases/" +SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \ + file://meson-setup.py \ + file://meson-wrapper \ + file://0001-python-module-do-not-manipulate-the-environment-when.patch \ + file://0001-Make-CPU-family-warnings-fatal.patch \ + file://0002-Support-building-allarch-recipes-again.patch \ + file://0001-Check-for-clang-before-guessing-gcc-or-lcc.patch \ + " +SRC_URI[sha256sum] = "d926b730de6f518728cc7c57bc5e701667bae0c3522f9e369427b2cc7839d3c1" + +# Removed 'github-releases' as it does not exist on Kirkstone +inherit python_setuptools_build_meta + +RDEPENDS:${PN} = "ninja python3-modules python3-pkg-resources" + +FILES:${PN} += "${datadir}/polkit-1" + +do_install:append () { + # As per the same issue in the python recipe itself: + # Unfortunately the following pyc files are non-deterministc due to 'frozenset' + # being written without strict ordering, even with PYTHONHASHSEED = 0 + # Upstream is discussing ways to solve the issue properly, until then let's + # just not install the problematic files. + # More info: http://benno.id.au/blog/2013/01/15/python-determinism + rm ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython* +} + +BBCLASSEXTEND = "native nativesdk" + +inherit meson-routines + +# The cross file logic is similar but not identical to that in meson.bbclass, +# since it's generating for an SDK rather than a cross-compile. Important +# differences are: +# - We can't set vars like CC, CXX, etc. yet because they will be filled in with +# real paths by meson-setup.sh when the SDK is extracted. +# - Some overrides aren't needed, since the SDK injects paths that take care of +# them. +def var_list2str(var, d): + items = d.getVar(var).split() + return items[0] if len(items) == 1 else ', '.join(repr(s) for s in items) + +def generate_native_link_template(d): + val = ['-L@{OECORE_NATIVE_SYSROOT}${libdir_native}', + '-L@{OECORE_NATIVE_SYSROOT}${base_libdir_native}', + '-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${libdir_native}', + '-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${base_libdir_native}', + '-Wl,--allow-shlib-undefined' + ] + build_arch = d.getVar('BUILD_ARCH') + if 'x86_64' in build_arch: + loader = 'ld-linux-x86-64.so.2' + elif 'i686' in build_arch: + loader = 'ld-linux.so.2' + elif 'aarch64' in build_arch: + loader = 'ld-linux-aarch64.so.1' + elif 'ppc64le' in build_arch: + loader = 'ld64.so.2' + elif 'loongarch64' in build_arch: + loader = 'ld-linux-loongarch-lp64d.so.1' + + if loader: + val += ['-Wl,--dynamic-linker=@{OECORE_NATIVE_SYSROOT}${base_libdir_native}/' + loader] + + return repr(val) + +install_templates() { + install -d ${D}${datadir}/meson + + cat >${D}${datadir}/meson/meson.native.template <${D}${datadir}/meson/meson.cross.template <