[compiler-rt] [compiler-rt][lit] Check glibc without external packages (PR #158387)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 17:54:06 PDT 2025


https://github.com/aeubanks updated https://github.com/llvm/llvm-project/pull/158387

>From f6d4005e3d4abdebc7c191c3f0fcaa138418926f Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Sat, 13 Sep 2025 00:48:37 +0000
Subject: [PATCH 1/2] [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 <features.h>")
         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 <aeubanks at google.com>
Date: Sat, 13 Sep 2025 00:53:48 +0000
Subject: [PATCH 2/2] 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 <features.h>")
         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
 



More information about the llvm-commits mailing list