[compiler-rt] 0a4b87d - [compiler-rt][lit] Check glibc version without external packages (#158387)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 09:21:28 PDT 2025


Author: Arthur Eubanks
Date: 2025-09-15T09:21:23-07:00
New Revision: 0a4b87dac476f525e1d9bd0cf6dafb743a2d8245

URL: https://github.com/llvm/llvm-project/commit/0a4b87dac476f525e1d9bd0cf6dafb743a2d8245
DIFF: https://github.com/llvm/llvm-project/commit/0a4b87dac476f525e1d9bd0cf6dafb743a2d8245.diff

LOG: [compiler-rt][lit] Check glibc version without external packages (#158387)

Alternative to #158236 without requiring external packages

Added: 
    

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

Removed: 
    


################################################################################
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 <features.h>")
         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
 


        


More information about the llvm-commits mailing list