Exemplo n.º 1
0
def use_support_substitutions(config):
    # Set up substitutions for support tools.  These tools can be overridden at the CMake
    # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
    # the just-built version.
    host_flags = ['--target=' + config.host_triple]
    if platform.system() in ['Darwin']:
        try:
            out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
            res = 0
        except OSError:
            res = -1
        if res == 0 and out:
            sdk_path = lit.util.to_string(out)
            llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path)
            host_flags += ['-isysroot', sdk_path]
    elif platform.system() in ['NetBSD', 'OpenBSD', 'Linux']:
        host_flags += ['-pthread']

    if sys.platform.startswith('netbsd'):
        # needed e.g. to use freshly built libc++
        host_flags += [
            '-L' + config.llvm_libs_dir, '-Wl,-rpath,' + config.llvm_libs_dir
        ]

    # The clang module cache is used for building inferiors.
    host_flags += ['-fmodules-cache-path={}'.format(config.clang_module_cache)]

    host_flags = ' '.join(host_flags)
    config.substitutions.append(('%clang_host', '%clang ' + host_flags))
    config.substitutions.append(('%clangxx_host', '%clangxx ' + host_flags))
    config.substitutions.append(
        ('%clang_cl_host', '%clang_cl --target=' + config.host_triple))

    additional_tool_dirs = []
    if config.lldb_lit_tools_dir:
        additional_tool_dirs.append(config.lldb_lit_tools_dir)

    llvm_config.use_clang(additional_flags=[
        '--target=specify-a-target-or-use-a-_host-substitution'
    ],
                          additional_tool_dirs=additional_tool_dirs,
                          required=True)

    if sys.platform == 'win32':
        _use_msvc_substitutions(config)

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False)
    if have_lld:
        config.available_features.add('lld')

    support_tools = [
        'yaml2obj', 'obj2yaml', 'llvm-dwp', 'llvm-pdbutil', 'llvm-mc',
        'llvm-readobj', 'llvm-objdump', 'llvm-objcopy', 'lli'
    ]
    additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
    llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)

    _disallow(config, 'clang')
def use_support_substitutions(config):
    # Set up substitutions for support tools.  These tools can be overridden at the CMake
    # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
    # the just-built version.
    flags = []
    if platform.system() in ['Darwin']:
        try:
            out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
            res = 0
        except OSError:
            res = -1
        if res == 0 and out:
            sdk_path = lit.util.to_string(out)
            llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path)
            flags = ['-isysroot', sdk_path]
    elif platform.system() in ['NetBSD', 'OpenBSD', 'Linux']:
        flags = ['-pthread']

    if sys.platform.startswith('netbsd'):
        # needed e.g. to use freshly built libc++
        flags += [
            '-L' + config.llvm_libs_dir, '-Wl,-rpath,' + config.llvm_libs_dir
        ]

    additional_tool_dirs = []
    if config.lldb_lit_tools_dir:
        additional_tool_dirs.append(config.lldb_lit_tools_dir)

    llvm_config.use_clang(additional_flags=flags,
                          additional_tool_dirs=additional_tool_dirs,
                          required=True)

    if sys.platform == 'win32':
        _use_msvc_substitutions(config)

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False)
    if have_lld:
        config.available_features.add('lld')

    support_tools = [
        'yaml2obj', 'obj2yaml', 'llvm-pdbutil', 'llvm-mc', 'llvm-readobj',
        'llvm-objdump', 'llvm-objcopy', 'lli'
    ]
    additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
    llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)
