From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web12.2752.1596089576787342519 for ; Wed, 29 Jul 2020 23:12:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@babayev.com header.s=google header.b=JtqU51Mc; spf=pass (domain: babayev.com, ip: 209.85.221.65, mailfrom: ruslan@babayev.com) Received: by mail-wr1-f65.google.com with SMTP id a5so13732131wrm.6 for ; Wed, 29 Jul 2020 23:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=babayev.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ifPUGPslYCnVq4W3h8iuNZVAP8HV8LK+Y4juZfDRB/o=; b=JtqU51Mckv+VIOPJnxHNwL8axULOPzNpUQqQu3+qZw9lX4KKGzzJxF/QhGRe+8sd2G EWCeSMcf9Lxcgu2+5P9y1ZaYU6sv3IO5KpCBIj4AyBjr+5jcSF+0dPk80hw2v5SKmGXn nZTEWEYI1kFjg29YKv2ECCASxrYHxgMQ/V4Q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ifPUGPslYCnVq4W3h8iuNZVAP8HV8LK+Y4juZfDRB/o=; b=VlfAGgbC+Y64FJHQsSbTAkY7/ISJpHOauNRitdoP5otR5D779yioYEhCL97gqWlHJH OmSXVqknS1FGLrXcIylfDrxe4o4kMnf7R6F9lBwKvIuMX6ZnlVasFGq4h8f6WPGE7kAh ssRgS2u69dKwQYt6FuJKld4xpUIYW+M75YDjBC+e5X0zxsCsKElUftzIUfzM5k/Yse8G BS6xG47CpOqho1Jh4VWHUSx07cez9gGZo5PBbVC9U4fBPvJixzAb/XpYZFRVigdeFBDD g6r0uDo64ycWTCSDwI0/c6rBQWQ8kdWtOEwPKx7CIEpKyK1vhHBbRGaXs78EJz6NiDL8 SfoA== X-Gm-Message-State: AOAM533fAlkd6ETtoEEh5aSXgQBAaPDq150Q3ubkDiC/sedSp3VtTWe6 Da9idG7e3c9ZnqBu0jnAMz01IGUZUWf27lC2/Yzn+Q== X-Google-Smtp-Source: ABdhPJwFAzmPXvcvYIZQyhskLQvvG9YGiloY8gMcg9fausHRnc+NapeDMmdZtrCryjLPb/EJ6odjKUwJWqFVWCdk9I0= X-Received: by 2002:adf:eccc:: with SMTP id s12mr36504872wro.157.1596089575211; Wed, 29 Jul 2020 23:12:55 -0700 (PDT) MIME-Version: 1.0 References: <20200726015614.2875-1-ruslan@babayev.com> In-Reply-To: From: "Ruslan Babayev" Date: Wed, 29 Jul 2020 23:12:44 -0700 Message-ID: Subject: Re: [OE-core] [PATCH] meson: use the more specific cpu arch in cross file To: Khem Raj Cc: OE-core Content-Type: multipart/alternative; boundary="0000000000002918de05aba290b4" --0000000000002918de05aba290b4 Content-Type: text/plain; charset="UTF-8" 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 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 > > --- > > 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 > > > > > > > > > > > --0000000000002918de05aba290b4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 cp= u_family=3D'x86-64' cpu=3D'nehalem'.
=C2=A0=C2=A0
Projects using Meson can query for the host_machine.cpu() and expe= ct a more specific CPU type.
Here's one example:



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 sub= type 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 <= br> understand the usecase

> Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
> ---
>=C2=A0 =C2=A0meta/classes/meson.bbclass=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= = =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 14 ++++++++++= ++--
>=C2=A0 =C2=A0.../meson/nativesdk-meson_0.53.2.bb=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 12 +++++++++++-
>=C2=A0 =C2=A02 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass<= br> > index ff52d20e56..0caa7a37c2 100644
> --- a/meta/classes/meson.bbclass
> +++ b/meta/classes/meson.bbclass
> @@ -62,6 +62,16 @@ def meson_cpu_family(var, d):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0else:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return arch
>=C2=A0 =C2=A0
> +def meson_cpu(prefix, d):
> +=C2=A0 =C2=A0 import re
> +=C2=A0 =C2=A0 arch =3D d.getVar(prefix + "_ARCH")
> +=C2=A0 =C2=A0 tune_ccargs =3D d.getVar("TUNE_CCARGS")
> +=C2=A0 =C2=A0 m =3D re.search(r"(?<=3D-march=3D)\w+|(?<= =3D-mcpu=3D)\w+", tune_ccargs)
> +=C2=A0 =C2=A0 if m:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return m.group(0)
> +=C2=A0 =C2=A0 else:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return arch
> +
>=C2=A0 =C2=A0# Map our OS values to what Meson expects:
>=C2=A0 =C2=A0# https://meson= build.com/Reference-tables.html#operating-system-names
>=C2=A0 =C2=A0def meson_operating_system(var, d):
> @@ -110,13 +120,13 @@ gtkdoc_exe_wrapper =3D '${B}/gtkdoc-qemuwra= pper'
>=C2=A0 =C2=A0[host_machine]
>=C2=A0 =C2=A0system =3D '${@meson_operating_system('HOST_OS= 9;, d)}'
>=C2=A0 =C2=A0cpu_family =3D '${@meson_cpu_family('HOST_ARCH= 9;, d)}'
> -cpu =3D '${HOST_ARCH}'
> +cpu =3D '${@meson_cpu('HOST', d)}'
>=C2=A0 =C2=A0endian =3D '${@meson_endian('HOST', d)}'<= br> >=C2=A0 =C2=A0
>=C2=A0 =C2=A0[target_machine]
>=C2=A0 =C2=A0system =3D '${@meson_operating_system('TARGET_OS&= #39;, d)}'
>=C2=A0 =C2=A0cpu_family =3D '${@meson_cpu_family('TARGET_ARCH&= #39;, d)}'
> -cpu =3D '${TARGET_ARCH}'
> +cpu =3D '${@meson_cpu('TARGET', d)}'
>=C2=A0 =C2=A0endian =3D '${@meson_endian('TARGET', d)}'= ;
>=C2=A0 =C2=A0EOF
>=C2=A0 =C2=A0}
> 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
>=C2=A0 =C2=A0SRC_URI +=3D "file://meson-setup.py \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0file://meson-wr= apper"
>=C2=A0 =C2=A0
> +def meson_cpu(var, d):
> +=C2=A0 =C2=A0 import re
> +=C2=A0 =C2=A0 arch =3D d.getVar(var)
> +=C2=A0 =C2=A0 tune_ccargs =3D d.getVar("TUNE_CCARGS")
> +=C2=A0 =C2=A0 m =3D re.search(r"(?<=3D-march=3D)\w+|(?<= =3D-mcpu=3D)\w+", tune_ccargs)
> +=C2=A0 =C2=A0 if m:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return m.group(0)
> +=C2=A0 =C2=A0 else:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return arch
> +
>=C2=A0 =C2=A0def meson_endian(prefix, d):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0arch, os =3D d.getVar(prefix + "_ARCH&= quot;), d.getVar(prefix + "_OS")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0sitedata =3D siteinfo_data_for_machine(arch= , os, d)
> @@ -44,7 +54,7 @@ cpp_link_args =3D @LDFLAGS
>=C2=A0 =C2=A0[host_machine]
>=C2=A0 =C2=A0system =3D '${SDK_OS}'
>=C2=A0 =C2=A0cpu_family =3D '${SDK_ARCH}'
> -cpu =3D '${SDK_ARCH}'
> +cpu =3D '${@meson_cpu("SDK_ARCH", d)}'
>=C2=A0 =C2=A0endian =3D '${@meson_endian("SDK", d)}'=
>=C2=A0 =C2=A0EOF
>=C2=A0 =C2=A0
>
>
>
>
--0000000000002918de05aba290b4--