Ejemplo n.º 1
0
def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'
                                                    ] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
    lldbmi = ToolSubst('%lldbmi',
                       command=FindTool('lldb-mi'),
                       extra_args=['--synchronous'],
                       unresolved='ignore')
    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=[
                      '-S',
                      os.path.join(config.test_source_root, 'lit-lldb-init')
                  ]), lldbmi,
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'), 'lldb-test'
    ]

    llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir])
    if lldbmi.was_resolved:
        config.available_features.add('lldb-mi')
Ejemplo n.º 2
0
def _use_msvc_substitutions(config):
    # If running from a Visual Studio Command prompt (e.g. vcvars), this will
    # detect the include and lib paths, and find cl.exe and link.exe and create
    # substitutions for each of them that explicitly specify /I and /L paths
    cl = lit.util.which('cl')
    link = lit.util.which('link')

    if not cl or not link:
        return

    cl = '"' + cl + '"'
    link = '"' + link + '"'
    includes = os.getenv('INCLUDE', '').split(';')
    libs = os.getenv('LIB', '').split(';')

    config.available_features.add('msvc')
    compiler_flags = [
        '"/I{}"'.format(x) for x in includes if os.path.exists(x)
    ]
    linker_flags = [
        '"/LIBPATH:{}"'.format(x) for x in libs if os.path.exists(x)
    ]

    tools = [
        ToolSubst('%msvc_cl', command=cl, extra_args=compiler_flags),
        ToolSubst('%msvc_link', command=link, extra_args=linker_flags)
    ]
    llvm_config.add_tool_substitutions(tools)
    return
Ejemplo n.º 3
0
def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']

    build_script = os.path.dirname(__file__)
    build_script = os.path.join(build_script, 'build.py')
    build_script_args = [build_script,
                        '--compiler=any', # Default to best compiler
                        '--arch=' + str(config.lldb_bitness)]
    if config.lldb_lit_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_lit_tools_dir))
    if config.lldb_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir))
    if config.llvm_libs_dir:
        build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))

    lldb_init = _get_lldb_init_path(config)

    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=['--no-lldbinit', '-S', lldb_init],
                  unresolved='fatal'),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb'),
                  extra_args=['-S', lldb_init],
                  unresolved='fatal'),
        ToolSubst('%lldb-noinit',
                  command=FindTool('lldb'),
                  extra_args=['--no-lldbinit'],
                  unresolved='fatal'),
        ToolSubst('%lldb-server',
                  command=FindTool("lldb-server"),
                  extra_args=[],
                  unresolved='ignore'),
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'),
        ToolSubst('%platformserver',
                  command=FindTool('lldb-server'),
                  extra_args=['platform'],
                  unresolved='ignore'),
        'lldb-test',
        'lldb-vscode',
        ToolSubst('%build',
                  command="'" + sys.executable + "'",
                  extra_args=build_script_args)
        ]

    _disallow(config, 'lldb')
    _disallow(config, 'lldb-server')
    _disallow(config, 'debugserver')
    _disallow(config, 'platformserver')

    llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir])
Ejemplo n.º 4
0
def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'
                                                    ] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
    lldbmi = ToolSubst('%lldbmi',
                       command=FindTool('lldb-mi'),
                       extra_args=['--synchronous'],
                       unresolved='ignore')

    build_script = os.path.dirname(__file__)
    build_script = os.path.join(build_script, 'build.py')
    build_script_args = [
        build_script,
        '--compiler=any',  # Default to best compiler
        '--arch=' + str(config.lldb_bitness)
    ]
    if config.lldb_lit_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(
            config.lldb_lit_tools_dir))
    if config.lldb_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(
            config.lldb_tools_dir))
    if config.llvm_libs_dir:
        build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))

    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=[
                      '--no-lldbinit', '-S',
                      os.path.join(config.test_source_root, 'lit-lldb-init')
                  ]),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb'),
                  extra_args=[
                      '-S',
                      os.path.join(config.test_source_root, 'lit-lldb-init')
                  ]), lldbmi,
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'),
        ToolSubst('%platformserver',
                  command=FindTool('lldb-server'),
                  extra_args=['platform'],
                  unresolved='ignore'), 'lldb-test', 'lldb-instr',
        ToolSubst('%build',
                  command="'" + sys.executable + "'",
                  extra_args=build_script_args)
    ]

    llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir])
    # lldb-mi always fails without Python support
    if lldbmi.was_resolved and not config.lldb_disable_python:
        config.available_features.add('lldb-mi')
