# -*- Python -*- import os def get_required_attr(config, attr_name): attr_value = getattr(config, attr_name, None) if not attr_value: lit_config.fatal( "No attribute %r in test configuration! You may need to run " "tests from your build directory or add this attribute " "to lit.site.cfg " % attr_name) return attr_value # Setup config name. config.name = 'ThreadSanitizer' # Setup source root. config.test_source_root = os.path.dirname(__file__) # Setup environment variables for running ThreadSanitizer. tsan_options = "atexit_sleep_ms=0" config.environment['TSAN_OPTIONS'] = tsan_options # Setup default compiler flags used with -fsanitize=thread option. # FIXME: Review the set of required flags and check if it can be reduced. clang_tsan_cflags = ["-fsanitize=thread", "-g", "-Wall", "-lpthread", "-ldl", "-m64"] clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags def build_invocation(compile_flags): return " " + " ".join([config.clang] + compile_flags) + " " config.substitutions.append( ("%clang_tsan ", build_invocation(clang_tsan_cflags)) ) config.substitutions.append( ("%clangxx_tsan ", build_invocation(clang_tsan_cxxflags)) ) # Define CHECK-%os to check for OS-dependent output. config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) # Default test suffixes. config.suffixes = ['.c', '.cc', '.cpp'] # ThreadSanitizer tests are currently supported on Linux only. if config.host_os not in ['Linux']: config.unsupported = True