aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-05 20:55:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-05 20:55:50 +0000
commitb40fd3fd3011ef3bdbd0cb314f70d3bdf539553b (patch)
treeff07e21a851bd93903f1761a08497300595c8877
parent7d7e9f963a4977e36efb90fd9c369f33ced1a95a (diff)
Teach lit to ask the Clang it is running what version string to use
rather than presuming that it is 3.0. This is extra important as the version should be 3.1, but CMake hasn't caught up with the times. That'll be fixed in a separate commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143823 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/lit.cfg24
1 files changed, 17 insertions, 7 deletions
diff --git a/test/lit.cfg b/test/lit.cfg
index 35f38aa44a..f444b2fb92 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -2,6 +2,9 @@
import os
import platform
+import re
+import subprocess
+
# Configuration file for the 'lit' test runner.
@@ -145,11 +148,22 @@ if not lit.quiet:
# Note that when substituting %clang_cc1 also fill in the include directory of
# the builtin headers. Those are part of even a freestanding environment, but
# Clang relies on the driver to locate them.
-# FIXME: It might be nice to teach the frontend how to find its builtin headers
-# in some limited cases when the driver provides no hints.
+def getClangVersion(clang):
+ # FIXME: Rather than just getting the version, we should have clang print
+ # out its resource dir here in an easy to scrape form.
+ cmd = subprocess.Popen([clang, '-v'], stderr=subprocess.PIPE)
+
+ for line in cmd.stderr:
+ m = re.match( r'^clang version ([^ ]+) ', line)
+ if m is not None:
+ return m.group(1)
+
+ lit.fatal("Couldn't find the version of Clang ('%s')" % clang)
+
clang_directory = os.path.dirname(os.path.realpath(config.clang))
clang_builtin_includes = os.path.join(os.path.dirname(clang_directory),
- 'lib', 'clang', '3.0', 'include')
+ 'lib', 'clang',
+ getClangVersion(config.clang), 'include')
config.substitutions.append( ('%clang_cc1',
'%s -cc1 -internal-nosysroot-isystem %s'
% (config.clang, clang_builtin_includes)) )
@@ -187,10 +201,6 @@ if platform.system() not in ['Windows'] or lit.getBashPath() != '':
config.available_features.add('shell')
# Registered Targets
-import subprocess
-import re
-import os
-
def getRegisteredTargets(tool):
set_of_targets = set()