[lld] r313579 - [lit] Update clang and lld to use new config helpers.
Zachary Turner via llvm-commits
llvm-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:
lld/trunk/test/lit.cfg
lld/trunk/test/lit.site.cfg.in
Modified: lld/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.cfg?rev=313579&r1=313578&r2=313579&view=diff
==============================================================================
--- lld/trunk/test/lit.cfg (original)
+++ lld/trunk/test/lit.cfg Mon Sep 18 15:26:48 2017
@@ -9,40 +9,18 @@ import locale
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 = 'lld'
-# Tweak PATH for Win32
-if sys.platform in ['win32']:
- # 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 = ['.ll', '.s', '.test', '.yaml', '.objtxt']
@@ -57,21 +35,10 @@ config.test_source_root = os.path.dirnam
config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
-
# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((config.lld_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
-
-config.environment['PATH'] = path
+llvm_config.with_environment('PATH', [config.llvm_tools_dir, config.lld_tools_dir], append_path=True)
-path = os.path.pathsep.join((config.lld_libs_dir, config.llvm_libs_dir,
- config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
-
-# Propagate LLVM_SRC_ROOT into the environment.
-config.environment['LLVM_SRC_ROOT'] = config.llvm_src_root
-
-# Propagate PYTHON_EXECUTABLE into the environment
-config.environment['PYTHON_EXECUTABLE'] = sys.executable
+llvm_config.with_environment('LD_LIBRARY_PATH', [config.lld_libs_dir, config.llvm_libs_dir], append_path=True)
# For each occurrence of a lld tool name as its own word, replace it
# with the full path to the build directory holding that tool. This
@@ -126,68 +93,26 @@ config.substitutions.append( ('%python',
if lit_config.useValgrind:
config.target_triple += '-vg'
-# Shell execution
-if execute_external:
- config.available_features.add('shell')
-
-# zlib compression library
-if config.have_zlib:
- config.available_features.add("zlib")
-
-# Running on Darwin OS
-if platform.system() in ['Darwin']:
- config.available_features.add('system-linker-mach-o')
-
# Running on ELF based *nix
if platform.system() in ['FreeBSD', 'Linux']:
config.available_features.add('system-linker-elf')
-# Running on Windows
-if platform.system() in ['Windows']:
- config.available_features.add('system-windows')
-
# Set if host-cxxabi's demangler can handle target's symbols.
if platform.system() not in ['Windows']:
config.available_features.add('demangler')
-# llvm-config knows whether it is compiled with asserts (and)
-# whether we are operating in release/debug mode.
-import subprocess
-try:
- llvm_config_cmd = \
- subprocess.Popen([os.path.join(config.llvm_tools_dir, 'llvm-config'),
- '--build-mode', '--assertion-mode', '--targets-built'],
- stdout = subprocess.PIPE)
-except OSError as why:
- print("Could not find llvm-config in " + config.llvm_tools_dir)
- exit(42)
-
-llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8')
-llvm_config_output_list = llvm_config_output.split("\n")
-
-if re.search(r'DEBUG', llvm_config_output_list[0]):
- config.available_features.add('debug')
-if re.search(r'ON', llvm_config_output_list[1]):
- config.available_features.add('asserts')
-
-archs = llvm_config_output_list[2]
-if re.search(r'AArch64', archs):
- config.available_features.add('aarch64')
-if re.search(r'AMDGPU', archs):
- config.available_features.add('amdgpu')
-if re.search(r'ARM', archs):
- config.available_features.add('arm')
-if re.search(r'AVR', archs):
- config.available_features.add('avr')
-if re.search(r'Mips', archs):
- config.available_features.add('mips')
-if re.search(r'PowerPC', archs):
- config.available_features.add('ppc')
-if re.search(r'Sparc', archs):
- config.available_features.add('sparc')
-if re.search(r'X86', archs):
- config.available_features.add('x86')
-llvm_config_cmd.wait()
+llvm_config.feature_config(
+ [('--build-mode', {'DEBUG' : 'debug'}),
+ ('--assertion-mode', {'ON' : 'asserts'}),
+ ('--targets-built', {'AArch64' : 'aarch64',
+ 'AMDGPU' : 'amdgpu',
+ 'ARM' : 'arm',
+ 'AVR' : 'avr',
+ 'Mips' : 'mips',
+ 'PowerPC' : 'ppc',
+ 'Sparc' : 'sparc',
+ 'X86' : 'x86'})
+ ])
# Set a fake constant version so that we get consitent output.
config.environment['LLD_VERSION'] = 'LLD 1.0'
Modified: lld/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.site.cfg.in?rev=313579&r1=313578&r2=313579&view=diff
==============================================================================
--- lld/trunk/test/lit.site.cfg.in (original)
+++ lld/trunk/test/lit.site.cfg.in Mon Sep 18 15:26:48 2017
@@ -22,5 +22,7 @@ except KeyError as e:
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, "@LLD_SOURCE_DIR@/test/lit.cfg")
More information about the llvm-commits
mailing list