@@ -708,31 +708,7 @@ def get_macos_aligned_version(macos_vers):
708
708
config .substitutions .append (("%push_to_device" , "echo " ))
709
709
config .substitutions .append (("%adb_shell" , "echo " ))
710
710
711
- if config .target_os == "Linux" :
712
- def add_glibc_versions (ver_string ):
713
- if config .android :
714
- return
715
-
716
- from distutils .version import LooseVersion
717
-
718
- ver = LooseVersion (ver_string )
719
- any_glibc = False
720
- for required in [
721
- "2.19" ,
722
- "2.27" ,
723
- "2.30" ,
724
- "2.33" ,
725
- "2.34" ,
726
- "2.37" ,
727
- "2.38" ,
728
- "2.40" ,
729
- ]:
730
- if ver >= LooseVersion (required ):
731
- config .available_features .add ("glibc-" + required )
732
- any_glibc = True
733
- if any_glibc :
734
- config .available_features .add ("glibc" )
735
-
711
+ if config .target_os == "Linux" and not config .android :
736
712
# detect whether we are using glibc, and which version
737
713
cmd_args = [
738
714
config .clang .strip (),
@@ -754,7 +730,27 @@ def add_glibc_versions(ver_string):
754
730
try :
755
731
sout , _ = cmd .communicate (b"#include <features.h>" )
756
732
m = dict (re .findall (r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)" , str (sout )))
757
- add_glibc_versions (f"{ m ['__GLIBC__' ]} .{ m ['__GLIBC_MINOR__' ]} " )
733
+ major = int (m ["__GLIBC__" ])
734
+ minor = int (m ["__GLIBC_MINOR__" ])
735
+ any_glibc = False
736
+ for required in [
737
+ (2 , 19 ),
738
+ (2 , 27 ),
739
+ (2 , 30 ),
740
+ (2 , 33 ),
741
+ (2 , 34 ),
742
+ (2 , 37 ),
743
+ (2 , 38 ),
744
+ (2 , 40 ),
745
+ ]:
746
+ if (major , minor ) >= required :
747
+ (required_major , required_minor ) = required
748
+ config .available_features .add (
749
+ f"glibc-{ required_major } .{ required_minor } "
750
+ )
751
+ any_glibc = True
752
+ if any_glibc :
753
+ config .available_features .add ("glibc" )
758
754
except :
759
755
pass
760
756
0 commit comments