r313579 - [lit] Update clang and lld to use new config helpers.
Zachary Turner via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 15:26:48 PDT 2017
Author: zturner
Date: Mon Sep 18 15:26:48 2017
New Revision: 313579
URL: http://llvm.org/viewvc/llvm-project?rev=313579&view=rev
Log:
[lit] Update clang and lld to use new config helpers.
NFC intended here, this only updates clang and lld's lit configs
to use some helper functionality in the lit.llvm submodule.
Modified:
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
Modified: cfe/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=313579&r1=313578&r2=313579&view=diff
==============================================================================
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Mon Sep 18 15:26:48 2017
@@ -9,39 +9,18 @@ import tempfile
import lit.formats
import lit.util
+from lit.llvm import llvm_config
+
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
config.name = 'Clang'
-# Tweak PATH for Win32
-if platform.system() == 'Windows':
- # Seek sane tools in directories and set to $PATH.
- path = getattr(config, 'lit_tools_dir', None)
- path = lit_config.getToolsPath(path,
- config.environment['PATH'],
- ['cmp.exe', 'grep.exe', 'sed.exe'])
- if path is not None:
- path = os.path.pathsep.join((path,
- config.environment['PATH']))
- config.environment['PATH'] = path
-
-# Choose between lit's internal shell pipeline runner and a real shell. If
-# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
-use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if use_lit_shell:
- # 0 is external, "" is default, and everything else is internal.
- execute_external = (use_lit_shell == "0")
-else:
- # Otherwise we default to internal on Windows and external elsewhere, as
- # bash on Windows is usually very slow.
- execute_external = (not sys.platform in ['win32'])
-
# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
# the test runner updated.
-config.test_format = lit.formats.ShTest(execute_external)
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
@@ -81,22 +60,16 @@ possibly_dangerous_env_vars = ['COMPILER
# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
if platform.system() != 'Windows':
possibly_dangerous_env_vars.append('INCLUDE')
-for name in possibly_dangerous_env_vars:
- if name in config.environment:
- del config.environment[name]
+
+llvm_config.clear_environment(possibly_dangerous_env_vars)
# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
- config.clang_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
-config.environment['PATH'] = path
-path = os.path.pathsep.join((config.llvm_shlib_dir, config.llvm_libs_dir,
- config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+llvm_config.with_environment('PATH', [config.llvm_tools_dir, config.clang_tools_dir], append_path=True)
+
+llvm_config.with_environment('LD_LIBRARY_PATH', [config.llvm_shlib_dir, config.llvm_libs_dir], append_path=True)
# Propagate path to symbolizer for ASan/MSan.
-for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
- if symbolizer in os.environ:
- config.environment[symbolizer] = os.environ[symbolizer]
+llvm_config.with_system_environment(['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
# Discover the 'clang' and 'clangcc' to use.
@@ -151,7 +124,7 @@ def getClangBuiltinIncludeDir(clang):
if not cmd.stdout:
lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % clang)
dir = cmd.stdout.read().strip()
- if sys.platform in ['win32'] and execute_external:
+ if sys.platform in ['win32'] and not llvm_config.use_lit_shell:
# Don't pass dosish path separator to msys bash.exe.
dir = dir.replace('\\', '/')
# Ensure the result is an ascii string, across Python2.5+ - Python3.
@@ -295,18 +268,6 @@ if config.clang_staticanalyzer:
if platform.system() not in ['FreeBSD']:
config.available_features.add('crash-recovery')
-# Shell execution
-if execute_external:
- config.available_features.add('shell')
-
-# For tests that require Darwin to run.
-# This is used by debuginfo-tests/*block*.m and debuginfo-tests/foreach.m.
-if platform.system() in ['Darwin']:
- config.available_features.add('system-darwin')
-elif platform.system() in ['Windows']:
- # For tests that require Windows to run.
- config.available_features.add('system-windows')
-
# ANSI escape sequences in non-dumb terminal
if platform.system() not in ['Windows']:
config.available_features.add('ansi-escape-sequences')
@@ -321,12 +282,6 @@ if platform.system() not in ['Windows']:
if platform.system() not in ['Darwin', 'Fuchsia']:
config.available_features.add('libgcc')
-# Native compilation: Check if triples match.
-# FIXME: Consider cases that target can be executed
-# even if host_triple were different from target_triple.
-if config.host_triple == config.target_triple:
- config.available_features.add("native")
-
# Case-insensitive file system
def is_filesystem_case_insensitive():
handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
@@ -367,87 +322,24 @@ if not re.match(r'.*-(cygwin)$', config.
if platform.system() not in ['Windows']:
config.available_features.add('can-remove-opened-file')
-# Returns set of available features, registered-target(s), asserts and
-# compile definitions.
-def get_llvm_config_props():
- set_of_features = set()
-
- cmd = subprocess.Popen(
- [
- os.path.join(config.llvm_tools_dir, 'llvm-config'),
- '--assertion-mode',
- '--targets-built',
- '--cxxflags'
- ],
- stdout=subprocess.PIPE,
- env=config.environment
- )
- # 1st line corresponds to --assertion-mode, "ON" or "OFF".
- line = cmd.stdout.readline().strip().decode('ascii')
- if line == "ON":
- set_of_features.add('asserts')
-
- # 2nd line corresponds to --targets-built, like;
- # AArch64 ARM CppBackend X86
- for arch in cmd.stdout.readline().decode('ascii').split():
- set_of_features.add(arch.lower() + '-registered-target')
-
- # 3rd line contains compile definitions, search it to define if
- # libstdc++ safe mode is set.
- if re.search(r'-D_GLIBCXX_DEBUG\b', cmd.stdout.readline().decode('ascii')):
- set_of_features.add('libstdcxx-safe-mode')
-
- return set_of_features
-
-config.available_features.update(get_llvm_config_props())
+def calculate_arch_features(arch_string):
+ features = []
+ for arch in arch_string.split():
+ features.append(arch.lower() + '-registered-target')
+ return features
+
+llvm_config.feature_config(
+ [('--assertion-mode', {'ON' : 'asserts'}),
+ ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b' : 'libstdcxx-safe-mode'}),
+ ('--targets-built', calculate_arch_features)
+ ])
if lit.util.which('xmllint'):
config.available_features.add('xmllint')
-# Sanitizers.
-if 'Address' in config.llvm_use_sanitizer:
- config.available_features.add("asan")
-else:
- config.available_features.add("not_asan")
-if 'Memory' in config.llvm_use_sanitizer:
- config.available_features.add("msan")
-if 'Undefined' in config.llvm_use_sanitizer:
- config.available_features.add("ubsan")
-else:
- config.available_features.add("not_ubsan")
-
if config.enable_backtrace:
config.available_features.add("backtrace")
-if config.have_zlib:
- config.available_features.add("zlib")
-else:
- config.available_features.add("nozlib")
-
-# Check if we should run long running tests.
-if lit_config.params.get("run_long_tests", None) == "true":
- config.available_features.add("long_tests")
-
-# Check if we should use gmalloc.
-use_gmalloc_str = lit_config.params.get('use_gmalloc', None)
-if use_gmalloc_str is not None:
- if use_gmalloc_str.lower() in ('1', 'true'):
- use_gmalloc = True
- elif use_gmalloc_str.lower() in ('', '0', 'false'):
- use_gmalloc = False
- else:
- lit_config.fatal('user parameter use_gmalloc should be 0 or 1')
-else:
- # Default to not using gmalloc
- use_gmalloc = False
-
-# Allow use of an explicit path for gmalloc library.
-# Will default to '/usr/lib/libgmalloc.dylib' if not set.
-gmalloc_path_str = lit_config.params.get('gmalloc_path',
- '/usr/lib/libgmalloc.dylib')
-if use_gmalloc:
- config.environment.update({'DYLD_INSERT_LIBRARIES' : gmalloc_path_str})
-
# Check if we should allow outputs to console.
run_console_tests = int(lit_config.params.get('enable_console', '0'))
if run_console_tests != 0:
@@ -457,6 +349,3 @@ lit.util.usePlatformSdkOnDarwin(config,
macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
if macOSSDKVersion is not None:
config.available_features.add('macos-sdk-' + macOSSDKVersion)
-
-if config.enable_abi_breaking_checks == "1":
- config.available_features.add('abi-breaking-checks')
Modified: cfe/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.in?rev=313579&r1=313578&r2=313579&view=diff
==============================================================================
--- cfe/trunk/test/lit.site.cfg.in (original)
+++ cfe/trunk/test/lit.site.cfg.in Mon Sep 18 15:26:48 2017
@@ -39,5 +39,7 @@ except KeyError:
key, = e.args
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+ at LIT_SITE_CFG_IN_FOOTER@
+
# Let the main config do the real work.
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg")
More information about the cfe-commits
mailing list