Ejemplo n.º 5
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')
Ejemplo n.º 6
0
def use_lldb_substitutions(config):
    # Set up substitutions for primary tools.  These tools must come from config.lldb_tools_dir
    # which is basically the build output directory.  We do not want to find these in path or
    # anywhere else, since they are specifically the programs which are actually being tested.

    dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server'
    dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
    lldbmi = ToolSubst('%lldbmi',
                       command=FindTool('lldb-mi'),
                       extra_args=['--synchronous'],
                       unresolved='ignore')


    build_script = os.path.dirname(__file__)
    build_script = os.path.join(build_script, 'build.py')
    build_script_args = [build_script,
                        '--compiler=any', # Default to best compiler
                        '--arch=' + str(config.lldb_bitness)]
    if config.lldb_lit_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_lit_tools_dir))
    if config.lldb_tools_dir:
        build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir))
    if config.llvm_libs_dir:
        build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))

    primary_tools = [
        ToolSubst('%lldb',
                  command=FindTool('lldb'),
                  extra_args=['--no-lldbinit', '-S',
                              os.path.join(config.test_source_root,
                                           'lit-lldb-init')]),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb'),
                  extra_args=['-S',
                              os.path.join(config.test_source_root,
                                           'lit-lldb-init')]),
        lldbmi,
        ToolSubst('%debugserver',
                  command=FindTool(dsname),
                  extra_args=dsargs,
                  unresolved='ignore'),
        ToolSubst('%platformserver',
                  command=FindTool('lldb-server'),
                  extra_args=['platform'],
                  unresolved='ignore'),
        'lldb-test',
        'lldb-instr',
        ToolSubst('%build',
                  command="'" + sys.executable + "'",
                  extra_args=build_script_args)
        ]

    llvm_config.add_tool_substitutions(primary_tools,
                                       [config.lldb_tools_dir])
    # lldb-mi always fails without Python support
    if lldbmi.was_resolved and not config.lldb_disable_python:
        config.available_features.add('lldb-mi')
Ejemplo n.º 7
0
def _AddToolSubstitutions(targets):
    paths = [
        t.lstrip('/').replace('@', '../').replace('//', '/').replace(':', '/')
        for t in targets
    ]
    llvm_config.add_tool_substitutions([
        ToolSubst(
            os.path.basename(p), os.path.join(cwd, p), unresolved='ignore')
        for p in paths
    ], [])