Exemplo n.º 3
0
def use_support_substitutions(config):
    # Set up substitutions for support tools.  These tools can be overridden at the CMake
    # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
    # the just-built version.
    flags = []
    if platform.system() in ['Darwin']:
        try:
            out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
            res = 0
        except OSError:
            res = -1
        if res == 0 and out:
            sdk_path = lit.util.to_string(out)
            llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path)
            flags = ['-isysroot', sdk_path]
    elif platform.system() in ['NetBSD', 'OpenBSD', 'Linux']:
        flags = ['-pthread']

    if sys.platform.startswith('netbsd'):
        # needed e.g. to use freshly built libc++
        flags += ['-L' + config.llvm_libs_dir,
                  '-Wl,-rpath,' + config.llvm_libs_dir]

    additional_tool_dirs=[]
    if config.lldb_lit_tools_dir:
        additional_tool_dirs.append(config.lldb_lit_tools_dir)

    llvm_config.use_clang(additional_flags=flags,
                          additional_tool_dirs=additional_tool_dirs,
                          required=True)

    if sys.platform == 'win32':
        _use_msvc_substitutions(config)

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False)
    if have_lld:
        config.available_features.add('lld')


    support_tools = ['yaml2obj', 'obj2yaml', 'llvm-pdbutil',
                     'llvm-mc', 'llvm-readobj', 'llvm-objdump',
                     'llvm-objcopy']
    additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
    llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)
Exemplo n.º 4
0
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = [
    'Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 'debuginfo-tests'
]

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.clang_obj_root, 'test')

llvm_config.use_default_substitutions()

llvm_config.use_clang()

config.substitutions.append(
    ('%src_include_dir', config.clang_src_dir + '/include'))

# Propagate path to symbolizer for ASan/MSan.
llvm_config.with_system_environment(
    ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

config.substitutions.append(('%PATH%', config.environment['PATH']))

# For each occurrence of a clang tool name, replace it with the full path to
# the build directory holding that tool.  We explicitly specify the directories
# to search to ensure that we get the tools just built and not some random
# tools that might happen to be in the user's PATH.
tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
Exemplo n.º 5
0
                   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']

# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 'debuginfo-tests']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.clang_obj_root, 'test')

llvm_config.use_default_substitutions()

llvm_config.use_clang()

# Propagate path to symbolizer for ASan/MSan.
llvm_config.with_system_environment(
    ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

config.substitutions.append(('%PATH%', config.environment['PATH']))


# For each occurrence of a clang tool name, replace it with the full path to
# the build directory holding that tool.  We explicitly specify the directories
# to search to ensure that we get the tools just built and not some random
# tools that might happen to be in the user's PATH.
tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]

tools = [
Exemplo n.º 6
0
        config.available_features.add('default_triple')

    # Ask llvm-config about asserts.
    llvm_config.feature_config([('--assertion-mode', {'ON': 'asserts'})])

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.test_run_dir, 'test_output')

llvm_config.use_default_substitutions()

# Explicitly set `use_installed` to alleviate downstream CI pipelines of
# any additional environment setup for pre-installed Clang usage.
llvm_config.use_clang(use_installed=True)

config.substitutions.append(('%PATH%', config.environment['PATH']))

tool_dirs = [config.llvm_tools_dir, config.llvm_spirv_dir]

tools = ['llvm-as', 'llvm-dis', 'llvm-spirv', 'not']
if not config.spirv_skip_debug_info_tests:
    tools.extend([
        'llc', 'llvm-dwarfdump', 'llvm-objdump', 'llvm-readelf', 'llvm-readobj'
    ])

llvm_config.add_tool_substitutions(tools, tool_dirs)

using_spirv_tools = False
Exemplo n.º 7
0
Arquivo: lit.cfg.py Projeto: nwf/llvm
    ToolSubst('%lli', FindTool('lli'), post='.', extra_args=lli_args),
    ToolSubst('%llc_dwarf', FindTool('llc'), extra_args=llc_args),
    ToolSubst('%go', config.go_executable, unresolved='ignore'),
    ToolSubst('%gold', config.gold_executable, unresolved='ignore'),
    ToolSubst('%ld64', ld64_cmd, unresolved='ignore'),
    ToolSubst('%ocamlc', ocamlc_command, unresolved='ignore'),
    ToolSubst('%ocamlopt', ocamlopt_command, unresolved='ignore'),
    ToolSubst('%opt-viewer', opt_viewer_cmd),
    ToolSubst('%llvm-objcopy', FindTool('llvm-objcopy')),
    ToolSubst('%llvm-strip', FindTool('llvm-strip')),
]

llvm_config.add_cheri_tool_substitutions(['llc', 'opt', 'llvm-mc'])

# FIXME: we shouldn't have any tests that depend on clang here
llvm_config.use_clang(required=False)
if config.clang:
    config.available_features.add('clang')

