From f6d4005e3d4abdebc7c191c3f0fcaa138418926f Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Sat, 13 Sep 2025 00:48:37 +0000 Subject: [PATCH 1/3] [compiler-rt][lit] Check glibc without external packages Alternative to #158236 without requiring external packages --- compiler-rt/test/lit.common.cfg.py | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index e2e815444dcf9..bbc022127d60d 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -708,27 +708,22 @@ 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) +if config.target_os == "Linux" and not config.android: + def add_glibc_versions(major, minor): any_glibc = False for required in [ - "2.19", - "2.27", - "2.30", - "2.33", - "2.34", - "2.37", - "2.38", - "2.40", + (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) + 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") @@ -754,7 +749,7 @@ 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__']}") + add_glibc_versions(int(m['__GLIBC__']), int(m['__GLIBC_MINOR__'])) except: pass From aefe79b241e48b06616f6ab50c5cb91e92602b5a Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Sat, 13 Sep 2025 00:53:48 +0000 Subject: [PATCH 2/3] remove unnecessary function --- compiler-rt/test/lit.common.cfg.py | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index bbc022127d60d..c9f62dd8bfda8 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -709,25 +709,6 @@ def get_macos_aligned_version(macos_vers): config.substitutions.append(("%adb_shell", "echo ")) if config.target_os == "Linux" and not config.android: - def add_glibc_versions(major, 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") - # detect whether we are using glibc, and which version cmd_args = [ config.clang.strip(), @@ -749,7 +730,25 @@ def add_glibc_versions(major, minor): try: sout, _ = cmd.communicate(b"#include ") m = dict(re.findall(r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)", str(sout))) - add_glibc_versions(int(m['__GLIBC__']), int(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 From f6a994602829caff4bf4f8f85578a531dc46d6a0 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Sat, 13 Sep 2025 01:59:39 +0000 Subject: [PATCH 3/3] format --- compiler-rt/test/lit.common.cfg.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index c9f62dd8bfda8..897f4cd76e21c 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -730,8 +730,8 @@ def get_macos_aligned_version(macos_vers): try: sout, _ = cmd.communicate(b"#include ") m = dict(re.findall(r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)", str(sout))) - major = int(m['__GLIBC__']) - minor = int(m['__GLIBC_MINOR__']) + major = int(m["__GLIBC__"]) + minor = int(m["__GLIBC_MINOR__"]) any_glibc = False for required in [ (2, 19), @@ -745,7 +745,9 @@ def get_macos_aligned_version(macos_vers): ]: if (major, minor) >= required: (required_major, required_minor) = required - config.available_features.add(f"glibc-{required_major}.{required_minor}") + config.available_features.add( + f"glibc-{required_major}.{required_minor}" + ) any_glibc = True if any_glibc: config.available_features.add("glibc")