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.
12 execute_external = (platform.system() != 'Windows'
13 or lit_config.getBashPath() not in [None, ""])
14 config.test_format = lit.formats.ShTest(execute_external)
17 compiler_path = getattr(config, 'clang', None)
18 if (not compiler_path) or (not os.path.exists(compiler_path)):
19 lit_config.fatal("Can't find compiler on path %r" % compiler_path)
21 compiler_id = getattr(config, 'compiler_id', None)
22 if compiler_id == "Clang":
23 config.cxx_mode_flags = ["--driver-mode=g++"]
24 elif compiler_id == 'GNU':
25 config.cxx_mode_flags = ["-x c++"]
27 lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
29 # Clear some environment variables that might affect Clang.
30 possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
31 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
32 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
33 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
34 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
35 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
36 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
37 'LIBCLANG_RESOURCE_USAGE',
38 'LIBCLANG_CODE_COMPLETION_LOGGING']
39 # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
40 if platform.system() != 'Windows':
41 possibly_dangerous_env_vars.append('INCLUDE')
42 for name in possibly_dangerous_env_vars:
43 if name in config.environment:
44 del config.environment[name]
46 # Tweak PATH to include llvm tools dir.
47 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
48 if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
49 lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
50 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
51 config.environment['PATH'] = path
53 # Use ugly construction to explicitly prohibit "clang", "clang++" etc.
55 config.substitutions.append(
56 (' clang', """\n\n*** Do not use 'clangXXX' in tests,
57 instead define '%clangXXX' substitution in lit config. ***\n\n""") )
59 # Allow tests to be executed on a simulator or remotely.
60 config.substitutions.append( ('%run', config.emulator) )
62 # Add supported compiler_rt architectures to a list of available features.
63 compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
65 for arch in compiler_rt_arch.split(";"):
66 config.available_features.add(arch + "-supported-target")
68 compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
69 if not compiler_rt_debug:
70 config.available_features.add('compiler-rt-optimized')