forked from OSchip/llvm-project
[compiler-rt][test] Make glibc-* feature detection work on a musl distribution
... where `ldd --version` has empty stdout and non-empty stderr.
This commit is contained in:
parent
0b56e3cdda
commit
99d650b369
|
@ -380,15 +380,15 @@ else:
|
||||||
|
|
||||||
if config.host_os == 'Linux':
|
if config.host_os == 'Linux':
|
||||||
# detect whether we are using glibc, and which version
|
# detect whether we are using glibc, and which version
|
||||||
# NB: 'ldd' is just one of the tools commonly installed as part of glibc
|
# NB: 'ldd' is just one of the tools commonly installed as part of glibc/musl
|
||||||
ldd_ver_cmd = subprocess.Popen(['ldd', '--version'],
|
ldd_ver_cmd = subprocess.Popen(['ldd', '--version'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
env={'LANG': 'C'})
|
env={'LANG': 'C'})
|
||||||
sout, _ = ldd_ver_cmd.communicate()
|
sout, _ = ldd_ver_cmd.communicate()
|
||||||
ver_line = sout.splitlines()[0]
|
ver_lines = sout.splitlines()
|
||||||
if not config.android and ver_line.startswith(b"ldd "):
|
if not config.android and len(ver_lines) and ver_lines[0].startswith(b"ldd "):
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
ver = LooseVersion(ver_line.split()[-1].decode())
|
ver = LooseVersion(ver_lines[0].split()[-1].decode())
|
||||||
for required in ["2.27", "2.30"]:
|
for required in ["2.27", "2.30"]:
|
||||||
if ver >= LooseVersion(required):
|
if ver >= LooseVersion(required):
|
||||||
config.available_features.add("glibc-" + required)
|
config.available_features.add("glibc-" + required)
|
||||||
|
|
Loading…
Reference in New Issue