All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] meson: use the more specific cpu arch in cross file
@ 2020-07-26  1:56 Ruslan Babayev
  2020-07-26  2:02 ` ✗ patchtest: failure for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ruslan Babayev @ 2020-07-26  1:56 UTC (permalink / raw)
  To: openembedded-core; +Cc: Ruslan Babayev

'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.

Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
---
 meta/classes/meson.bbclass                         | 14 ++++++++++++--
 .../meson/nativesdk-meson_0.53.2.bb                | 12 +++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index ff52d20e56..0caa7a37c2 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -62,6 +62,16 @@ def meson_cpu_family(var, d):
     else:
         return arch
 
+def meson_cpu(prefix, d):
+    import re
+    arch = d.getVar(prefix + "_ARCH")
+    tune_ccargs = d.getVar("TUNE_CCARGS")
+    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
+    if m:
+        return m.group(0)
+    else:
+        return arch
+
 # Map our OS values to what Meson expects:
 # https://mesonbuild.com/Reference-tables.html#operating-system-names
 def meson_operating_system(var, d):
@@ -110,13 +120,13 @@ gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
 [host_machine]
 system = '${@meson_operating_system('HOST_OS', d)}'
 cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}'
-cpu = '${HOST_ARCH}'
+cpu = '${@meson_cpu('HOST', d)}'
 endian = '${@meson_endian('HOST', d)}'
 
 [target_machine]
 system = '${@meson_operating_system('TARGET_OS', d)}'
 cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}'
-cpu = '${TARGET_ARCH}'
+cpu = '${@meson_cpu('TARGET', d)}'
 endian = '${@meson_endian('TARGET', d)}'
 EOF
 }
diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
index 67add2c25e..021bff0992 100644
--- a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
+++ b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
@@ -6,6 +6,16 @@ inherit siteinfo
 SRC_URI += "file://meson-setup.py \
             file://meson-wrapper"
 
+def meson_cpu(var, d):
+    import re
+    arch = d.getVar(var)
+    tune_ccargs = d.getVar("TUNE_CCARGS")
+    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
+    if m:
+        return m.group(0)
+    else:
+        return arch
+
 def meson_endian(prefix, d):
     arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
     sitedata = siteinfo_data_for_machine(arch, os, d)
@@ -44,7 +54,7 @@ cpp_link_args = @LDFLAGS
 [host_machine]
 system = '${SDK_OS}'
 cpu_family = '${SDK_ARCH}'
-cpu = '${SDK_ARCH}'
+cpu = '${@meson_cpu("SDK_ARCH", d)}'
 endian = '${@meson_endian("SDK", d)}'
 EOF
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* ✗ patchtest: failure for meson: use the more specific cpu arch in cross file
  2020-07-26  1:56 [PATCH] meson: use the more specific cpu arch in cross file Ruslan Babayev
@ 2020-07-26  2:02 ` Patchwork
  2020-07-27 10:52 ` [OE-core] [PATCH] " Ross Burton
  2020-07-30  4:55 ` Khem Raj
  2 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2020-07-26  2:02 UTC (permalink / raw)
  To: Ruslan Babayev; +Cc: openembedded-core

== Series Details ==

Series: meson: use the more specific cpu arch in cross file
Revision: 1
URL   : https://patchwork.openembedded.org/series/25306/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             Series does not apply on top of target branch [test_series_merge_on_head] 
  Suggested fix    Rebase your series on top of targeted branch
  Targeted branch  master (currently at ffa4fa35e1)



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-26  1:56 [PATCH] meson: use the more specific cpu arch in cross file Ruslan Babayev
  2020-07-26  2:02 ` ✗ patchtest: failure for " Patchwork
@ 2020-07-27 10:52 ` Ross Burton
  2020-07-27 19:03   ` Ruslan Babayev
  2020-07-30  4:55 ` Khem Raj
  2 siblings, 1 reply; 8+ messages in thread
From: Ross Burton @ 2020-07-27 10:52 UTC (permalink / raw)
  To: Ruslan Babayev; +Cc: OE-core

On Sun, 26 Jul 2020 at 02:56, Ruslan Babayev <ruslan@babayev.com> wrote:
> 'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.

Can you elaborate here some more?