# FIXME: Why do we have both `lli` and `%lli` that do slightly different things?
tools.extend([
    'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as',
    'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', 'llvm-cxxdump',
    'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dwarfdump', 'llvm-extract',
    'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib', 'llvm-link', 'llvm-lto',
    'llvm-lto2', 'llvm-mc', 'llvm-mca', 'llvm-modextract', 'llvm-nm',
    'llvm-objcopy', 'llvm-objdump', 'llvm-pdbutil', 'llvm-profdata',
    'llvm-ranlib', 'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split',
    'llvm-strings', 'llvm-strip', 'llvm-tblgen', 'llvm-c-test', 'llvm-cxxfilt',
    'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder',
    'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'
Exemplo n.º 8
0
    # FIXME: We should add some llvm lit utility code to find the Windows SDK
    # and set up the environment appopriately.
    win_sdk = 'C:/Program Files (x86)/Windows Kits/10/'
    arch = 'x64'
    llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
    # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
    # the network.
    llvm_config.with_environment('_NT_SYMBOL_PATH', '')
    tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 'Debuggers',
                                                         arch, 'cdb.exe')))

# clang_src_dir and lld_src_dir are not used by these tests, but are required by
# use_clang() and use_lld() respectively, so set them to "", if needed.
if not hasattr(config, 'clang_src_dir'):
    config.clang_src_dir = ""
llvm_config.use_clang(required=('clang' in config.llvm_enabled_projects))

if not hasattr(config, 'lld_src_dir'):
    config.lld_src_dir = ""
llvm_config.use_lld(required=('lld' in config.llvm_enabled_projects))

if config.llvm_use_sanitizer:
    # Propagate path to symbolizer for ASan/MSan.
    llvm_config.with_system_environment(
        ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

def add_host_triple(clang):
  return '{} --target={}'.format(clang, config.host_triple)

# The set of arches we can build.
targets = set(config.targets_to_build)
Exemplo n.º 9
0
def use_support_substitutions(config):
    # Set up substitutions for support tools.  These tools can be overridden at the CMake
    # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
    # the just-built version.
    host_flags = ['--target=' + config.host_triple]
    if platform.system() in ['Darwin']:
        try:
            out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
            res = 0
        except OSError:
            res = -1
        if res == 0 and out:
            sdk_path = lit.util.to_string(out)
            llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path)
            host_flags += ['-isysroot', sdk_path]
    elif platform.system() in ['NetBSD', 'OpenBSD', 'Linux']:
        host_flags += ['-pthread']

    config.target_shared_library_suffix = '.dylib' if platform.system() in [
        'Darwin'
    ] else '.so'
    config.substitutions.append(
        ('%target-shared-library-suffix', config.target_shared_library_suffix))

    # Swift support
    swift_args = [
        '-module-cache-path',
        os.path.join(os.path.dirname(config.lldb_libs_dir),
                     'lldb-test-build.noindex', 'module-cache-clang')
    ]
    swift_driver_args = []
    if platform.system() in ['Darwin']:
        swift_args += ['-sdk', sdk_path]
    tools = [
        ToolSubst('%target-swiftc',
                  command=config.swiftc,
                  extra_args=swift_args + swift_driver_args),
        ToolSubst('%target-swift-frontend',
                  command=config.swiftc[:-1],
                  extra_args=(['-frontend'] + swift_args))
    ]
    llvm_config.add_tool_substitutions(tools)

    swift_bin_dir = os.path.dirname(config.swiftc)
    swift_Benchmark_Onone = os.path.join(
        swift_bin_dir, 'Benchmark_Onone-{0}'.format(config.target_triple))
    if os.path.exists(swift_Benchmark_Onone):
        config.substitutions.append(
            ('%swift_Benchmark_Onone', swift_Benchmark_Onone))
        config.available_features.add('swift_Benchmark_Onone')

    if sys.platform.startswith('netbsd'):
        # needed e.g. to use freshly built libc++
        host_flags += [
            '-L' + config.llvm_libs_dir, '-Wl,-rpath,' + config.llvm_libs_dir
        ]

    # The clang module cache is used for building inferiors.
    host_flags += ['-fmodules-cache-path={}'.format(config.clang_module_cache)]

    host_flags = ' '.join(host_flags)
    config.substitutions.append(('%clang_host', '%clang ' + host_flags))
    config.substitutions.append(('%clangxx_host', '%clangxx ' + host_flags))
    config.substitutions.append(
        ('%clang_cl_host', '%clang_cl --target=' + config.host_triple))

    additional_tool_dirs = []
    if config.lldb_lit_tools_dir:
        additional_tool_dirs.append(config.lldb_lit_tools_dir)

    llvm_config.use_clang(additional_flags=[
        '--target=specify-a-target-or-use-a-_host-substitution'
    ],
                          additional_tool_dirs=additional_tool_dirs,
                          required=True)

    if sys.platform == 'win32':
        _use_msvc_substitutions(config)

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False)
    if have_lld:
        config.available_features.add('lld')

    support_tools = [
        'yaml2obj', 'obj2yaml', 'llvm-dwp', 'llvm-pdbutil', 'llvm-mc',
        'llvm-readobj', 'llvm-objdump', 'llvm-objcopy', 'lli'
    ]
    additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
    llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)

    _disallow(config, 'clang')
