All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] external-arm-toolchain-versions: Use ldd to get libc version
@ 2022-04-29  6:21 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:08 ` [PATCH v2 1/2] external-arm-toolchain-versions: Use ldd to get libc version Denys Dmytriyenko
  0 siblings, 2 replies; 7+ messages in thread
From: Sumit Garg @ 2022-04-29  6:21 UTC (permalink / raw)
  To: meta-arm; +Cc: jon.mason, ross.burton, denis, daniel.thompson, Sumit Garg

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>
---

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



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

end of thread, other threads:[~2022-05-03 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 1/2] external-arm-toolchain-versions: Use ldd to get libc version Denys Dmytriyenko

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.