Ross

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-27 10:52 ` [OE-core] [PATCH] " Ross Burton
@ 2020-07-27 19:03   ` Ruslan Babayev
  2020-07-29 21:04     ` Ruslan Babayev
  0 siblings, 1 reply; 8+ messages in thread
From: Ruslan Babayev @ 2020-07-27 19:03 UTC (permalink / raw)
  To: Ross Burton; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]

Hi Ross,

According to https://mesonbuild.com/Cross-compilation.html

There are two different values for the CPU. The first one is cpu_family. It
is a general type of the CPU. This should have a value from the CPU Family
table <https://mesonbuild.com/Reference-tables.html#cpu-families>. *Note* that
meson does not add el to end cpu_family value for little endian systems.
Big endian and little endian mips are both just mips, with the endian field
set approriately.

The second value is cpu which is a more specific subtype for the CPU.
Typical values for a x86 CPU family might include i386 or i586 and for arm
 family armv5 or armv7hl. Note that CPU type strings are very system
dependent. You might get a different value if you check its value on the
same machine but with different operating systems.
At the moment both 'cpu_family' and 'cpu' are being set to TARGET_ARCH
(like x86_64) in meson cross file.

TUNE_CCARSG usually contains the exact subfamily either as -march= or
-mcpu=

The meson_cpu function will use regex to search for -march and if that's
missing for -mcpu value. If both flags are missing it defaults to
TARGET_ARCH.

Ruslan


On Mon, Jul 27, 2020 at 3:52 AM Ross Burton <ross@burtonini.com> wrote:

> On Sun, 26 Jul 2020 at 02:56, Ruslan Babayev <ruslan@babayev.com> wrote:
> > 'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.
>
> Can you elaborate here some more?
>
> Ross
>

[-- Attachment #2: Type: text/html, Size: 5799 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-27 19:03   ` Ruslan Babayev
@ 2020-07-29 21:04     ` Ruslan Babayev
  0 siblings, 0 replies; 8+ messages in thread
From: Ruslan Babayev @ 2020-07-29 21:04 UTC (permalink / raw)
  To: Ross Burton; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]

Hi Ross,

What do you think of the patch? Any objections to merging it? Do you have
any feedback?

Thanks,
Ruslan

On Mon, Jul 27, 2020 at 12:03 PM Ruslan Babayev <ruslan@babayev.com> wrote:

> Hi Ross,
>
> According to https://mesonbuild.com/Cross-compilation.html
>
> There are two different values for the CPU. The first one is cpu_family.
> It is a general type of the CPU. This should have a value from the CPU
> Family table <https://mesonbuild.com/Reference-tables.html#cpu-families>.
> *Note* that meson does not add el to end cpu_family value for little
> endian systems. Big endian and little endian mips are both just mips,
> with the endian field set approriately.
>
> The second value is cpu which is a more specific subtype for the CPU.
> Typical values for a x86 CPU family might include i386 or i586 and for arm
>  family armv5 or armv7hl. Note that CPU type strings are very system
> dependent. You might get a different value if you check its value on the
> same machine but with different operating systems.
> At the moment both 'cpu_family' and 'cpu' are being set to TARGET_ARCH
> (like x86_64) in meson cross file.
>
> TUNE_CCARSG usually contains the exact subfamily either as -march= or
> -mcpu=
>
> The meson_cpu function will use regex to search for -march and if that's
> missing for -mcpu value. If both flags are missing it defaults to
> TARGET_ARCH.
>
> Ruslan
>
>
> On Mon, Jul 27, 2020 at 3:52 AM Ross Burton <ross@burtonini.com> wrote:
>
>> On Sun, 26 Jul 2020 at 02:56, Ruslan Babayev <ruslan@babayev.com> wrote:
>> > 'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.
>>
>> Can you elaborate here some more?
>>
>> Ross
>>
>

[-- Attachment #2: Type: text/html, Size: 6795 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-26  1:56 [PATCH] meson: use the more specific cpu arch in cross file Ruslan Babayev
  2020-07-26  2:02 ` ✗ patchtest: failure for " Patchwork
  2020-07-27 10:52 ` [OE-core] [PATCH] " Ross Burton
@ 2020-07-30  4:55 ` Khem Raj
  2020-07-30  6:12   ` Ruslan Babayev
  2 siblings, 1 reply; 8+ messages in thread
From: Khem Raj @ 2020-07-30  4:55 UTC (permalink / raw)
  To: Ruslan Babayev, openembedded-core



On 7/25/20 6:56 PM, Ruslan Babayev wrote:
> 'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.
> 

since mcpu/march should provide the right values already, do we need 
this additional logic in meson? dont we get needed settings to meson
already?

perhaps you can describe some missing cases this would address will help 
understand the usecase

> Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
> ---
>   meta/classes/meson.bbclass                         | 14 ++++++++++++--
>   .../meson/nativesdk-meson_0.53.2.bb                | 12 +++++++++++-
>   2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
> index ff52d20e56..0caa7a37c2 100644
> --- a/meta/classes/meson.bbclass
> +++ b/meta/classes/meson.bbclass
> @@ -62,6 +62,16 @@ def meson_cpu_family(var, d):
>       else:
>           return arch
>   
> +def meson_cpu(prefix, d):
> +    import re
> +    arch = d.getVar(prefix + "_ARCH")
> +    tune_ccargs = d.getVar("TUNE_CCARGS")
> +    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
> +    if m:
> +        return m.group(0)
> +    else:
> +        return arch
> +
>   # Map our OS values to what Meson expects:
>   # https://mesonbuild.com/Reference-tables.html#operating-system-names
>   def meson_operating_system(var, d):
> @@ -110,13 +120,13 @@ gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
>   [host_machine]
>   system = '${@meson_operating_system('HOST_OS', d)}'
>   cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}'
> -cpu = '${HOST_ARCH}'
> +cpu = '${@meson_cpu('HOST', d)}'
>   endian = '${@meson_endian('HOST', d)}'
>   
>   [target_machine]
>   system = '${@meson_operating_system('TARGET_OS', d)}'
>   cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}'
> -cpu = '${TARGET_ARCH}'
> +cpu = '${@meson_cpu('TARGET', d)}'
>   endian = '${@meson_endian('TARGET', d)}'
>   EOF
>   }
> diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> index 67add2c25e..021bff0992 100644
> --- a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> +++ b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> @@ -6,6 +6,16 @@ inherit siteinfo
>   SRC_URI += "file://meson-setup.py \
>               file://meson-wrapper"
>   
> +def meson_cpu(var, d):
> +    import re
> +    arch = d.getVar(var)
> +    tune_ccargs = d.getVar("TUNE_CCARGS")
> +    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
> +    if m:
> +        return m.group(0)
> +    else:
> +        return arch
> +
>   def meson_endian(prefix, d):
>       arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
>       sitedata = siteinfo_data_for_machine(arch, os, d)
> @@ -44,7 +54,7 @@ cpp_link_args = @LDFLAGS
>   [host_machine]
>   system = '${SDK_OS}'
>   cpu_family = '${SDK_ARCH}'
> -cpu = '${SDK_ARCH}'
> +cpu = '${@meson_cpu("SDK_ARCH", d)}'
>   endian = '${@meson_endian("SDK", d)}'
>   EOF
>   
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-30  4:55 ` Khem Raj
@ 2020-07-30  6:12   ` Ruslan Babayev
  2020-07-30  8:49     ` Richard Purdie
  0 siblings, 1 reply; 8+ messages in thread
