diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index e2e815444dcf9..897f4cd76e21c 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -708,31 +708,7 @@ def get_macos_aligned_version(macos_vers): config.substitutions.append(("%push_to_device", "echo ")) config.substitutions.append(("%adb_shell", "echo ")) -if config.target_os == "Linux": - def add_glibc_versions(ver_string): - if config.android: - return - - from distutils.version import LooseVersion - - ver = LooseVersion(ver_string) - any_glibc = False - for required in [ - "2.19", - "2.27", - "2.30", - "2.33", - "2.34", - "2.37", - "2.38", - "2.40", - ]: - if ver >= LooseVersion(required): - config.available_features.add("glibc-" + required) - any_glibc = True - if any_glibc: - config.available_features.add("glibc") - +if config.target_os == "Linux" and not config.android: # detect whether we are using glibc, and which version cmd_args = [ config.clang.strip(), @@ -754,7 +730,27 @@ def add_glibc_versions(ver_string): try: sout, _ = cmd.communicate(b"#include ") m = dict(re.findall(r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)", str(sout))) - add_glibc_versions(f"{m['__GLIBC__']}.{m['__GLIBC_MINOR__']}") + major = int(m["__GLIBC__"]) + minor = int(m["__GLIBC_MINOR__"]) + any_glibc = False + for required in [ + (2, 19), + (2, 27), + (2, 30), + (2, 33), + (2, 34), + (2, 37), + (2, 38), + (2, 40), + ]: + if (major, minor) >= required: + (required_major, required_minor) = required + config.available_features.add( + f"glibc-{required_major}.{required_minor}" + ) + any_glibc = True + if any_glibc: + config.available_features.add("glibc") except: pass