1# -*- Python -*- 2 3import os 4 5# Setup config name. 6config.name = "Scudo" + config.name_suffix 7 8# Setup source root. 9config.test_source_root = os.path.dirname(__file__) 10 11# Path to the shared library 12shared_libscudo = os.path.join( 13 config.compiler_rt_libdir, "libclang_rt.scudo%s.so" % config.target_suffix 14) 15shared_minlibscudo = os.path.join( 16 config.compiler_rt_libdir, "libclang_rt.scudo_minimal%s.so" % config.target_suffix 17) 18 19# Test suffixes. 20config.suffixes = [".c", ".cpp", ".test"] 21 22# C & CXX flags. 23c_flags = [config.target_cflags] + [ 24 "-pthread", 25 "-fPIE", 26 "-pie", 27 "-O0", 28 "-UNDEBUG", 29 "-ldl", 30 "-Wl,--gc-sections", 31] 32 33# Android doesn't want -lrt. 34if not config.android: 35 c_flags += ["-lrt"] 36 37cxx_flags = c_flags + config.cxx_mode_flags + ["-std=c++11"] 38 39scudo_flags = ["-fsanitize=scudo"] 40 41 42def build_invocation(compile_flags): 43 return " " + " ".join([config.clang] + compile_flags) + " " 44 45 46# Add substitutions. 47config.substitutions.append(("%clang ", build_invocation(c_flags))) 48config.substitutions.append(("%clang_scudo ", build_invocation(c_flags + scudo_flags))) 49config.substitutions.append( 50 ("%clangxx_scudo ", build_invocation(cxx_flags + scudo_flags)) 51) 52config.substitutions.append(("%shared_libscudo", shared_libscudo)) 53config.substitutions.append(("%shared_minlibscudo", shared_minlibscudo)) 54 55# Platform-specific default SCUDO_OPTIONS for lit tests. 56default_scudo_opts = "" 57if config.android: 58 # Android defaults to abort_on_error=1, which doesn't work for us. 59 default_scudo_opts = "abort_on_error=0" 60 61# Disable GWP-ASan for scudo internal tests. 62if config.gwp_asan: 63 config.environment["GWP_ASAN_OPTIONS"] = "Enabled=0" 64 65if default_scudo_opts: 66 config.environment["SCUDO_OPTIONS"] = default_scudo_opts 67 default_scudo_opts += ":" 68config.substitutions.append( 69 ("%env_scudo_opts=", "env SCUDO_OPTIONS=" + default_scudo_opts) 70) 71 72# Hardened Allocator tests are currently supported on Linux only. 73if config.host_os not in ["Linux"]: 74 config.unsupported = True 75