From: Ruslan Babayev @ 2020-07-30  6:12 UTC (permalink / raw)
  To: Khem Raj; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]

Currently we have both cpu_family and cpu set to TARGET_ARCH which is
wrong. As mentioned before cpu is more specific. E.g where
cpu_family='x86-64' cpu='nehalem'.

Projects using Meson can query for the host_machine.cpu() and expect a more
specific CPU type.
Here's one example:
https://github.com/DPDK/dpdk/blob/74f4d6424da1297bd6e83dcb7bd84444ca8c59dd/config/meson.build#L69




On Wed, Jul 29, 2020 at 9:55 PM Khem Raj <raj.khem@gmail.com> wrote:

>
>
> On 7/25/20 6:56 PM, Ruslan Babayev wrote:
> > 'cpu' unlike 'cpu_family' must be a more specific subtype for the CPU.
> >
>
> since mcpu/march should provide the right values already, do we need
> this additional logic in meson? dont we get needed settings to meson
> already?
>
> perhaps you can describe some missing cases this would address will help
> understand the usecase
>
> > Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
> > ---
> >   meta/classes/meson.bbclass                         | 14 ++++++++++++--
> >   .../meson/nativesdk-meson_0.53.2.bb                | 12 +++++++++++-
> >   2 files changed, 23 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
> > index ff52d20e56..0caa7a37c2 100644
> > --- a/meta/classes/meson.bbclass
> > +++ b/meta/classes/meson.bbclass
> > @@ -62,6 +62,16 @@ def meson_cpu_family(var, d):
> >       else:
> >           return arch
> >
> > +def meson_cpu(prefix, d):
> > +    import re
> > +    arch = d.getVar(prefix + "_ARCH")
> > +    tune_ccargs = d.getVar("TUNE_CCARGS")
> > +    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
> > +    if m:
> > +        return m.group(0)
> > +    else:
> > +        return arch
> > +
> >   # Map our OS values to what Meson expects:
> >   # https://mesonbuild.com/Reference-tables.html#operating-system-names
> >   def meson_operating_system(var, d):
> > @@ -110,13 +120,13 @@ gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
> >   [host_machine]
> >   system = '${@meson_operating_system('HOST_OS', d)}'
> >   cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}'
> > -cpu = '${HOST_ARCH}'
> > +cpu = '${@meson_cpu('HOST', d)}'
> >   endian = '${@meson_endian('HOST', d)}'
> >
> >   [target_machine]
> >   system = '${@meson_operating_system('TARGET_OS', d)}'
> >   cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}'
> > -cpu = '${TARGET_ARCH}'
> > +cpu = '${@meson_cpu('TARGET', d)}'
> >   endian = '${@meson_endian('TARGET', d)}'
> >   EOF
> >   }
> > diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> > index 67add2c25e..021bff0992 100644
> > --- a/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> > +++ b/meta/recipes-devtools/meson/nativesdk-meson_0.53.2.bb
> > @@ -6,6 +6,16 @@ inherit siteinfo
> >   SRC_URI += "file://meson-setup.py \
> >               file://meson-wrapper"
> >
> > +def meson_cpu(var, d):
> > +    import re
> > +    arch = d.getVar(var)
> > +    tune_ccargs = d.getVar("TUNE_CCARGS")
> > +    m = re.search(r"(?<=-march=)\w+|(?<=-mcpu=)\w+", tune_ccargs)
> > +    if m:
> > +        return m.group(0)
> > +    else:
> > +        return arch
> > +
> >   def meson_endian(prefix, d):
> >       arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
> >       sitedata = siteinfo_data_for_machine(arch, os, d)
> > @@ -44,7 +54,7 @@ cpp_link_args = @LDFLAGS
> >   [host_machine]
> >   system = '${SDK_OS}'
> >   cpu_family = '${SDK_ARCH}'
> > -cpu = '${SDK_ARCH}'
> > +cpu = '${@meson_cpu("SDK_ARCH", d)}'
> >   endian = '${@meson_endian("SDK", d)}'
> >   EOF
> >
> >
> >
> > 
> >
>