Ejemplo n.º 8
0
def use_lldb_repro_substitutions(config, mode):
    lldb_init = _get_lldb_init_path(config)
    substitutions = [
        ToolSubst('%lldb',
                  command=FindTool('lldb-repro'),
                  extra_args=[mode, '--no-lldbinit', '-S', lldb_init]),
        ToolSubst('%lldb-init',
                  command=FindTool('lldb-repro'),
                  extra_args=[mode, '-S', lldb_init]),
    ]
    llvm_config.add_tool_substitutions(substitutions, [config.lldb_tools_dir])
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)
Ejemplo 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 ['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)
Ejemplo n.º 11
0
def _use_msvc_substitutions(config):
    # If running from a Visual Studio Command prompt (e.g. vcvars), this will
    # detect the include and lib paths, and find cl.exe and link.exe and create
    # substitutions for each of them that explicitly specify /I and /L paths
    cl = lit.util.which('cl')
    link = lit.util.which('link')

    if not cl or not link:
        return

    cl = '"' + cl + '"'
    link = '"' + link + '"'
    includes = os.getenv('INCLUDE', '').split(';')
    libs = os.getenv('LIB', '').split(';')

    config.available_features.add('msvc')
    compiler_flags = ['"/I{}"'.format(x) for x in includes if os.path.exists(x)]
    linker_flags = ['"/LIBPATH:{}"'.format(x) for x in libs if os.path.exists(x)]

    tools = [
        ToolSubst('%msvc_cl', command=cl, extra_args=compiler_flags),
        ToolSubst('%msvc_link', command=link, extra_args=linker_flags)]
    llvm_config.add_tool_substitutions(tools)
    return
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
import lit.formats
from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst

# name: The name of this test suite.
config.name = 'Chapter 6 example'

# suffixes: A list of file extensions to treat as test files. This is overriden
# by individual lit.local.cfg files in the test subdirectories.
config.suffixes = ['.ll']

# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest()

# 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.ch6_build_path, 'test')

# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)

# Define common LLVM substitutions, such as 'FileCheck' and 'not'.
llvm_config.use_default_substitutions()

# Define substitutions that are specific to the external project.
tools = [ToolSubst('ch6_read_ir', unresolved='fatal')]
llvm_config.add_tool_substitutions(tools, [config.ch6_build_path])
Ejemplo n.º 14
0
# 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 = [
    'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'clang-tblgen',
    'opt',
    ToolSubst('%clang_func_map', command=FindTool(
        'clang-func-mapping'), unresolved='ignore'),
]

if config.clang_examples:
    config.available_features.add('examples')
    tools.append('clang-interpreter')

llvm_config.add_tool_substitutions(tools, tool_dirs)

# Plugins (loadable modules)
# TODO: This should be supplied by Makefile or autoconf.
if sys.platform in ['win32', 'cygwin']:
    has_plugins = config.enable_shared
else:
    has_plugins = True

if has_plugins and config.llvm_plugin_ext:
    config.available_features.add('plugins')

# Set available features we allow tests to conditionalize on.
#
if config.clang_default_cxx_stdlib != '':
    config.available_features.add('default-cxx-stdlib-set')
Ejemplo n.º 15
0
# For each occurrence of a flang tool name, replace it with the full path to
# the build directory holding that tool.
tools = [
  ToolSubst('%f18', command=FindTool('f18'),
    extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
    unresolved='fatal')
]

if config.include_flang_new_driver_test:
   tools.append(ToolSubst('%flang-new', command=FindTool('flang-new'), unresolved='fatal'))
   tools.append(ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'))
   tools.append(ToolSubst('%flang_fc1', command=FindTool('flang-new'),
    extra_args=['-fc1'], unresolved='fatal'))
else:
   tools.append(ToolSubst('%flang', command=FindTool('f18'),
    extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
    unresolved='fatal'))
   tools.append(ToolSubst('%flang_fc1', command=FindTool('f18'),
    extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
    unresolved='fatal'))

if config.flang_standalone_build:
    llvm_config.add_tool_substitutions(tools, [config.flang_llvm_tools_dir])
else:
    llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)

# Enable libpgmath testing
result = lit_config.params.get("LIBPGMATH")
if result:
    config.environment["LIBPGMATH"] = True
Ejemplo n.º 16
0
# 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

if config.spirv_tools_have_spirv_as:
    llvm_config.add_tool_substitutions(['spirv-as'],
                                       [config.spirv_tools_bin_dir])
    config.available_features.add('spirv-as')
    using_spirv_tools = True

if config.spirv_tools_have_spirv_link:
    llvm_config.add_tool_substitutions(['spirv-link'],
                                       [config.spirv_tools_bin_dir])
    config.available_features.add('spirv-link')
    using_spirv_tools = True
Ejemplo n.º 17
0
    'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-c-test', 'llvm-cxxfilt',
    'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder',
    'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])

# The following tools are optional
tools.extend([
    ToolSubst('llvm-go', unresolved='ignore'),
    ToolSubst('llvm-mt', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch3', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch4', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch5', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch6', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch7', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch8', unresolved='ignore')])

llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)

# Targets

