All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denys Dmytriyenko <denis@denix.org>
To: Sumit Garg <sumit.garg@linaro.org>
Cc: meta-arm@lists.yoctoproject.org, jon.mason@arm.com,
	ross.burton@arm.com, daniel.thompson@linaro.org
Subject: Re: [PATCH v2 1/2] external-arm-toolchain-versions: Use ldd to get libc version
Date: Fri, 29 Apr 2022 12:08:26 -0400	[thread overview]
Message-ID: <20220429160826.GO9834@denix.org> (raw)
In-Reply-To: <20220429062142.11206-1-sumit.garg@linaro.org>

On Fri, Apr 29, 2022 at 11:51:41AM +0530, Sumit Garg wrote:
> Arm GCC 11.2 binary release has moved away from keeping libc library
> versioning info as libc-{EAT_VER_LIBC}.so. So rather switch to
> retrieving libc version by parsing output from "$ ldd --version".
> 
> Signed-off-by: Sumit Garg <sumit.garg@linaro.org>

Reviewed-by: Denys Dmytriyenko <denis@denix.org>


> ---
> 
> Changes in v2:
> - Directly invoke interpreter (/bin/sh) rather than sed-in-place ldd
>   executable which can lead to permissions issue.
> 
>  .../external-arm-toolchain-versions.inc       | 41 +++++++------------
>  1 file changed, 15 insertions(+), 26 deletions(-)
> 
> diff --git a/meta-arm-toolchain/conf/distro/include/external-arm-toolchain-versions.inc b/meta-arm-toolchain/conf/distro/include/external-arm-toolchain-versions.inc
> index a89f2f0..244de26 100644
> --- a/meta-arm-toolchain/conf/distro/include/external-arm-toolchain-versions.inc
> +++ b/meta-arm-toolchain/conf/distro/include/external-arm-toolchain-versions.inc
> @@ -50,37 +50,26 @@ def eat_get_gcc_version(d):
>  
>  def eat_get_libc_version(d):
>      import os,bb
> +    import subprocess
> +
>      syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${EAT_TARGET_SYS}', d)
>      if not syspath:
>          return 'UNKNOWN'
>  
> -    libpath = syspath + '/libc/' + bb.data.expand('${EAT_LIBDIR}/${EAT_TARGET_SYS}/', d)
> -
> -    if os.path.exists(libpath):
> -        for file in os.listdir(libpath):
> -            if file.find('libc-') == 0:
> -                return file[5:-3]
> -
> -    libpath = syspath + '/libc/' + bb.data.expand('${EAT_LIBDIR}/', d)
> -
> -    if os.path.exists(libpath):
> -        for file in os.listdir(libpath):
> -            if file.find('libc-') == 0:
> -                return file[5:-3]
> -
> -    libpath = syspath + '/libc/usr/' + bb.data.expand('${EAT_LIBDIR}/${EAT_TARGET_SYS}/', d)
> -
> -    if os.path.exists(libpath):
> -        for file in os.listdir(libpath):
> -            if file.find('libc-') == 0:
> -                return file[5:-3]
> -
> -    libpath = syspath + '/libc/usr/' + bb.data.expand('${EAT_LIBDIR}/', d)
> +    topdir = d.getVar('TOPDIR', True)
> +    lddpath = syspath + '/libc/usr/bin/ldd'
> +
> +    if os.path.exists(lddpath):
> +        cmd = '/bin/sh ' + lddpath + ' --version'
> +        try:
> +            stdout, stderr = bb.process.run(cmd, cwd=topdir, stderr=subprocess.PIPE)
> +        except bb.process.CmdError as exc:
> +            bb.error('Failed to obtain external Arm libc version: %s' % exc)
> +            return 'UNKNOWN'
> +        else:
> +            first_line = stdout.splitlines()[0]
> +            return first_line.split()[2]
>  
> -    if os.path.exists(libpath):
> -        for file in os.listdir(libpath):
> -            if file.find('libc-') == 0:
> -                return file[5:-3]
>      return 'UNKNOWN'
>  
>  def eat_get_kernel_version(d):
> -- 
> 2.25.1
> 

-- 
Regards,
Denys Dmytriyenko <denis@denix.org>
PGP: 0x420902729A92C964 - https://denix.org/0x420902729A92C964
Fingerprint: 25FC E4A5 8A72 2F69 1186  6D76 4209 0272 9A92 C964


      parent reply	other threads:[~2022-04-29 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29  6:21 [PATCH v2 1/2] external-arm-toolchain-versions: Use ldd to get libc version Sumit Garg
2022-04-29  6:21 ` [PATCH v2 2/2] external-arm-toolchain: Add support for Arm GCC 11.2 binary release Sumit Garg
2022-04-29 16:10   ` Denys Dmytriyenko
2022-05-03  9:27   ` Ross Burton
2022-05-03 12:37     ` Sumit Garg
2022-05-03 15:24       ` Denys Dmytriyenko
2022-04-29 16:08 ` Denys Dmytriyenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429160826.GO9834@denix.org \
    --to=denis@denix.org \
    --cc=daniel.thompson@linaro.org \
    --cc=jon.mason@arm.com \
    --cc=meta-arm@lists.yoctoproject.org \
    --cc=ross.burton@arm.com \
    --cc=sumit.garg@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.