brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 3c3badb Raw
102 lines · python
1# -*- Python -*-2 3import os4import subprocess5 6# Setup config name.7config.name = "ORC" + config.name_suffix8 9# Setup source root.10config.test_source_root = os.path.dirname(__file__)11 12# Determine whether the test target is compatible with execution on the host.13host_arch_compatible = config.target_arch == config.host_arch14 15if config.host_arch == "x86_64h" and config.target_arch == "x86_64":16    host_arch_compatible = True17if host_arch_compatible:18    config.available_features.add("host-arch-compatible")19 20# If the target OS hasn't been set then assume host.21if not config.orc_test_target_os:22    config.orc_test_target_os = config.target_os23 24config.test_target_is_host_executable = (25    config.orc_test_target_os == config.target_os and host_arch_compatible26)27 28# Assume that llvm-jitlink is in the config.llvm_tools_dir.29llvm_jitlink = os.path.join(config.llvm_tools_dir, "llvm-jitlink")30orc_rt_executor_stem = os.path.join(31    config.compiler_rt_obj_root, "lib/orc/tests/tools/orc-rt-executor"32)33lli = os.path.join(config.llvm_tools_dir, "lli")34if config.target_os == "Darwin":35    orc_rt_path = "%s/liborc_rt_osx.a" % config.compiler_rt_libdir36else:37    orc_rt_path = "%s/liborc_rt%s.a" % (config.compiler_rt_libdir, config.target_suffix)38 39if config.libunwind_shared:40    config.available_features.add("libunwind-available")41    shared_libunwind_path = os.path.join(config.libunwind_install_dir, "libunwind.so")42    config.substitutions.append(("%shared_libunwind", shared_libunwind_path))43 44 45def build_invocation(compile_flags):46    return " " + " ".join([config.clang] + compile_flags) + " "47 48 49config.substitutions.append(("%clang ", build_invocation([config.target_cflags])))50config.substitutions.append(51    ("%clangxx ", build_invocation(config.cxx_mode_flags + [config.target_cflags]))52)53config.substitutions.append(54    ("%clang_cl ", build_invocation(["--driver-mode=cl"] + [config.target_cflags]))55)56if config.target_os == "Windows":57    config.substitutions.append(58        (59            "%llvm_jitlink",60            (61                llvm_jitlink62                + " -orc-runtime="63                + orc_rt_path64                + " -no-process-syms=true -slab-allocate=64MB"65            ),66        )67    )68else:69    config.substitutions.append(70        ("%llvm_jitlink", (llvm_jitlink + " -orc-runtime=" + orc_rt_path))71    )72config.substitutions.append(73    ("%orc_rt_executor", orc_rt_executor_stem + "-" + config.host_arch)74)75config.substitutions.append(76    (77        "%lli_orc_jitlink",78        (lli + " -jit-kind=orc -jit-linker=jitlink -orc-runtime=" + orc_rt_path),79    )80)81config.substitutions.append(("%ar", "ar"))82 83# Default test suffixes.84config.suffixes = [".c", ".cpp", ".m", ".S", ".ll", ".test"]85 86# Exclude Inputs directories.87config.excludes = ["Inputs"]88 89if config.target_os not in ["Darwin", "FreeBSD", "Linux", "Windows"]:90    config.unsupported = True91 92# Ask llvm-config about assertion mode.93try:94    llvm_config_result = subprocess.check_output(95        [os.path.join(config.llvm_tools_dir, "llvm-config"), "--assertion-mode"],96        env=config.environment,97    )98    if llvm_config_result.startswith(b"ON"):99        config.available_features.add("asserts")100except OSError as e:101    lit_config.warning(f"Could not determine if LLVM was built with assertions: {e}")102