• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- Python -*-
2
3# Configuration file for 'lit' test runner.
4# This file contains common rules for various compiler-rt testsuites.
5# It is mostly copied from lit.cfg used by Clang.
6import os
7import platform
8
9import lit.formats
10import lit.util
11
12# Setup test format
13execute_external = (platform.system() != 'Windows'
14                    or lit_config.getBashPath() not in [None, ""])
15config.test_format = lit.formats.ShTest(execute_external)
16
17# Setup clang binary.
18compiler_path = getattr(config, 'clang', None)
19if (not compiler_path) or (not os.path.exists(compiler_path)):
20  lit_config.fatal("Can't find compiler on path %r" % compiler_path)
21
22compiler_id = getattr(config, 'compiler_id', None)
23if compiler_id == "Clang":
24  if platform.system() != 'Windows':
25    config.cxx_mode_flags = ["--driver-mode=g++"]
26  else:
27    config.cxx_mode_flags = []
28  # We assume that sanitizers should provide good enough error
29  # reports and stack traces even with minimal debug info.
30  config.debug_info_flags = ["-gline-tables-only"]
31elif compiler_id == 'GNU':
32  config.cxx_mode_flags = ["-x c++"]
33  config.debug_info_flags = ["-g"]
34else:
35  lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
36# Add compiler ID to the list of available features.
37config.available_features.add(compiler_id)
38
39# Clear some environment variables that might affect Clang.
40possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
41                               'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
42                               'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
43                               'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
44                               'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
45                               'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
46                               'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
47                               'LIBCLANG_RESOURCE_USAGE',
48                               'LIBCLANG_CODE_COMPLETION_LOGGING']
49# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
50if platform.system() != 'Windows':
51    possibly_dangerous_env_vars.append('INCLUDE')
52for name in possibly_dangerous_env_vars:
53  if name in config.environment:
54    del config.environment[name]
55
56# Tweak PATH to include llvm tools dir.
57llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
58if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
59  lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
60path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
61config.environment['PATH'] = path
62
63# Help MSVS link.exe find the standard libraries.
64# Make sure we only try to use it when targetting Windows.
65if platform.system() == 'Windows' and '-win' in config.target_triple:
66  config.environment['LIB'] = os.environ['LIB']
67
68# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
69# in RUN lines.
70config.substitutions.append(
71    (' clang', """\n\n*** Do not use 'clangXXX' in tests,
72     instead define '%clangXXX' substitution in lit config. ***\n\n""") )
73
74# Allow tests to be executed on a simulator or remotely.
75config.substitutions.append( ('%run', config.emulator) )
76
77# Define CHECK-%os to check for OS-dependent output.
78config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
79
80# Add supported compiler_rt architectures to a list of available features.
81compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
82if compiler_rt_arch:
83  for arch in compiler_rt_arch.split(";"):
84    config.available_features.add(arch + "-supported-target")
85
86compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
87if not compiler_rt_debug:
88  config.available_features.add('compiler-rt-optimized')
89
90lit.util.usePlatformSdkOnDarwin(config, lit_config)
91