meson: Allow user to override setup command options
PATCH v6 1/6 meson: Allow user to override setup command options
The user cannot override the setup command options --cross-file and --native-file because the meson-wrapper places these options on the command line after the user options. This problem was noticed when trying to build with an SDK using a custom cross-file.
--- meta/recipes-devtools/meson/meson/meson-wrapper | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
meta/recipes-devtools/meson/meson/meson-wrapper +11 -4
@@ -14,8 +14,14 @@ fi 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 ;; +setup|configure|dist|install|introspect|init|test|wrap|subprojects|rewrite|compile|devenv|env2mfile|help) + MESON_CMD="$1" + shift + ;; +*) + MESON_CMD=setup + echo meson-wrapper: Implicit setup command assumed + ;; esac if [ "$MESON_CMD" = "setup" ]; then
@@ -27,5 +33,6 @@ if [ "$MESON_CMD" = "setup" ]; then fi exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \ - "$@" \ - $MESON_SETUP_OPTS + $MESON_CMD \ + $MESON_SETUP_OPTS \ + "$@"
Signature · 1 line
2.34.1
PATCH v6 2/6 toolchain-scripts: Add Meson settings for Yocto build SDK
The Meson settings for the standalone SDK also need to be available for the Yocto build SDK, a.k.a. meta-ide-support.
--- meta/classes-recipe/toolchain-scripts.bbclass | 2 ++ 1 file changed, 2 insertions(+)
meta/classes-recipe/toolchain-scripts.bbclass +2 -0
@@ -99,6 +99,8 @@ toolchain_create_tree_env_script () { echo 'export OECORE_BASELIB="${baselib}"' >> $script echo 'export OECORE_TARGET_ARCH="${TARGET_ARCH}"' >>$script echo 'export OECORE_TARGET_OS="${TARGET_OS}"' >>$script + echo 'export OECORE_TARGET_BITS="${@siteinfo_with_prefix(d, 'bit-')}"' >>$script + echo 'export OECORE_TARGET_ENDIAN="${@siteinfo_with_prefix(d, 'endian-')}"' >>$script toolchain_shared_env_script
Signature · 1 line
2.34.1
PATCH v6 3/6 toolchain-scripts: Export meson settings for SDK builds
In reply to Tom HochsteinCreate a new set of exports for the Meson host_machine cross settings. This allows the target cross file to be created correctly from meson.cross.template and aligns with meson.bbclass.
Note, one might think that HOST_OS and HOST_ARCH would be appropriate as inputs here, aligning nicely with the Meson naming. That turns out to be incorrect since the script is generated in a native/nativesdk build with HOST_OS and HOST_ARCH set for the "build machine", not the "host machine", using the Meson terminology. See
https://mesonbuild.com/Cross-compilation.html.
--- meta/classes-recipe/toolchain-scripts.bbclass | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
meta/classes-recipe/toolchain-scripts.bbclass +9 -1
@@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT # -inherit toolchain-scripts-base siteinfo kernel-arch +inherit toolchain-scripts-base siteinfo kernel-arch meson-routines # We want to be able to change the value of MULTIMACH_TARGET_SYS, because it # doesn't always match our expectations... but we default to the stock value
@@ -72,6 +72,10 @@ toolchain_create_sdk_env_script () { echo 'export OECORE_TARGET_OS="${TARGET_OS}"' >>$script echo 'export OECORE_TARGET_BITS="${@siteinfo_with_prefix(d, 'bit-')}"' >>$script echo 'export OECORE_TARGET_ENDIAN="${@siteinfo_with_prefix(d, 'endian-')}"' >>$script + echo 'export OECORE_MESON_HOST_SYSTEM="${@meson_operating_system('TARGET_OS', d)}"' >>$script + echo 'export OECORE_MESON_HOST_CPU_FAMILY="${@meson_cpu_family('TARGET_ARCH', d)}"' >>$script + echo 'export OECORE_MESON_HOST_CPU="${TARGET_ARCH}"' >>$script + echo 'export OECORE_MESON_HOST_ENDIAN="${@meson_endian('TARGET', d)}"' >>$script echo 'unset command_not_found_handle' >> $script
@@ -101,6 +105,10 @@ toolchain_create_tree_env_script () { echo 'export OECORE_TARGET_OS="${TARGET_OS}"' >>$script echo 'export OECORE_TARGET_BITS="${@siteinfo_with_prefix(d, 'bit-')}"' >>$script echo 'export OECORE_TARGET_ENDIAN="${@siteinfo_with_prefix(d, 'endian-')}"' >>$script + echo 'export OECORE_MESON_HOST_SYSTEM="${@meson_operating_system('TARGET_OS', d)}"' >>$script + echo 'export OECORE_MESON_HOST_CPU_FAMILY="${@meson_cpu_family('TARGET_ARCH', d)}"' >>$script + echo 'export OECORE_MESON_HOST_CPU="${TARGET_ARCH}"' >>$script + echo 'export OECORE_MESON_HOST_ENDIAN="${@meson_endian('TARGET', d)}"' >>$script toolchain_shared_env_script
Signature · 1 line
2.34.1
PATCH v6 4/6 meson: Fix host_machine setting for native cross-file
In reply to Tom HochsteinFor native and nativesdk, the meson cross-file settings for host_machine are incorrectly set for the build machine, not the "machine on which the compiled binary will run". See
https://mesonbuild.com/Cross-compilation.html.
--- meta/recipes-devtools/meson/meson_1.7.2.bb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
meta/recipes-devtools/meson/meson_1.7.2.bb +4 -12
@@ -107,18 +107,14 @@ needs_exe_wrapper = true sys_root = @OECORE_TARGET_SYSROOT [host_machine] -system = '$host_system' -cpu_family = '$host_cpu_family' -cpu = '$host_cpu' -endian = '$host_endian' +system = @OECORE_MESON_HOST_SYSTEM +cpu_family = @OECORE_MESON_HOST_CPU_FAMILY +cpu = @OECORE_MESON_HOST_CPU +endian = @OECORE_MESON_HOST_ENDIAN EOF } do_install:append:class-nativesdk() { - host_system=${SDK_OS} - host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)} - host_cpu=${SDK_ARCH} - host_endian=${@meson_endian("SDK", d)} install_templates install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
@@ -132,10 +128,6 @@ do_install:append:class-nativesdk() { FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}" do_install:append:class-native() { - host_system=${HOST_OS} - host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)} - host_cpu=${HOST_ARCH} - host_endian=${@meson_endian("HOST", d)} install_templates install -d ${D}${datadir}/post-relocate-setup.d
Signature · 1 line
2.34.1
PATCH v6 5/6 oeqa/sdk/meson: improve test to validate host/build target assignments
In reply to Tom HochsteinFrom: Ross Burton <[email protected]>
Use 'meson introspect' to dump JSON describing the build configuration and validate that the build and host architectures are correctly set in the meson.cross file.
Also instead of calling ninja directly, call the relevant meson commands.
--- meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
meta/lib/oeqa/sdk/cases/meson.py +13 -5
@@ -4,6 +4,7 @@ # SPDX-License-Identifier: MIT # +import json import os import subprocess import tempfile
@@ -39,10 +40,17 @@ class MesonTest(OESDKTestCase): self.assertTrue(os.path.isdir(dirs["source"])) os.makedirs(dirs["build"]) - log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs)) - # Check that Meson thinks we're doing a cross build and not a native - self.assertIn("Build type: cross build", log) - self._run("ninja -C {build} -v".format(**dirs)) - self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs)) + log = self._run("meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs)) + + # Check that the host (gcc) and build (cross-gcc) compilers are different + data = json.loads(self._run("meson introspect --compilers {build}".format(**dirs))) + self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"]) + # Check that the system architectures were set correctly + data = json.loads(self._run("meson introspect --machines {build}".format(**dirs))) + self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"]) + self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"]) + + self._run("meson compile -C {build} -v".format(**dirs)) + self._run("meson install -C {build} --destdir {install}".format(**dirs)) self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))
Signature · 1 line
2.34.1
Re: [OE-core] [PATCH v6 5/6] oeqa/sdk/meson: improve test to validate host/build target assignments
Quoted 6 lines · Tom Hochstein via lists.openembedded.org
From: Ross Burton <[email protected]>
Use 'meson introspect' to dump JSON describing the build configuration and validate that the build and host architectures are correctly set in the meson.cross file.
Quoted 6 lines
Also instead of calling ninja directly, call the relevant meson commands.
Fixes [YOCTO #15485]Signed-off-by Ross Burton <[email protected]>Signed-off-by Tom Hochstein <[email protected]>---
Hi Tom,
Thanks for the new version, but we still have a failure. Same error I believe:
Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/genericarm64/build/meta/lib/oeqa/sdk/cases/meson.py", line 52, in test_epoxy
self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
KeyError: 'c'
https://autobuilder.yoctoproject.org/valkyrie/#/builders/60/builds/1384
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v6 6/6 oeqa/sdk/meson: Skip test when SDK arch != build machine arch
In reply to Tom HochsteinThe SDK Meson test fails when the SDK is not for the build machine:
```
Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
~~~~~~~~~~~~~^^^^^
KeyError: 'c'
```Skip the test in this case.
--- meta/lib/oeqa/sdk/cases/meson.py | 5 +++++ 1 file changed, 5 insertions(+)
meta/lib/oeqa/sdk/cases/meson.py +5 -0
@@ -27,6 +27,11 @@ class MesonTest(OESDKTestCase): self.tc.hasHostPackage("meson-native")): raise unittest.SkipTest("MesonTest: needs meson") + sdk_arch = self.td["SDK_ARCH"] + build_arch = self._run("uname -m").strip() + if not sdk_arch == build_arch: + raise unittest.SkipTest("MesonTest: SDK arch '%s' not valid for build machine arch '%s'" % (sdk_arch, build_arch)) + def test_epoxy(self): with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz")
Signature · 1 line
2.34.1
Re: [OE-core] [PATCH v6 6/6] oeqa/sdk/meson: Skip test when SDK arch != build machine arch
Quoted 9 lines · Tom Hochstein via lists.openembedded.org
The SDK Meson test fails when the SDK is not for the build machine:
``` Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"]) ~~~~~~~~~~~~~^^^^^ KeyError: 'c' ```
Quoted 6 lines
Skip the test in this case.
Signed-off-by Tom Hochstein <[email protected]>---
meta/lib/oeqa/sdk/cases/meson.py | 5 +++++1 file changed, 5 insertions(+)
I think this may not be quite right as I saw:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/42/builds/1370
in my build with this series applied.
Cheers,
Richard
Re: [OE-core] [PATCH v6 6/6] oeqa/sdk/meson: Skip test when SDK arch != build machine arch
Quoted 21 lines · Richard Purdie
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 9 lines · Tom Hochstein via lists.openembedded.org
The SDK Meson test fails when the SDK is not for the build machine:
``` Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"]) ~~~~~~~~~~~~~^^^^^ KeyError: 'c' ```Quoted 6 lines
Skip the test in this case.
Signed-off-by Tom Hochstein <[email protected]>--- meta/lib/oeqa/sdk/cases/meson.py | 5 +++++ 1 file changed, 5 insertions(+)I think this may not be quite right as I saw:
Quoted 7 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/42/builds/1370
in my build with this series applied.
Cheers,
Richard
Thanks, Richard. I'm able to reproduce this. It's specific to meta-ide-support.
The setup looks fine:
$ meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false build meson-wrapper: Running meson with setup options: " --cross-file=.../poky/build/tmp/sysroots/x86_64/usr/share/meson/arm-poky-linux-gnueabi-meson.cross --native-file=.../poky/build/tmp/sysroots/x86_64/usr/share/meson/meson.native " The Meson build system Version: 1.7.2 ...
The KeyError appears because the build machine data is empty:
$ meson introspect -i --compilers build
{
"host": {
"c": {
"id": "gcc",
"exelist": [
"arm-poky-linux-gnueabi-gcc",
"-mthumb",
"-mfpu=neon",
"-mfloat-abi=hard",
"-mcpu=cortex-a15",
"-fstack-protector-strong",
"-O2",
"-D_FORTIFY_SOURCE=2",
"-Wformat",
"-Wformat-security",
"-Werror=format-security",
"-D_TIME_BITS=64",
"-D_FILE_OFFSET_BITS=64",
"--sysroot=.../poky/build/tmp/sysroots/qemuarm"
],
"linker_exelist": [
"arm-poky-linux-gnueabi-gcc",
"-mthumb",
"-mfpu=neon",
"-mfloat-abi=hard",
"-mcpu=cortex-a15",
"-fstack-protector-strong",
"-O2",
"-D_FORTIFY_SOURCE=2",
"-Wformat",
"-Wformat-security",
"-Werror=format-security",
"-D_TIME_BITS=64",
"-D_FILE_OFFSET_BITS=64",
"--sysroot=.../poky/build/tmp/sysroots/qemuarm"
],
"file_suffixes": [
"c"
],
"default_suffix": "c",
"version": "14.2.0",
"full_version": "arm-poky-linux-gnueabi-gcc (GCC) 14.2.0",
"linker_id": "ld.bfd"
}
},
"build": {}
}I don't understand why. The meson.native file looks the same as for the standalone SDK case, and the meson machine data seems fine.
$ meson introspect -i --machines build/
{
"host": {
"system": "linux",
"cpu_family": "arm",
"cpu": "arm",
"endian": "little",
"kernel": null,
"subsystem": null,
"is_64_bit": false,
"exe_suffix": "",
"object_suffix": "o"
},
"build": {
"system": "linux",
"cpu_family": "x86_64",
"cpu": "x86_64",
"endian": "little",
"kernel": "linux",
"subsystem": "linux",
"is_64_bit": true,
"exe_suffix": "",
"object_suffix": "o"
},
"target": {
"system": "linux",
"cpu_family": "arm",
"cpu": "arm",
"endian": "little",
"kernel": null,
"subsystem": null,
"is_64_bit": false,
"exe_suffix": "",
"object_suffix": "o"
}
}I'm stuck.
Tom
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [OE-core] [PATCH v6 6/6] oeqa/sdk/meson: Skip test when SDK arch != build machine arch
Quoted 35 lines · Tom Hochstein via lists.openembedded.org
Quoted 21 lines · Richard Purdie
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 9 lines · Tom Hochstein via lists.openembedded.org
The SDK Meson test fails when the SDK is not for the build machine:
``` Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"]) ~~~~~~~~~~~~~^^^^^ KeyError: 'c' ```Quoted 6 lines
Skip the test in this case.
Signed-off-by Tom Hochstein <[email protected]>---
meta/lib/oeqa/sdk/cases/meson.py| 5 +++++1 file changed, 5 insertions(+)I think this may not be quite right as I saw:
Quoted 7 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/42/builds/1370
in my build with this series applied.
Cheers,
Richard
Thanks, Richard. I'm able to reproduce this. It's specific to meta-ide-support.
The setup looks fine:
Quoted 8 lines
$ meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false build meson-wrapper: Running meson with setup options: " --cross-file=.../poky/build/tmp/sysroots/x86_64/usr/share/meson/arm-poky-linux-gnueabi-meson.cross --native-file=.../poky/build/tmp/sysroots/x86_64/usr/share/meson/meson.native " The Meson build system Version: 1.7.2 ...The KeyError appears because the build machine data is empty:
This assertion turns out to be wrong. In fact, the build machine data is empty in the working case as well. I propose to drop this part of the new test, as the remaining part of the test seems sufficient.
Quoted 103 lines
$ meson introspect -i --compilers build { "host": { "c": { "id": "gcc", "exelist": [ "arm-poky-linux-gnueabi-gcc", "-mthumb", "-mfpu=neon", "-mfloat-abi=hard", "-mcpu=cortex-a15", "-fstack-protector-strong", "-O2", "-D_FORTIFY_SOURCE=2", "-Wformat", "-Wformat-security", "-Werror=format-security", "-D_TIME_BITS=64", "-D_FILE_OFFSET_BITS=64", "--sysroot=.../poky/build/tmp/sysroots/qemuarm" ], "linker_exelist": [ "arm-poky-linux-gnueabi-gcc", "-mthumb", "-mfpu=neon", "-mfloat-abi=hard", "-mcpu=cortex-a15", "-fstack-protector-strong", "-O2", "-D_FORTIFY_SOURCE=2", "-Wformat", "-Wformat-security", "-Werror=format-security", "-D_TIME_BITS=64", "-D_FILE_OFFSET_BITS=64", "--sysroot=.../poky/build/tmp/sysroots/qemuarm" ], "file_suffixes": [ "c" ], "default_suffix": "c", "version": "14.2.0", "full_version": "arm-poky-linux-gnueabi-gcc (GCC) 14.2.0", "linker_id": "ld.bfd" } }, "build": {} }I don't understand why. The meson.native file looks the same as for the standalone SDK case, and the meson machine data seems fine.
$ meson introspect -i --machines build/ { "host": { "system": "linux", "cpu_family": "arm", "cpu": "arm", "endian": "little", "kernel": null, "subsystem": null, "is_64_bit": false, "exe_suffix": "", "object_suffix": "o" }, "build": { "system": "linux", "cpu_family": "x86_64", "cpu": "x86_64", "endian": "little", "kernel": "linux", "subsystem": "linux", "is_64_bit": true, "exe_suffix": "", "object_suffix": "o" }, "target": { "system": "linux", "cpu_family": "arm", "cpu": "arm", "endian": "little", "kernel": null, "subsystem": null, "is_64_bit": false, "exe_suffix": "", "object_suffix": "o" } }I'm stuck.
Tom
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#215000): https://lists.openembedded.org/g/openembedded-core/message/215000
Mute This Topic: https://lists.openembedded.org/mt/112214633/3617670
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-