aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-08-02 16:53:11 -0400
committerJack Lloyd <[email protected]>2017-08-02 16:53:11 -0400
commit5a9b5c2c2f32909ab7963307291827ed7bd2d102 (patch)
treedf15e7f3438c0e4cf519dc67cb92feedc21e6626
parentce2deaef167fbd2073959488880b932efaf024d9 (diff)
parent2ffb60e2ab66a05b4b9c46189aa3ebf7bce46ac3 (diff)
Merge GH #1136 Improvements to compiler runtime checks
-rwxr-xr-xconfigure.py57
-rw-r--r--src/lib/entropy/rdseed/info.txt6
-rw-r--r--src/lib/hash/sha1/sha1_x86/info.txt2
-rw-r--r--src/lib/hash/sha2_32/sha2_32_x86/info.txt2
-rwxr-xr-xsrc/scripts/python_uniitests.py22
5 files changed, 56 insertions, 33 deletions
diff --git a/configure.py b/configure.py
index 4405a6e3f..c123b248d 100755
--- a/configure.py
+++ b/configure.py
@@ -827,20 +827,32 @@ class ModuleInfo(InfoObject):
# Check if module gives explicit compiler dependencies
def supported_compiler(ccinfo, cc_version):
+ if self.cc == []:
+ # no compiler restriction
+ return True
- if self.cc == [] or ccinfo.basename in self.cc:
+ if ccinfo.basename in self.cc:
+ # compiler is supported, independent of version
return True
# Maybe a versioned compiler dep
- if cc_version != None:
- for cc in self.cc:
- with_version = cc.find(':')
- if with_version > 0:
- if cc[0:with_version] == ccinfo.basename:
- min_cc_version = [int(v) for v in cc[with_version+1:].split('.')]
+ for cc in self.cc:
+ try:
+ name, version = cc.split(":")
+ if name == ccinfo.basename:
+ if cc_version:
+ min_cc_version = [int(v) for v in version.split('.')]
cur_cc_version = [int(v) for v in cc_version.split('.')]
# With lists of ints, this does what we want
return cur_cc_version >= min_cc_version
+ else:
+ # Compiler version unknown => module unsupported
+ return False
+ except ValueError:
+ # No version part specified
+ pass
+
+ return False # compiler not listed
return supported_isa_flags(ccinfo, arch) and supported_compiler(ccinfo, cc_version)
@@ -2581,8 +2593,8 @@ class CompilerDetector(object):
}
_version_patterns = {
'msvc': r'^([0-9]{2})([0-9]{2})',
- 'gcc': r'gcc version ([0-9]+\.[0-9]+)\.[0-9]+',
- 'clang': r'clang version ([0-9]+\.[0-9])[ \.]',
+ 'gcc': r'gcc version ([0-9]+)\.([0-9]+)\.[0-9]+',
+ 'clang': r'clang version ([0-9]+)\.([0-9])[ \.]',
}
def __init__(self, cc_name, cc_bin, os_name):
@@ -2615,19 +2627,11 @@ class CompilerDetector(object):
match = re.search(CompilerDetector._version_patterns[self._cc_name], cc_output, flags=re.MULTILINE)
if match:
- if self._cc_name == 'msvc':
- cl_version_to_msvc_version = {
- '18.00': '2013',
- '19.00': '2015',
- '19.10': '2017'
- }
- try:
- cc_version = cl_version_to_msvc_version[match.group(1) + "." + match.group(2)]
- except KeyError:
- raise InternalError('Unknown MSVC version in output "%s"' % (cc_output))
- else:
- cc_version = match.group(1)
- elif match is None and self._cc_name == 'clang' and self._os_name in ['darwin', 'ios']:
+ major = int(match.group(1))
+ minor = int(match.group(2))
+ cc_version = "%d.%d" % (major, minor)
+
+ if cc_version is None and self._cc_name == 'clang' and self._os_name in ['darwin', 'ios']:
xcode_version_to_clang = {
'703': '3.8',
'800': '3.9',
@@ -2635,7 +2639,6 @@ class CompilerDetector(object):
}
match = re.search(r'Apple LLVM version [0-9.]+ \(clang-([0-9]{3})\.', cc_output)
-
if match:
apple_clang_version = match.group(1)
if apple_clang_version in xcode_version_to_clang:
@@ -2645,14 +2648,14 @@ class CompilerDetector(object):
else:
logging.warning('Unable to determine LLVM Clang version cooresponding to Apple Clang %s' %
(apple_clang_version))
- return '3.8' # safe default
+ cc_version = '3.8' # safe default
- if cc_version is None:
+ if cc_version:
+ logging.info('Detected %s compiler version %s' % (self._cc_name, cc_version))
+ else:
logging.warning("Tried to get %s version, but output '%s' does not match expected version format" % (
self._cc_name, cc_output))
- return None
- logging.info('Detected %s compiler version %s' % (self._cc_name, cc_version))
return cc_version
diff --git a/src/lib/entropy/rdseed/info.txt b/src/lib/entropy/rdseed/info.txt
index 085174257..13ea33175 100644
--- a/src/lib/entropy/rdseed/info.txt
+++ b/src/lib/entropy/rdseed/info.txt
@@ -14,8 +14,8 @@ x86_64
</arch>
<cc>
-gcc:4.8
-clang:3.2
+gcc
+clang
icc
-msvc:2013
+msvc
</cc>
diff --git a/src/lib/hash/sha1/sha1_x86/info.txt b/src/lib/hash/sha1/sha1_x86/info.txt
index fa329ae77..9cddd40a2 100644
--- a/src/lib/hash/sha1/sha1_x86/info.txt
+++ b/src/lib/hash/sha1/sha1_x86/info.txt
@@ -7,5 +7,5 @@ need_isa sha,ssse3,sse4.1
<cc>
clang:3.9
gcc:5.0
-msvc:2015
+msvc:19.0 # MSVS 2015
</cc>
diff --git a/src/lib/hash/sha2_32/sha2_32_x86/info.txt b/src/lib/hash/sha2_32/sha2_32_x86/info.txt
index c0b159ab2..bf34e73a3 100644
--- a/src/lib/hash/sha2_32/sha2_32_x86/info.txt
+++ b/src/lib/hash/sha2_32/sha2_32_x86/info.txt
@@ -7,5 +7,5 @@ need_isa sha,sse4.1
<cc>
gcc:5.0
clang:3.9
-msvc:2015
+msvc:19.0 # MSVS 2015
</cc>
diff --git a/src/scripts/python_uniitests.py b/src/scripts/python_uniitests.py
index f7b1bc97e..fff32e03f 100755
--- a/src/scripts/python_uniitests.py
+++ b/src/scripts/python_uniitests.py
@@ -82,13 +82,33 @@ Candidate multilib: .;@m64
Selected multilib: .;@m64"""
self.assertEqual(detector.version_from_compiler_output(compiler_out), "4.0")
+ def test_clang_version_two_digit(self):
+ # Output from Crystax NDK. Note: there is a trailing whitespace behind the version
+ # number for whatever reason. But let's keep the original output unchanged.
+ # pylint: disable=trailing-whitespace
+ detector = CompilerDetector("clang", "clang++", "android")
+ compiler_out = """clang version 3.7
+Target: i686-none-linux-android
+Thread model: posix
+Found candidate GCC installation: /foo/crystax-toolchains/x86/bin/../lib/gcc/i686-linux-android/4.9
+Selected GCC installation: /foo/crystax-toolchains/x86/bin/../lib/gcc/i686-linux-android/4.9
+Candidate multilib: .;@m32
+Selected multilib: .;@m32"""
+ self.assertEqual(detector.version_from_compiler_output(compiler_out), "3.7")
+
def test_msvc_version(self):
detector = CompilerDetector("msvc", "cl.exe", "windows")
compiler_out = """msvc_version.c
1900
"""
- self.assertEqual(detector.version_from_compiler_output(compiler_out), "2015")
+ self.assertEqual(detector.version_from_compiler_output(compiler_out), "19.0")
+
+ compiler_out = """msvc_version.c
+
+1910
+"""
+ self.assertEqual(detector.version_from_compiler_output(compiler_out), "19.10")
class ModulesChooserResolveDependencies(unittest.TestCase):