1# -*- Python -*- 2 3import os 4 5# Setup config name. 6config.name = 'XRay' + config.name_suffix 7 8# Setup source root. 9config.test_source_root = os.path.dirname(__file__) 10 11# Setup default compiler flags use with -fxray-instrument option. 12clang_xray_cflags = (['-fxray-instrument', config.target_cflags]) 13 14# If libc++ was used to build XRAY libraries, libc++ is needed. Fix applied 15# to Linux only since -rpath may not be portable. This can be extended to 16# other platforms. 17if config.libcxx_used == "1" and config.host_os == "Linux": 18 clang_xray_cflags = clang_xray_cflags + (['-L%s -lc++ -Wl,-rpath=%s' 19 % (config.llvm_shlib_dir, 20 config.llvm_shlib_dir)]) 21 22clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags 23 24def build_invocation(compile_flags): 25 return ' ' + ' '.join([config.clang] + compile_flags) + ' ' 26 27# Assume that llvm-xray is in the config.llvm_tools_dir. 28llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray') 29 30# Setup substitutions. 31if config.host_os == "Linux": 32 libdl_flag = "-ldl" 33else: 34 libdl_flag = "" 35 36config.substitutions.append( 37 ('%clang ', build_invocation([config.target_cflags]))) 38config.substitutions.append( 39 ('%clangxx ', 40 build_invocation(config.cxx_mode_flags + [config.target_cflags]))) 41config.substitutions.append( 42 ('%clang_xray ', build_invocation(clang_xray_cflags))) 43config.substitutions.append( 44 ('%clangxx_xray', build_invocation(clang_xray_cxxflags))) 45config.substitutions.append( 46 ('%llvm_xray', llvm_xray)) 47config.substitutions.append( 48 ('%xraylib', 49 ('-lm -lpthread %s -lrt -L%s ' 50 '-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive') 51 % (libdl_flag, config.compiler_rt_libdir, config.target_suffix))) 52 53# Default test suffixes. 54config.suffixes = ['.c', '.cpp'] 55 56if config.host_os not in ['FreeBSD', 'Linux', 'NetBSD', 'OpenBSD']: 57 config.unsupported = True 58elif '64' not in config.host_arch: 59 if 'arm' in config.host_arch: 60 if '-mthumb' in config.target_cflags: 61 config.unsupported = True 62 else: 63 config.unsupported = True 64 65if config.host_os == 'NetBSD': 66 config.substitutions.insert(0, ('%run', config.netbsd_nomprotect_prefix)) 67