config.targets = frozenset(config.targets_to_build.split())

for arch in config.targets_to_build.split():
    config.available_features.add(arch.lower() + '-registered-target')

# Features
known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
if (config.host_ldflags.find("-m32") < 0
    and any(config.llvm_host_triple.startswith(x) for x in known_arches)):
  config.available_features.add("llvm-64-bits")

config.available_features.add("host-byteorder-" + sys.byteorder + "-endian")
Ejemplo n.º 18
0
    config.available_features.add("bolt-runtime")

if config.gnu_ld:
    config.available_features.add("gnu_ld")

llvm_config.use_default_substitutions()

llvm_config.config.environment['CLANG'] = config.bolt_clang
llvm_config.use_clang()

llvm_config.config.environment['LD_LLD'] = config.bolt_lld
ld_lld = llvm_config.use_llvm_tool('ld.lld',
                                   required=True,
                                   search_env='LD_LLD')
llvm_config.config.available_features.add('ld.lld')
llvm_config.add_tool_substitutions([ToolSubst(r'ld\.lld', command=ld_lld)])

config.substitutions.append(('%cflags', ''))
config.substitutions.append(('%cxxflags', ''))

link_fdata_cmd = os.path.join(config.test_source_root, 'link_fdata.py')

tool_dirs = [config.llvm_tools_dir, config.test_source_root]

tools = [
    ToolSubst('llc', unresolved='fatal'),
    ToolSubst('llvm-dwarfdump', unresolved='fatal'),
    ToolSubst('llvm-bolt', unresolved='fatal'),
    ToolSubst('llvm-boltdiff', unresolved='fatal'),
    ToolSubst('llvm-bolt-heatmap', unresolved='fatal'),
    ToolSubst('perf2bolt', unresolved='fatal'),
Ejemplo n.º 19
0
    '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-tblgen',
    'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml',
    'FileCheck', 'yaml-bench', 'verify-uselistorder',
    ToolFilter('bugpoint', post='-'),
    ToolFilter('llc', pre=JUNKCHARS),
    ToolFilter('llvm-symbolizer', pre=JUNKCHARS),
    ToolFilter('opt', JUNKCHARS),
    ToolFilter('sancov', pre=JUNKCHARS),
    ToolFilter('sanstats', pre=JUNKCHARS),
    # Handle these specially as they are strings searched for during testing.
    ToolFilter(r'\| \bcount\b', verbatim=True),
    ToolFilter(r'\| \bnot\b', verbatim=True)]

llvm_config.add_tool_substitutions(required_tools, config.llvm_tools_dir)

# For tools that are optional depending on the config, we won't warn
# if they're missing.

optional_tools = [
    'llvm-go', 'llvm-mt', 'Kaleidoscope-Ch3', 'Kaleidoscope-Ch4',
    'Kaleidoscope-Ch5', 'Kaleidoscope-Ch6', 'Kaleidoscope-Ch7',
    'Kaleidoscope-Ch8']
llvm_config.add_tool_substitutions(optional_tools, config.llvm_tools_dir,
                                   warn_missing=False)

### Targets

config.targets = frozenset(config.targets_to_build.split())
Ejemplo n.º 20
0
])

# The following tools are optional
tools.extend([
    ToolSubst('llvm-go', unresolved='ignore'),
    ToolSubst('llvm-mt', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch3', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch4', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch5', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch6', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch7', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch8', unresolved='ignore'),
    ToolSubst('LLJITWithThinLTOSummaries', unresolved='ignore')
])

llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)

# Targets

config.targets = frozenset(config.targets_to_build.split())

for arch in config.targets_to_build.split():
    config.available_features.add(arch.lower() + '-registered-target')

# Features
known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
if (config.host_ldflags.find("-m32") < 0
        and any(config.llvm_host_triple.startswith(x) for x in known_arches)):
    config.available_features.add("llvm-64-bits")

config.available_features.add("host-byteorder-" + sys.byteorder + "-endian")
Ejemplo n.º 21
0
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.environ['RUNFILES_DIR']

