diff mbox series

[5/9] meson: add back warning when default value for external properties are used

Message ID 20230810162451.1766532-5-ross.burton@arm.com
State New
Headers show
Series [1/9] meson.bbclass: add MESON_TARGET | expand

Commit Message

Ross Burton Aug. 10, 2023, 4:24 p.m. UTC
From: Ross Burton <ross.burton@arm.com>

This is adding back a warning that was removed in the upgrade to Meson
0.58 (cb2a7dcc) as source evolution meant the patch didn't apply.

Meson scripts which want to identify runtime behaviour often use
external properties (meson.get_external_property(), set via the cross
and native files) to define default behaviour if they can't run code at
configure time.

These defaults may or may not be correct, so emit a warning that this is
happening. The recipe should then provide a cross file fragment which
sets the value appropriately.

In the long term I hope to be able to remove this patch as Meson evolves
cc.run() to support fallback values directly, and Meson will log the use
of defaults itself.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../meson/meson/default.patch                 | 24 +++++++++++++++++++
 meta/recipes-devtools/meson/meson_1.1.1.bb    |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 meta/recipes-devtools/meson/meson/default.patch

Comments

Alexandre Belloni Aug. 16, 2023, 6:46 p.m. UTC | #1
Hello,

This causes:

WARNING: glib-2.0-1_2.76.4-r0 do_configure: Meson cross property have_strlcpy used without explicit assignment, defaulting to False

On 10/08/2023 17:24:47+0100, Ross Burton wrote:
> From: Ross Burton <ross.burton@arm.com>
> 
> This is adding back a warning that was removed in the upgrade to Meson
> 0.58 (cb2a7dcc) as source evolution meant the patch didn't apply.
> 
> Meson scripts which want to identify runtime behaviour often use
> external properties (meson.get_external_property(), set via the cross
> and native files) to define default behaviour if they can't run code at
> configure time.
> 
> These defaults may or may not be correct, so emit a warning that this is
> happening. The recipe should then provide a cross file fragment which
> sets the value appropriately.
> 
> In the long term I hope to be able to remove this patch as Meson evolves
> cc.run() to support fallback values directly, and Meson will log the use
> of defaults itself.
> 
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  .../meson/meson/default.patch                 | 24 +++++++++++++++++++
>  meta/recipes-devtools/meson/meson_1.1.1.bb    |  1 +
>  2 files changed, 25 insertions(+)
>  create mode 100644 meta/recipes-devtools/meson/meson/default.patch
> 
> diff --git a/meta/recipes-devtools/meson/meson/default.patch b/meta/recipes-devtools/meson/meson/default.patch
> new file mode 100644
> index 00000000000..60adfc8cf4d
> --- /dev/null
> +++ b/meta/recipes-devtools/meson/meson/default.patch
> @@ -0,0 +1,24 @@
> +Emit a warning if a cross property is used (via meson.get_external_property())
> +without an explicit value being set.
> +
> +All default values should be validated to be sure that they're correct, so if we
> +emit a warning in Meson then meson.bbclass can catch and expose it.
> +
> +This is inappropriate as upstream are thinking about improving how cc.run()
> +handles the cross case.
> +
> +Upstream-Status: Inappropriate
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +
> +diff --git a/mesonbuild/interpreter/mesonmain.py b/mesonbuild/interpreter/mesonmain.py
> +index 01d0029a7..936b03fbf 100644
> +--- a/mesonbuild/interpreter/mesonmain.py
> ++++ b/mesonbuild/interpreter/mesonmain.py
> +@@ -416,6 +416,7 @@ class MesonMain(MesonInterpreterObject):
> +             return self.interpreter.environment.properties[machine][propname]
> +         except KeyError:
> +             if fallback is not None:
> ++                mlog.warning(f"Cross property {propname} is using default value {fallback}")
> +                 return fallback
> +             raise InterpreterException(f'Unknown property for {machine.get_lower_case_name()} machine: {propname}')
> + 
> diff --git a/meta/recipes-devtools/meson/meson_1.1.1.bb b/meta/recipes-devtools/meson/meson_1.1.1.bb
> index 500e13775f4..d017d2dccd9 100644
> --- a/meta/recipes-devtools/meson/meson_1.1.1.bb
> +++ b/meta/recipes-devtools/meson/meson_1.1.1.bb
> @@ -14,6 +14,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \
>             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://default.patch \
>             "
>  SRC_URI[sha256sum] = "d04b541f97ca439fb82fab7d0d480988be4bd4e62563a5ca35fadb5400727b1c"
>  
> -- 
> 2.34.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#185806): https://lists.openembedded.org/g/openembedded-core/message/185806
> Mute This Topic: https://lists.openembedded.org/mt/100666859/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/meson/meson/default.patch b/meta/recipes-devtools/meson/meson/default.patch
new file mode 100644
index 00000000000..60adfc8cf4d
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/default.patch
@@ -0,0 +1,24 @@ 
+Emit a warning if a cross property is used (via meson.get_external_property())
+without an explicit value being set.
+
+All default values should be validated to be sure that they're correct, so if we
+emit a warning in Meson then meson.bbclass can catch and expose it.
+
+This is inappropriate as upstream are thinking about improving how cc.run()
+handles the cross case.
+
+Upstream-Status: Inappropriate
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+
+diff --git a/mesonbuild/interpreter/mesonmain.py b/mesonbuild/interpreter/mesonmain.py
+index 01d0029a7..936b03fbf 100644
+--- a/mesonbuild/interpreter/mesonmain.py
++++ b/mesonbuild/interpreter/mesonmain.py
+@@ -416,6 +416,7 @@ class MesonMain(MesonInterpreterObject):
+             return self.interpreter.environment.properties[machine][propname]
+         except KeyError:
+             if fallback is not None:
++                mlog.warning(f"Cross property {propname} is using default value {fallback}")
+                 return fallback
+             raise InterpreterException(f'Unknown property for {machine.get_lower_case_name()} machine: {propname}')
+ 
diff --git a/meta/recipes-devtools/meson/meson_1.1.1.bb b/meta/recipes-devtools/meson/meson_1.1.1.bb
index 500e13775f4..d017d2dccd9 100644
--- a/meta/recipes-devtools/meson/meson_1.1.1.bb
+++ b/meta/recipes-devtools/meson/meson_1.1.1.bb
@@ -14,6 +14,7 @@  SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \
            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://default.patch \
            "
 SRC_URI[sha256sum] = "d04b541f97ca439fb82fab7d0d480988be4bd4e62563a5ca35fadb5400727b1c"