Message ID | 20220429062142.11206-1-sumit.garg@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v2,1/2] external-arm-toolchain-versions: Use ldd to get libc version | expand |
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 >
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):
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(-)