Skip to content

Commit 0a4b87d

Browse files
authored
[compiler-rt][lit] Check glibc version without external packages (#158387)
Alternative to #158236 without requiring external packages
1 parent ed16523 commit 0a4b87d

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

compiler-rt/test/lit.common.cfg.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -708,31 +708,7 @@ def get_macos_aligned_version(macos_vers):
708708
config.substitutions.append(("%push_to_device", "echo "))
709709
config.substitutions.append(("%adb_shell", "echo "))
710710

711-
if config.target_os == "Linux":
712-
def add_glibc_versions(ver_string):
713-
if config.android:
714-
return
715-
716-
from distutils.version import LooseVersion
717-
718-
ver = LooseVersion(ver_string)
719-
any_glibc = False
720-
for required in [
721-
"2.19",
722-
"2.27",
723-
"2.30",
724-
"2.33",
725-
"2.34",
726-
"2.37",
727-
"2.38",
728-
"2.40",
729-
]:
730-
if ver >= LooseVersion(required):
731-
config.available_features.add("glibc-" + required)
732-
any_glibc = True
733-
if any_glibc:
734-
config.available_features.add("glibc")
735-
711+
if config.target_os == "Linux" and not config.android:
736712
# detect whether we are using glibc, and which version
737713
cmd_args = [
738714
config.clang.strip(),
@@ -754,7 +730,27 @@ def add_glibc_versions(ver_string):
754730
try:
755731
sout, _ = cmd.communicate(b"#include <features.h>")
756732
m = dict(re.findall(r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)", str(sout)))
757-
add_glibc_versions(f"{m['__GLIBC__']}.{m['__GLIBC_MINOR__']}")
733+
major = int(m["__GLIBC__"])
734+
minor = int(m["__GLIBC_MINOR__"])
735+
any_glibc = False
736+
for required in [
737+
(2, 19),
738+
(2, 27),
739+
(2, 30),
740+
(2, 33),
741+
(2, 34),
742+
(2, 37),
743+
(2, 38),
744+
(2, 40),
745+
]:
746+
if (major, minor) >= required:
747+
(required_major, required_minor) = required
748+
config.available_features.add(
749+
f"glibc-{required_major}.{required_minor}"
750+
)
751+
any_glibc = True
752+
if any_glibc:
753+
config.available_features.add("glibc")
758754
except:
759755
pass
760756

0 commit comments

Comments
 (0)