@@ -612,8 +612,8 @@ def try_check_compiler(cc, lang):
612
612
613
613
values = (proc.communicate()[0].split() + [' 0' ] * 7)[0:7]
614
614
is_clang = values[0] == ' 1'
615
- gcc_version = ' %s.%s.%s ' % tuple(values[1:1+3])
616
- clang_version = ' %s.%s.%s ' % tuple(values[4:4+3])
615
+ gcc_version = tuple(values[1:1+3])
616
+ clang_version = tuple(values[4:4+3])
617
617
618
618
return (True, is_clang, clang_version, gcc_version)
619
619
@@ -691,6 +691,18 @@ def get_gas_version(cc):
691
691
else:
692
692
return ' 0'
693
693
694
+ # Compares (major, min, patch) version tuples
695
+ def less_than(a, b):
696
+ if a[0] < b[0]:
697
+ return True
698
+ elif a[0] == b[0] and a[1] < b[1]:
699
+ return True
700
+ elif a[0] == b[0] and a[1] == b[1] and a[2] < b[2]:
701
+ return True
702
+ else:
703
+ return False
704
+
705
+
694
706
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
695
707
# the version check more by accident than anything else but a more rigorous
696
708
# check involves checking the build number against a whitelist. I'm not
@@ -707,13 +719,13 @@ def check_compiler(o):
707
719
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, ' c++' )
708
720
if not ok:
709
721
warn(' failed to autodetect C++ compiler version (CXX=%s)' % CXX)
710
- elif clang_version < ' 3.4.2 ' if is_clang else gcc_version < ' 4.9.4 ' :
722
+ elif less_than( clang_version, (3, 4, 2)) if is_clang else less_than( gcc_version, (4, 9, 4)) :
711
723
warn(' C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=%s)' % CXX)
712
724
713
725
ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, ' c' )
714
726
if not ok:
715
727
warn(' failed to autodetect C compiler version (CC=%s)' % CC)
716
- elif not is_clang and gcc_version < ' 4.2.0 ' :
728
+ elif not is_clang and less_than( gcc_version, (4, 2, 0)) :
717
729
# clang 3.2 is a little white lie because any clang version will probably
718
730
# do for the C bits. However, we might as well encourage people to upgrade
719
731
# to a version that is not completely ancient.
0 commit comments