[-- Attachment #2: Type: text/html, Size: 6156 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file
  2020-07-30  6:12   ` Ruslan Babayev
@ 2020-07-30  8:49     ` Richard Purdie
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Purdie @ 2020-07-30  8:49 UTC (permalink / raw)
  To: Ruslan Babayev, Khem Raj; +Cc: OE-core

On Wed, 2020-07-29 at 23:12 -0700, Ruslan Babayev wrote:
> Currently we have both cpu_family and cpu set to TARGET_ARCH which is
> wrong. As mentioned before cpu is more specific. E.g where
> cpu_family='x86-64' cpu='nehalem'.
>   
> Projects using Meson can query for the host_machine.cpu() and expect
> a more specific CPU type.
> Here's one example:
> https://github.com/DPDK/dpdk/blob/74f4d6424da1297bd6e83dcb7bd84444ca8c59dd/config/meson.build#L69 

That logic looks like its basically being used to set -march. We
already set this.

Khem and Ross' question is to find out what is currently breaking that
needs this fix. In general for example, we have a much better idea of
what march should be set to in our uses cases.

Cheers

Richard




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-30  8:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-26  1:56 [PATCH] meson: use the more specific cpu arch in cross file Ruslan Babayev
2020-07-26  2:02 ` ✗ patchtest: failure for " Patchwork
2020-07-27 10:52 ` [OE-core] [PATCH] " Ross Burton
2020-07-27 19:03   ` Ruslan Babayev
2020-07-29 21:04     ` Ruslan Babayev
2020-07-30  4:55 ` Khem Raj
2020-07-30  6:12   ` Ruslan Babayev
2020-07-30  8:49     ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.