if platform.system() == 'Windows':
    tool_patterns = [
        ToolSubst('FileCheck.exe', unresolved='fatal'),
        #  Handle these specially as they are strings searched for during testing.
        ToolSubst('count.exe', unresolved='fatal'),
        ToolSubst('not.exe', unresolved='fatal')
    ]

    llvm_config.config.substitutions.append(
        ('%python', '"%s"' % (sys.executable)))

    llvm_config.add_tool_substitutions(tool_patterns,
                                       [llvm_config.config.llvm_tools_dir])
else:
    llvm_config.use_default_substitutions()

llvm_config.config.substitutions.append(
    ('%tfrt_bindir', 'tensorflow/compiler/aot'))

# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)

tool_dirs = config.mlir_tf_tools_dirs + [
    config.mlir_tools_dir, config.llvm_tools_dir
]
tool_names = [
    'mlir-opt', 'mlir-translate', 'tf-opt', 'tf_tfl_translate',
    'flatbuffer_to_string', 'flatbuffer_translate', 'tf-mlir-translate',
Ejemplo n.º 22
0
if config.clang_staticanalyzer:
    config.available_features.add('staticanalyzer')
    tools.append('clang-check')

    if config.clang_staticanalyzer_z3 == '1':
        config.available_features.add('z3')

    check_analyzer_fixit_path = os.path.join(config.test_source_root,
                                             "Analysis",
                                             "check-analyzer-fixit.py")
    config.substitutions.append(
        ('%check_analyzer_fixit',
         '"%s" %s' % (config.python_executable, check_analyzer_fixit_path)))

llvm_config.add_tool_substitutions(tools, tool_dirs)

if llvm_config.add_tool_substitutions(['llvm-rc'], tool_dirs):
    config.available_features.add('llvm-rc')

config.substitutions.append(
    ('%hmaptool',
     "'%s' %s" % (config.python_executable,
                  os.path.join(config.clang_tools_dir, 'hmaptool'))))

config.substitutions.append(('%host_cc', config.host_cc))
config.substitutions.append(('%host_cxx', config.host_cxx))

# Plugins (loadable modules)
if config.has_plugins and config.llvm_plugin_ext:
    config.available_features.add('plugins')
Ejemplo n.º 23
0
config.excludes = ['Inputs']

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

config.test_exec_root = os.path.join(config.lld_obj_root, 'test')

llvm_config.use_default_substitutions()
llvm_config.use_lld()

tool_patterns = [
    'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil',
    'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
    'opt', 'llvm-dis']

llvm_config.add_tool_substitutions(tool_patterns)

# When running under valgrind, we mangle '-vg' onto the end of the triple so we
# can check it with XFAIL and XTARGET.
if lit_config.useValgrind:
    config.target_triple += '-vg'

# Running on ELF based *nix
if platform.system() in ['FreeBSD', 'Linux']:
    config.available_features.add('system-linker-elf')

# Set if host-cxxabi's demangler can handle target's symbols.
if platform.system() not in ['Windows']:
    config.available_features.add('demangler')

llvm_config.feature_config(
Ejemplo n.º 24
0
import lit
import lit.llvm

lit.llvm.initialize(lit_config, config)

from lit.llvm import llvm_config


config.name = 'PassManager'
config.test_format = lit.formats.ShTest()
config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
config.test_exec_root   = "@CMAKE_CURRENT_BINARY_DIR@"
config.suffixes = ['.c', '.ll']

config.substitutions.append((r'%dylibdir', "@CMAKE_LIBRARY_OUTPUT_DIR@"))

config.llvm_config_bindir = "@LLVM_BINDIR@"
llvm_config.add_tool_substitutions(
        ["clang", "opt", "FileCheck"],
        config.llvm_config_bindir)
Ejemplo n.º 25
0
config.substitutions.append(('%opencl_include_dir', config.opencl_include_dir))

if cl_options:
    config.substitutions.append(
        ('%sycl_options', ' sycl.lib /I' + config.sycl_include))
    config.substitutions.append(('%include_option', '/FI'))
    config.substitutions.append(('%debug_option', '/DEBUG'))
    config.substitutions.append(('%cxx_std_option', '/std:'))
else:
    config.substitutions.append(
        ('%sycl_options', ' -lsycl -I' + config.sycl_include))
    config.substitutions.append(('%include_option', '-include'))
    config.substitutions.append(('%debug_option', '-g'))
    config.substitutions.append(('%cxx_std_option', '-std='))

llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])