Exemplo n.º 10
0
def use_support_substitutions(config):
    # Set up substitutions for support tools.  These tools can be overridden at the CMake
    # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use
    # the just-built version.
    flags = []
    if platform.system() in ['Darwin']:
        try:
            out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
            res = 0
        except OSError:
            res = -1
        if res == 0 and out:
            sdk_path = lit.util.to_string(out)
            llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path)
            flags = ['-isysroot', sdk_path]
    elif platform.system() in ['OpenBSD', 'Linux']:
        flags = ['-pthread']

    config.target_shared_library_suffix = '.dylib' if platform.system() in [
        'Darwin'
    ] else '.so'
    config.substitutions.append(
        ('%target-shared-library-suffix', config.target_shared_library_suffix))

    # Swift support
    swift_args = [
        '-module-cache-path',
        os.path.join(os.path.dirname(config.lldb_libs_dir),
                     'lldb-test-build.noindex', 'module-cache-clang')
    ]
    if platform.system() in ['Darwin']:
        swift_args += ['-sdk', sdk_path]
    tools = [
        ToolSubst('%target-swiftc',
                  command=config.swiftc,
                  extra_args=swift_args),
        ToolSubst('%target-swift-frontend',
                  command=config.swiftc[:-1],
                  extra_args=(['-frontend'] + swift_args))
    ]
    llvm_config.add_tool_substitutions(tools)

    additional_tool_dirs = []
    if config.lldb_lit_tools_dir:
        additional_tool_dirs.append(config.lldb_lit_tools_dir)

    llvm_config.use_clang(additional_flags=flags,
                          additional_tool_dirs=additional_tool_dirs,
                          required=True)

    if sys.platform == 'win32':
        _use_msvc_substitutions(config)

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False)
    if have_lld:
        config.available_features.add('lld')

    support_tools = [
        'yaml2obj', 'obj2yaml', 'llvm-pdbutil', 'llvm-mc', 'llvm-readobj',
        'llvm-objdump', 'llvm-objcopy'
    ]
    additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]
    llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs)
Exemplo n.º 11
0
config.excludes = ['CMakeLists.txt']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.join(os.path.dirname(__file__), 'binding')

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.test_run_dir, 'test')

libclc_inc = os.path.join(config.libclc_root, 'generic', 'include')

target = lit_config.params.get('target', '')
builtins = lit_config.params.get('builtins', '')
cpu = lit_config.params.get('cpu', '')
cpu = [] if cpu == '' else ["-mcpu=" + cpu]

llvm_config.use_default_substitutions()

llvm_config.use_clang(additional_flags=[
    "-fno-builtin", "-I", libclc_inc, "-target", target, "-Xclang",
    "-fdeclare-spirv-builtins", "-Xclang", "-mlink-builtin-bitcode", "-Xclang",
    os.path.join(config.llvm_libs_dir, "clc", builtins)
] + cpu)

config.substitutions.append(('%PATH%', config.environment['PATH']))

tool_dirs = [config.llvm_tools_dir]

tools = ['llvm-dis', 'not']

llvm_config.add_tool_substitutions(tools, tool_dirs)