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. 6 import os 7 import platform 8 9 import lit.formats 10 import lit.util 11 12 # Setup test format 13 execute_external = (platform.system() != 'Windows' 14 or lit_config.getBashPath() not in [None, ""]) 15 config.test_format = lit.formats.ShTest(execute_external) 16 17 # Setup clang binary. 18 compiler_path = getattr(config, 'clang', None) 19 if (not compiler_path) or (not os.path.exists(compiler_path)): 20 lit_config.fatal("Can't find compiler on path %r" % compiler_path) 21 22 compiler_id = getattr(config, 'compiler_id', None) 23 if 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"] 31 elif compiler_id == 'GNU': 32 config.cxx_mode_flags = ["-x c++"] 33 config.debug_info_flags = ["-g"] 34 else: 35 lit_config.fatal("Unsupported compiler id: %r" % compiler_id) 36 # Add compiler ID to the list of available features. 37 config.available_features.add(compiler_id) 38 39 # Clear some environment variables that might affect Clang. 40 possibly_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. 50 if platform.system() != 'Windows': 51 possibly_dangerous_env_vars.append('INCLUDE') 52 for 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. 57 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) 58 if (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) 60 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) 61 config.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. 65 if 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. 70 config.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. 75 config.substitutions.append( ('%run', config.emulator) ) 76 77 # Define CHECK-%os to check for OS-dependent output. 78 config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) 79 80 # Add supported compiler_rt architectures to a list of available features. 81 compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) 82 if compiler_rt_arch: 83 for arch in compiler_rt_arch.split(";"): 84 config.available_features.add(arch + "-supported-target") 85 86 compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) 87 if not compiler_rt_debug: 88 config.available_features.add('compiler-rt-optimized') 89 90 lit.util.usePlatformSdkOnDarwin(config, lit_config) 91