if not config.sycl_be:
    lit_config.error("SYCL backend is not specified")

# Mapping from SYCL_BE backend definition style to SYCL_DEVICE_FILTER used
# for backward compatibility
try:
    config.sycl_be = {
        'PI_OPENCL': 'opencl',
        'PI_CUDA': 'cuda',
        'PI_LEVEL_ZERO': 'level_zero'
    }[config.sycl_be]
except:
    # do nothing a we expect that new format of plugin values are used
    pass
Ejemplo n.º 26
0
    config.substitutions.append(
        ('%questa', os.path.join(config.questa_path, "vsim")))
    config.substitutions.append(
        ('%ieee-sim', os.path.join(config.questa_path, "vsim")))

ieee_sims = list(filter(lambda x: x[0] == '%ieee-sim', config.substitutions))
if len(ieee_sims) > 1:
    warnings.warn(
        f"You have multiple ieee-sim simulators configured, choosing: {ieee_sims[-1][1]}"
    )

# Enable ESI cosim tests if they have been built.
if config.esi_cosim_path != "":
    config.available_features.add('esi-cosim')
    config.substitutions.append(
        ('%ESIINC%', f'{config.circt_include_dir}/circt/Dialect/ESI/'))
    config.substitutions.append(('%ESICOSIM%', f'{config.esi_cosim_path}'))

# Enable ESI's Capnp tests if they're supported.
if config.esi_capnp != "":
    config.available_features.add('capnp')

# Enable Python bindings tests if they're supported.
if config.bindings_python_enabled:
    config.available_features.add('bindings_python')
if config.bindings_tcl_enabled:
    config.available_features.add('bindings_tcl')

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 27
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')
Ejemplo n.º 28
0
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

config.test_exec_root = os.path.join(config.lld_obj_root, 'test')

llvm_config.use_default_substitutions()
llvm_config.use_lld()

tool_patterns = [
    'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil',
    'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'llvm-strip',
    'obj2yaml', 'yaml2obj',
    'opt', 'llvm-dis']

llvm_config.add_tool_substitutions(tool_patterns)

# When running under valgrind, we mangle '-vg' onto the end of the triple so we
# can check it with XFAIL and XTARGET.
if lit_config.useValgrind:
    config.target_triple += '-vg'

# Running on ELF based *nix
if platform.system() in ['FreeBSD', 'Linux']:
    config.available_features.add('system-linker-elf')

# Set if host-cxxabi's demangler can handle target's symbols.
if platform.system() not in ['Windows']:
    config.available_features.add('demangler')

llvm_config.feature_config(
Ejemplo n.º 29
0
    'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-c-test', 'llvm-cxxfilt',
    'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder',
    'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])

# The following tools are optional
tools.extend([
    ToolSubst('llvm-go', unresolved='ignore'),
    ToolSubst('llvm-mt', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch3', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch4', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch5', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch6', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch7', unresolved='ignore'),
    ToolSubst('Kaleidoscope-Ch8', unresolved='ignore')])

llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)

for tool in ('llvm-exegesis', 'llvm-mca', 'llvm-rc'):
    if llvm_config.add_tool_substitutions([ToolSubst(tool, unresolved='break')], config.llvm_tools_dir):
        config.available_features.add('llvm-tool-' + tool)

# Targets

config.targets = frozenset(config.targets_to_build.split())

for arch in config.targets_to_build.split():
    config.available_features.add(arch.lower() + '-registered-target')

# Features
known_arches = ["x86_64", "mips64", "ppc64", "aarch64"]
if (config.host_ldflags.find("-m32") < 0