brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · e56ed85 Raw
70 lines · python
1# -*- Python -*-2 3import os4 5# Setup config name.6config.name = "XRay" + config.name_suffix7 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 applied15# to Linux only since -rpath may not be portable. This can be extended to16# other platforms.17if config.libcxx_used == "1" and config.target_os == "Linux":18    clang_xray_cflags = clang_xray_cflags + (19        ["-L%s -lc++ -Wl,-rpath=%s" % (config.llvm_shlib_dir, config.llvm_shlib_dir)]20    )21 22clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags23 24 25def build_invocation(compile_flags):26    return " " + " ".join([config.clang] + compile_flags) + " "27 28 29# Assume that llvm-xray is in the config.llvm_tools_dir.30llvm_xray = os.path.join(config.llvm_tools_dir, "llvm-xray")31 32# Setup substitutions.33if config.target_os == "Linux":34    libdl_flag = "-ldl"35else:36    libdl_flag = ""37 38config.substitutions.append(("%clang ", build_invocation([config.target_cflags])))39config.substitutions.append(40    ("%clangxx ", build_invocation(config.cxx_mode_flags + [config.target_cflags]))41)42config.substitutions.append(("%clang_xray ", build_invocation(clang_xray_cflags)))43config.substitutions.append(("%clangxx_xray", build_invocation(clang_xray_cxxflags)))44config.substitutions.append(("%llvm_xray", llvm_xray))45config.substitutions.append(46    (47        "%xraylib",48        (49            "-lm -lpthread %s -lrt -L%s "50            "-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive"51        )52        % (libdl_flag, config.compiler_rt_libdir, config.target_suffix),53    )54)55 56# Default test suffixes.57config.suffixes = [".c", ".cpp"]58 59if config.target_os not in ["FreeBSD", "Linux", "NetBSD", "OpenBSD"]:60    config.unsupported = True61elif "64" not in config.host_arch:62    if "arm" in config.host_arch:63        if "-mthumb" in config.target_cflags:64            config.unsupported = True65    else:66        config.unsupported = True67 68if config.target_os == "NetBSD":69    config.substitutions.insert(0, ("%run", config.netbsd_nomprotect_prefix))70