[compiler-rt] f56309a - [compiler-rt][test] Use packaging.version.Version to compare glibc versions (#142596)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 01:33:08 PDT 2025


Author: David Spickett
Date: 2025-09-11T09:33:04+01:00
New Revision: f56309ac2846e4846d23e97b7bde7f7b286abb92

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

LOG: [compiler-rt][test] Use packaging.version.Version to compare glibc versions (#142596)

Instead of distutils.LooseVersion. distutils was depracated
(https://peps.python.org/pep-0632/) and has been removed in Python 3.12
(https://docs.python.org/3/whatsnew/3.12.html)

> Of note, the distutils package has been removed from the standard library.

packaging's version is able to handle glibc's major.minor:
https://packaging.pypa.io/en/latest/version.html#packaging.version.Version

> For these modules or types, use the standards-defined Python Packaging
Authority packages specified:
> distutils.version — use the packaging package

Relates to https://github.com/llvm/llvm-project/issues/54337

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..7734491310edf 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -713,9 +713,9 @@ def add_glibc_versions(ver_string):
         if config.android:
             return
 
-        from distutils.version import LooseVersion
+        from packaging.version import Version
 
-        ver = LooseVersion(ver_string)
+        ver = Version(ver_string)
         any_glibc = False
         for required in [
             "2.19",
@@ -727,7 +727,7 @@ def add_glibc_versions(ver_string):
             "2.38",
             "2.40",
         ]:
-            if ver >= LooseVersion(required):
+            if ver >= Version(required):
                 config.available_features.add("glibc-" + required)
                 any_glibc = True
             if any_glibc:


        


More information about the llvm-commits mailing list