Ejemplo n.º 1
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']

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

# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.debuginfo_tests_obj_root

llvm_config.use_default_substitutions()

tools = [
    ToolSubst('%test_debuginfo', command=os.path.join(
        config.debuginfo_tests_src_root, 'llgdb-tests', 'test_debuginfo.pl')),
    ToolSubst("%llvm_src_root", config.llvm_src_root),
    ToolSubst("%llvm_tools_dir", config.llvm_tools_dir),
]

def get_required_attr(config, attr_name):
  attr_value = getattr(config, attr_name, None)
  if attr_value == None:
    lit_config.fatal(
      "No attribute %r in test configuration! You may need to run "
      "tests from your build directory or add this attribute "
      "to lit.site.cfg " % attr_name)
  return attr_value

# If this is an MSVC environment, the tests at the root of the tree are
# unsupported. The local win_cdb test suite, however, is supported.
Ejemplo n.º 2
0
if asan_rtlib:
    ld64_cmd = 'DYLD_INSERT_LIBRARIES={} {}'.format(asan_rtlib, ld64_cmd)

ocamlc_command = '%s ocamlc -cclib -L%s %s' % (
    config.ocamlfind_executable, config.llvm_lib_dir, config.ocaml_flags)
ocamlopt_command = 'true'
if config.have_ocamlopt:
    ocamlopt_command = '%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s' % (
        config.ocamlfind_executable, config.llvm_lib_dir, config.llvm_lib_dir,
        config.ocaml_flags)

opt_viewer_cmd = '%s %s/tools/opt-viewer/opt-viewer.py' % (
    sys.executable, config.llvm_src_root)

tools = [
    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)
Ejemplo n.º 3
0
    sys.executable, config.llvm_src_root)

llvm_original_di_preservation_cmd = os.path.join(
    config.llvm_src_root, 'utils', 'llvm-original-di-preservation.py')
config.substitutions.append(
    ('%llvm-original-di-preservation', "'%s' %s" %
     (config.python_executable, llvm_original_di_preservation_cmd)))

llvm_locstats_tool = os.path.join(config.llvm_tools_dir, 'llvm-locstats')
config.substitutions.append(
    ('%llvm-locstats',
     "'%s' %s" % (config.python_executable, llvm_locstats_tool)))
config.llvm_locstats_used = os.path.exists(llvm_locstats_tool)

tools = [
    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')),
    ToolSubst('%llvm-install-name-tool', FindTool('llvm-install-name-tool')),
    ToolSubst('%llvm-bitcode-strip', FindTool('llvm-bitcode-strip')),
    ToolSubst('%split-file', FindTool('split-file')),
]

# FIXME: Why do we have both `lli` and `%lli` that do slightly different things?
Ejemplo n.º 4
0
    'mlir-capi-execution-engine-test',
    'mlir-capi-ir-test',
    'mlir-capi-llvm-test',
    'mlir-capi-pass-test',
    'mlir-capi-sparse-tensor-test',
    'mlir-capi-quant-test',
    'mlir-capi-pdl-test',
    'mlir-cpu-runner',
    'mlir-linalg-ods-yaml-gen',
    'mlir-reduce',
    'mlir-pdll',
]

# The following tools are optional
tools.extend([
    ToolSubst('toy-ch1', unresolved='ignore'),
    ToolSubst('toy-ch2', unresolved='ignore'),
    ToolSubst('toy-ch3', unresolved='ignore'),
    ToolSubst('toy-ch4', unresolved='ignore'),
    ToolSubst('toy-ch5', unresolved='ignore'),
    ToolSubst('%linalg_test_lib_dir', config.linalg_test_lib_dir, unresolved='ignore'),
    ToolSubst('%mlir_runner_utils_dir', config.mlir_runner_utils_dir, unresolved='ignore'),
    ToolSubst('%spirv_wrapper_library_dir', config.spirv_wrapper_library_dir, unresolved='ignore'),
    ToolSubst('%vulkan_wrapper_library_dir', config.vulkan_wrapper_library_dir, unresolved='ignore'),
    ToolSubst('%mlir_integration_test_dir', config.mlir_integration_test_dir, unresolved='ignore'),
])

python_executable = config.python_executable
# Python configuration with sanitizer requires some magic preloading. This will only work on clang/linux.
# TODO: detect Darwin/Windows situation (or mark these tests as unsupported on these platforms).
if "asan" in config.available_features and "Linux" in config.host_os:
Ejemplo n.º 5
0
    def use_clang(self,
                  additional_tool_dirs=[],
                  additional_flags=[],
                  required=True):
        """Configure the test suite to be able to invoke clang.

        Sets up some environment variables important to clang, locates a
        just-built or installed clang, and add a set of standard
        substitutions useful to any test suite that makes use of clang.

        """
        # Clear some environment variables that might affect Clang.
        #
        # This first set of vars are read by Clang, but shouldn't affect tests
        # that aren't specifically looking for these features, or are required
        # simply to run the tests at all.
        #
        # FIXME: Should we have a tool that enforces this?

        # safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
        #                  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
        #                  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
        #                  'VC80COMNTOOLS')
        possibly_dangerous_env_vars = [
            'COMPILER_PATH', 'RC_DEBUG_OPTIONS', 'CINDEXTEST_PREAMBLE_FILE',
            'LIBRARY_PATH', 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
            'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', 'LIBCLANG_TIMING',
            'LIBCLANG_OBJTRACKING', 'LIBCLANG_LOGGING',
            'LIBCLANG_BGPRIO_INDEX', 'LIBCLANG_BGPRIO_EDIT',
            'LIBCLANG_NOTHREADS', 'LIBCLANG_RESOURCE_USAGE',
            'LIBCLANG_CODE_COMPLETION_LOGGING'
        ]
        # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
        if platform.system() != 'Windows':
            possibly_dangerous_env_vars.append('INCLUDE')

        self.clear_environment(possibly_dangerous_env_vars)

        # Tweak the PATH to include the tools dir and the scripts dir.
        # Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
        exe_dir_props = [
            self.config.name.lower() + '_tools_dir', 'clang_tools_dir',
            'llvm_tools_dir'
        ]
        paths = [
            getattr(self.config, pp) for pp in exe_dir_props
            if getattr(self.config, pp, None)
        ]
        paths = additional_tool_dirs + paths
        self.with_environment('PATH', paths, append_path=True)

        lib_dir_props = [
            self.config.name.lower() + '_libs_dir', 'clang_libs_dir',
            'llvm_shlib_dir', 'llvm_libs_dir'
        ]
        paths = [
            getattr(self.config, pp) for pp in lib_dir_props
            if getattr(self.config, pp, None)
        ]

        self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)

        # Discover the 'clang' and 'clangcc' to use.

        self.config.clang = self.use_llvm_tool('clang',
                                               search_env='CLANG',
                                               required=required)

        shl = getattr(self.config, 'llvm_shlib_dir', None)
        pext = getattr(self.config, 'llvm_plugin_ext', None)
        if shl:
            self.config.substitutions.append(('%llvmshlibdir', shl))
        if pext:
            self.config.substitutions.append(('%pluginext', pext))

        builtin_include_dir = self.get_clang_builtin_include_dir(
            self.config.clang)
        tool_substitutions = [
            ToolSubst('%clang',
                      command=self.config.clang,
                      extra_args=additional_flags),
            ToolSubst(
                '%clang_analyze_cc1',
                command='%clang_cc1',
                extra_args=['-analyze', '%analyze', '-setup-static-analyzer'] +
                additional_flags),
            ToolSubst('%clang_cc1',
                      command=self.config.clang,
                      extra_args=[
                          '-cc1', '-internal-isystem', builtin_include_dir,
                          '-nostdsysteminc'
                      ] + additional_flags),
            ToolSubst('%clang_cpp',
                      command=self.config.clang,
                      extra_args=['--driver-mode=cpp'] + additional_flags),
            ToolSubst('%clang_cl',
                      command=self.config.clang,
                      extra_args=['--driver-mode=cl'] + additional_flags),
            ToolSubst('%clangxx',
                      command=self.config.clang,
                      extra_args=['--driver-mode=g++'] + additional_flags),
        ]
        self.add_tool_substitutions(tool_substitutions)

        self.config.substitutions.append(
            ('%itanium_abi_triple',
             self.make_itanium_abi_triple(self.config.target_triple)))
        self.config.substitutions.append(
            ('%ms_abi_triple',
             self.make_msabi_triple(self.config.target_triple)))
        self.config.substitutions.append(
            ('%resource_dir', builtin_include_dir))

        # The host triple might not be set, at least if we're compiling clang from
        # an already installed llvm.
        if self.config.host_triple and self.config.host_triple != '@LLVM_HOST_TRIPLE@':
            self.config.substitutions.append(
                ('%target_itanium_abi_host_triple', '--target=%s' %
                 self.make_itanium_abi_triple(self.config.host_triple)))
        else:
            self.config.substitutions.append(
                ('%target_itanium_abi_host_triple', ''))

        # FIXME: Find nicer way to prohibit this.
        self.config.substitutions.append(
            (' clang ',
             """\"*** Do not use 'clang' in tests, use '%clang'. ***\""""))
        self.config.substitutions.append(
            (' clang\+\+ ',
             """\"*** Do not use 'clang++' in tests, use '%clangxx'. ***\""""))
        self.config.substitutions.append((
            ' clang-cc ',
            """\"*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***\""""
        ))
        self.config.substitutions.append(
            (' clang-cl ',
             """\"*** Do not use 'clang-cl' in tests, use '%clang_cl'. ***\""""
             ))
        self.config.substitutions.append((
            ' clang -cc1 -analyze ',
            """\"*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***\""""
        ))
        self.config.substitutions.append((
            ' clang -cc1 ',
            """\"*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***\""""
        ))
        self.config.substitutions.append(
            (' %clang-cc1 ',
             """\"*** invalid substitution, use '%clang_cc1'. ***\""""))
        self.config.substitutions.append(
            (' %clang-cpp ',
             """\"*** invalid substitution, use '%clang_cpp'. ***\""""))
        self.config.substitutions.append(
            (' %clang-cl ',
             """\"*** invalid substitution, use '%clang_cl'. ***\""""))
Ejemplo n.º 6
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']

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

# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.debuginfo_tests_obj_root

llvm_config.use_default_substitutions()

tools = [
    ToolSubst('%test_debuginfo', command=os.path.join(
        config.debuginfo_tests_src_root, 'llgdb-tests', 'test_debuginfo.pl')),
]

def get_required_attr(config, attr_name):
  attr_value = getattr(config, attr_name, None)
  if attr_value == None:
    lit_config.fatal(
      "No attribute %r in test configuration! You may need to run "
      "tests from your build directory or add this attribute "
      "to lit.site.cfg " % attr_name)
  return attr_value

# If this is an MSVC environment, the tests at the root of the tree are
# unsupported. The local win_cdb test suite, however, is supported.
is_msvc = get_required_attr(config, "is_msvc")
if is_msvc:
Ejemplo n.º 7
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 sys.platform != 'win32':
        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, use_installed=True)


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

    have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs,
                                   required=False, use_installed=True)
    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.º 8
0
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.npcomp_obj_root, 'test')
config.npcomp_tools_dir = os.path.join(config.npcomp_obj_root, 'tools')
config.npcomp_runtime_shlib = os.path.join(
    config.npcomp_obj_root,
    'lib',
    'libNPCOMPCompilerRuntimeShlib' + config.llvm_shlib_ext
)

# Tweak the PATH and PYTHONPATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
llvm_config.with_environment('PYTHONPATH', [
    os.path.join(config.npcomp_obj_root, "python")
],
                             append_path=True)

tool_dirs = [
        os.path.join(config.npcomp_tools_dir, 'npcomp-opt'),
        os.path.join(config.npcomp_tools_dir, 'npcomp-run-mlir'),
        config.llvm_tools_dir,
]
tools = [
    'npcomp-opt',
    'npcomp-run-mlir',
    ToolSubst('%npcomp_runtime_shlib', config.npcomp_runtime_shlib),
]

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 9
0
from lit.llvm.subst import FindTool

# Configuration file for the 'lit' test runner.

# name: The name of this test suite.
config.name = 'IGC'

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

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.ll']

# excludes: A list of directories  and files to exclude from the testsuite.
config.excludes = ['CMakeLists.txt']

# 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()

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

tool_dirs = [config.igc_opt_dir, config.llvm_tools_dir]
tools = [ToolSubst('igc_opt')]

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 10
0
def configure_dexter_substitutions():
    """Configure substitutions for host platform and return list of dependencies
  """
    # Produce dexter path, lldb path, and combine into the %dexter substitution
    # for running a test.
    dexter_path = os.path.join(config.cross_project_tests_src_root,
                               'debuginfo-tests', 'dexter', 'dexter.py')
    dexter_test_cmd = '"{}" "{}" test'.format(sys.executable, dexter_path)
    if lldb_path is not None:
        dexter_test_cmd += ' --lldb-executable "{}"'.format(lldb_path)
    tools.append(ToolSubst('%dexter', dexter_test_cmd))

    # For testing other bits of dexter that aren't under the "test" subcommand,
    # have a %dexter_base substitution.
    dexter_base_cmd = '"{}" "{}"'.format(sys.executable, dexter_path)
    tools.append(ToolSubst('%dexter_base', dexter_base_cmd))

    # Set up commands for DexTer regression tests.
    # Builder, debugger, optimisation level and several other flags differ
    # depending on whether we're running a unix like or windows os.
    if platform.system() == 'Windows':
        # The Windows builder script uses lld.
        dependencies = ['clang', 'lld-link']
        dexter_regression_test_builder = 'clang-cl_vs2015'
        dexter_regression_test_debugger = 'dbgeng'
        dexter_regression_test_cflags = '/Zi /Od'
        dexter_regression_test_ldflags = '/Zi'
    else:
        # Use lldb as the debugger on non-Windows platforms.
        dependencies = ['clang', 'lldb']
        dexter_regression_test_builder = 'clang'
        dexter_regression_test_debugger = 'lldb'
        dexter_regression_test_cflags = '-O0 -glldb'
        dexter_regression_test_ldflags = ''

    tools.append(
        ToolSubst('%dexter_regression_test_builder',
                  dexter_regression_test_builder))
    tools.append(
        ToolSubst('%dexter_regression_test_debugger',
                  dexter_regression_test_debugger))
    tools.append(
        ToolSubst('%dexter_regression_test_cflags',
                  dexter_regression_test_cflags))
    tools.append(
        ToolSubst('%dexter_regression_test_ldflags',
                  dexter_regression_test_cflags))

    # Typical command would take the form:
    # ./path_to_py/python.exe ./path_to_dex/dexter.py test --fail-lt 1.0 -w --builder clang --debugger lldb --cflags '-O0 -g'
    # Exclude build flags for %dexter_regression_base.
    dexter_regression_test_base = ' '.join(
        # "python", "dexter.py", test, fail_mode, builder, debugger, cflags, ldflags
        [
            '"{}"'.format(sys.executable), '"{}"'.format(dexter_path), 'test',
            '--fail-lt 1.0 -w', '--debugger', dexter_regression_test_debugger
        ])
    tools.append(
        ToolSubst('%dexter_regression_base', dexter_regression_test_base))

    # Include build flags for %dexter_regression_test.
    dexter_regression_test_build = ' '.join([
        dexter_regression_test_base, '--builder',
        dexter_regression_test_builder, '--cflags "',
        dexter_regression_test_cflags + '"', '--ldflags "',
        dexter_regression_test_ldflags + '"'
    ])
    tools.append(
        ToolSubst('%dexter_regression_test', dexter_regression_test_build))
    return dependencies
Ejemplo n.º 11
0
# 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.mlir_obj_root, 'test')

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

tool_dirs = [config.mlir_tools_dir, config.llvm_tools_dir]
tools = [
    'mlir-opt',
    'mlir-tblgen',
    'mlir-translate',
    'mlir-edsc-builder-api-test',
]

# The following tools are optional
tools.extend([
    ToolSubst('toy-ch1', unresolved='ignore'),
    ToolSubst('toy-ch2', unresolved='ignore'),
    ToolSubst('toy-ch3', unresolved='ignore'),
    ToolSubst('toy-ch4', unresolved='ignore'),
    ToolSubst('toy-ch5', unresolved='ignore'),
    ToolSubst('%linalg_test_lib_dir',
              config.linalg_test_lib_dir,
              unresolved='ignore'),
])

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 12
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']

# test_source_root: The root path where tests are located.
config.test_source_root = config.cross_project_tests_src_root

# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.cross_project_tests_obj_root

llvm_config.use_default_substitutions()

tools = [
    ToolSubst('%test_debuginfo',
              command=os.path.join(config.cross_project_tests_src_root,
                                   'debuginfo-tests', 'llgdb-tests',
                                   'test_debuginfo.pl')),
    ToolSubst("%llvm_src_root", config.llvm_src_root),
    ToolSubst("%llvm_tools_dir", config.llvm_tools_dir),
]


def get_required_attr(config, attr_name):
    attr_value = getattr(config, attr_name, None)
    if attr_value == None:
        lit_config.fatal(
            "No attribute %r in test configuration! You may need to run "
            "tests from your build directory or add this attribute "
            "to lit.site.cfg " % attr_name)
    return attr_value
Ejemplo n.º 13
0
# test_exec_root: The root path where integration tests should be run.
config.test_exec_root = os.path.join(config.mlir_obj_root, 'integration_test')

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

llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])

llvm_config.use_default_substitutions()

# excludes: A list of directories to exclude from the integration testsuite.
config.excludes = ['CMakeLists.txt', 'README.txt', 'LICENSE.txt']

# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
tool_dirs = [config.mlir_tools_dir, config.llvm_tools_dir]
tools = [
    'mlir-opt',
    'mlir-cpu-runner',
]

# The following tools are optional.
tools.extend([
    ToolSubst('%mlir_integration_test_dir',
              config.mlir_integration_test_dir,
              unresolved='ignore'),
])

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 14
0
    'LICENSE.txt',
    'lit.cfg.py',
    'lit.site.cfg.py',
]

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

tool_dirs = [
    config.pml_bin_dir,
    config.llvm_tools_dir,
]
tools = [
    'pmlc-jit',
    'pmlc-opt',
    ToolSubst('cc_test', FindTool('plaidml_edsl_tests_cc_test')),
]

llvm_config.add_tool_substitutions(tools, tool_dirs)

# FileCheck -enable-var-scope is enabled by default in MLIR test
# This option avoids to accidentally reuse variable across -LABEL match,
# it can be explicitly opted-in by prefixing the variable name with $
config.environment['FILECHECK_OPTS'] = "-enable-var-scope"

# LLVM can be configured with an empty default triple
# by passing ` -DLLVM_DEFAULT_TARGET_TRIPLE="" `.
# This is how LLVM filters tests that require the host target
# to be available for JIT tests.
if config.target_triple:
    config.available_features.add('default_triple')
Ejemplo n.º 15
0
if config.bolt_enable_runtime:
    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'),
Ejemplo n.º 16
0
config.suffixes = ['.c', '.cpp', '.m']

# 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']

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

# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.debuginfo_tests_obj_root

tools = [
    ToolSubst('%test_debuginfo',
              command=os.path.join(config.debuginfo_tests_src_root,
                                   'test_debuginfo.pl')),
]


def get_required_attr(config, attr_name):
    attr_value = getattr(config, attr_name, None)
    if attr_value == None:
        lit_config.fatal(
            "No attribute %r in test configuration! You may need to run "
            "tests from your build directory or add this attribute "
            "to lit.site.cfg " % attr_name)
    return attr_value


# If this is an MSVC environment, the tests at the root of the tree are
Ejemplo n.º 17
0
if config.flang_standalone_build:
    # For builds with FIR, set path for tco and enable related tests
    if config.flang_llvm_tools_dir != "":
        config.available_features.add('fir')
        if config.llvm_tools_dir != config.flang_llvm_tools_dir:
            llvm_config.with_environment('PATH',
                                         config.flang_llvm_tools_dir,
                                         append_path=True)

# 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'))

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)
Ejemplo n.º 18
0
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.flang_tools_dir, append_path=True)
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)

if config.flang_standalone_build:
    # For builds with FIR, set path for tco and enable related tests
    if config.flang_llvm_tools_dir != "":
        config.available_features.add('fir')
        if config.llvm_tools_dir != config.flang_llvm_tools_dir:
            llvm_config.with_environment('PATH',
                                         config.flang_llvm_tools_dir,
                                         append_path=True)

# 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'), unresolved='fatal')]

if config.include_flang_new_driver_test:
    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'), unresolved='fatal'))
    tools.append(
        ToolSubst('%flang_fc1', command=FindTool('f18'), unresolved='fatal'))
Ejemplo n.º 19
0
llvm_config.use_default_substitutions()

llvm_config.config.environment['CLANG'] = config.bolt_clang
llvm_config.config.environment['LLD'] = config.bolt_lld
llvm_config.use_clang()
llvm_config.use_llvm_tool('lld', required=True, search_env='LLD')

config.substitutions.append(('%cflags', '-no-pie -gdwarf-4'))
config.substitutions.append(('%cxxflags', '-no-pie -gdwarf-4'))

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('perf2bolt', unresolved='fatal'),
    ToolSubst('yaml2obj', unresolved='fatal'),
    ToolSubst('llvm-mc', unresolved='fatal'),
    ToolSubst('llvm-nm', unresolved='fatal'),
    ToolSubst('llvm-objdump', unresolved='fatal'),
    ToolSubst('llvm-objcopy', unresolved='fatal'),
    ToolSubst('llvm-strip', unresolved='fatal'),
    ToolSubst('llvm-readelf', unresolved='fatal'),
    ToolSubst('link_fdata', command=link_fdata_cmd, unresolved='fatal'),
    ToolSubst('merge-fdata', unresolved='fatal'),
]
llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 20
0
# clang_src_dir is not used by these tests, but is required by
# use_clang(), so set it to "".
if not hasattr(config, 'clang_src_dir'):
    config.clang_src_dir = ""
llvm_config.use_clang()

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

tool_dirs = [config.llvm_tools_dir]

tools = [
    ToolSubst('%test_debuginfo',
              command=os.path.join(config.debuginfo_tests_src_root,
                                   'test_debuginfo.pl')),
]

llvm_config.add_tool_substitutions(tools, tool_dirs)

lit.util.usePlatformSdkOnDarwin(config, lit_config)

if platform.system() == 'Darwin':
    import subprocess
    xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version'])
    match = re.search('lldb-(\d+)', xcode_lldb_vers)
    if match:
        apple_lldb_vers = int(match.group(1))
        if apple_lldb_vers < 1000:
            config.available_features.add('apple-lldb-pre-1000')
Ejemplo n.º 21
0
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 = [
    'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format',
    'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
    ToolSubst('%clang_extdef_map', command=FindTool(
        'clang-extdef-mapping'), unresolved='ignore'),
]

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

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")
Ejemplo n.º 22
0
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 = [
    'c-index-test',
    'clang-check',
    'clang-diff',
    'clang-format',
    'opt',
    ToolSubst('%test_debuginfo',
              command=os.path.join(config.llvm_src_root, 'utils',
                                   'test_debuginfo.pl')),
    ToolSubst('%clang_func_map',
              command=FindTool('clang-func-mapping'),
              unresolved='ignore'),
]

if config.clang_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
Ejemplo n.º 23
0
# 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 = [
    'llvm-readobj',
    'llvm-objdump',  # XXXAR: needed by some CHERI tests
    'c-index-test',
    'clang-check',
    'clang-diff',
    'clang-format',
    'opt',
    ToolSubst('%clang_func_map',
              command=FindTool('clang-func-mapping'),
              unresolved='ignore'),
]

if config.clang_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
Ejemplo n.º 24
0
tools = [
    'apinotes-test',
    'c-index-test',
    'clang-diff',
    'clang-format',
    'clang-repl',
    'clang-offload-packager',
    'clang-tblgen',
    'clang-scan-deps',
    'opt',
    'llvm-ifs',
    'yaml2obj',
    'clang-linker-wrapper',
    ToolSubst('%clang_extdef_map',
              command=FindTool('clang-extdef-mapping'),
              unresolved='ignore'),
    ToolSubst('%clang_dxc',
              command=config.clang,
              extra_args=['--driver-mode=dxc']),
]

if config.clang_examples:
    config.available_features.add('examples')


def have_host_jit_support():
    clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)

    if not clang_repl_exe:
        print('clang-repl not found')
Ejemplo n.º 25
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', 'Examples', 'tosa', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'
]

# 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.mlir_hlo_obj_root, 'tests')
config.mlir_hlo_tools_dir = os.path.join(config.mlir_hlo_obj_root, 'bin')

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

tool_dirs = [
    config.mlir_hlo_tools_dir,
    config.llvm_tools_dir,
]
tools = [
    'mlir-hlo-opt',
    'mlir-cpu-runner',
    ToolSubst('%mlir_runner_utils_dir',
              config.mlir_runner_utils_dir,
              unresolved='ignore'),
]

llvm_config.add_tool_substitutions(tools, tool_dirs)
Ejemplo n.º 26
0
config.name = 'MLIR ' + os.path.basename(config.mlir_test_dir)

config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.cc', '.hlo', '.hlotxt', '.json', '.mlir', '.pbtxt', '.py']

# test_source_root: The root path where tests are located.
config.test_source_root = config.mlir_test_dir

# 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'))
Ejemplo n.º 27
0
llvm_config.with_environment(
    "LD_LIBRARY_PATH",
    os.path.join(config.oneflow_obj_root, "_deps/glog-build"),
    append_path=True,
)

llvm_config.with_environment("ONEFLOW_MLIR_STDOUT", "1")
llvm_config.with_environment("ONEFLOW_MLIR_ENABLE_CODEGEN_FUSERS", "1")
llvm_config.with_environment("ONEFLOW_MLIR_ENABLE_ROUND_TRIP", "1")
llvm_config.with_environment(
    "PYTHONPATH",
    os.path.join(config.oneflow_src_root, "python"),
    append_path=True,
)

tool_dirs = [config.oneflow_tools_dir, config.llvm_tools_dir]
tools = ["oneflow-opt", "oneflow-translate", "oneflow-runner"]
tools.extend([
    ToolSubst("%linalg_test_lib_dir", config.llvm_lib_dir,
              unresolved="ignore"),
    ToolSubst("%test_exec_root", config.test_exec_root, unresolved="ignore"),
])
llvm_config.add_tool_substitutions(tools, tool_dirs)

try:
    import oneflow_iree.compiler

    config.WITH_ONEFLOW_IREE = True
except ImportError:
    config.WITH_ONEFLOW_IREE = False
Ejemplo n.º 28
0
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.flang_tools_dir, append_path=True)
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)

if config.flang_standalone_build:
    # For builds with FIR, set path for tco and enable related tests
    if config.flang_llvm_tools_dir != "":
        config.available_features.add('fir')
        if config.llvm_tools_dir != config.flang_llvm_tools_dir:
            llvm_config.with_environment('PATH', config.flang_llvm_tools_dir, append_path=True)

# For each occurrence of a flang tool name, replace it with the full path to
# the build directory holding that tool.
tools = [
        ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'),
    ToolSubst('%flang_fc1', command=FindTool('flang-new'), extra_args=['-fc1'],
        unresolved='fatal')]

# Flang has several unimplemented features. TODO messages are used to mark and fail if these
# features are exercised. TODOs exit with an error in non-assert builds but in assert builds
# it aborts. To catch aborts, the `--crash` option for the `not` command has to be used.
if 'asserts' in config.available_features:
    tools.append(ToolSubst('%not_todo_cmd', command=FindTool('not'), extra_args=['--crash'],
        unresolved='fatal'))
else:
    tools.append(ToolSubst('%not_todo_cmd', command=FindTool('not'), unresolved='fatal'))

# Define some variables to help us test that the flang runtime doesn't depend on
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
Ejemplo n.º 29
0
# pylint: disable=undefined-variable

# name: The name of this test suite.
config.name = 'TFRT'

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

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.mlir']

# test_source_root: The root path where tests are located.
config.test_source_root = config.tfrt_test_dir

# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.runfile_srcdir

llvm_config.use_default_substitutions()

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

tool_dirs = config.tfrt_tools_dirs + [config.llvm_tools_dir]

tool_names = [
    'bef_executor', 'tfrt_translate', 'tfrt_opt', 'code_size_test_driver'
]
tools = [ToolSubst(s, unresolved='ignore') for s in tool_names]
llvm_config.add_tool_substitutions(tools, tool_dirs)
# pylint: enable=undefined-variable
Ejemplo n.º 30
0
    def use_clang(self, required=True):
        """Configure the test suite to be able to invoke clang.

        Sets up some environment variables important to clang, locates a
        just-built or installed clang, and add a set of standard
        substitutions useful to any test suite that makes use of clang.

        """
        # Clear some environment variables that might affect Clang.
        #
        # This first set of vars are read by Clang, but shouldn't affect tests
        # that aren't specifically looking for these features, or are required
        # simply to run the tests at all.
        #
        # FIXME: Should we have a tool that enforces this?

        # safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
        #                  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
        #                  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
        #                  'VC80COMNTOOLS')
        possibly_dangerous_env_vars = [
            'COMPILER_PATH', 'RC_DEBUG_OPTIONS', 'CINDEXTEST_PREAMBLE_FILE',
            'LIBRARY_PATH', 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
            'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', 'LIBCLANG_TIMING',
            'LIBCLANG_OBJTRACKING', 'LIBCLANG_LOGGING',
            'LIBCLANG_BGPRIO_INDEX', 'LIBCLANG_BGPRIO_EDIT',
            'LIBCLANG_NOTHREADS', 'LIBCLANG_RESOURCE_USAGE',
            'LIBCLANG_CODE_COMPLETION_LOGGING'
        ]
        # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
        if platform.system() != 'Windows':
            possibly_dangerous_env_vars.append('INCLUDE')

        self.clear_environment(possibly_dangerous_env_vars)

        # Tweak the PATH to include the tools dir and the scripts dir.
        # Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
        possible_paths = ['clang_tools_dir', 'llvm_tools_dir']
        paths = [
            getattr(self.config, pp) for pp in possible_paths
            if getattr(self.config, pp, None)
        ]
        self.with_environment('PATH', paths, append_path=True)

        paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
        self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)

        # Discover the 'clang' and 'clangcc' to use.

        self.config.clang = self.use_llvm_tool('clang',
                                               search_env='CLANG',
                                               required=required)
        if not self.config.clang:
            return

        self.config.substitutions.append(
            ('%llvmshlibdir', self.config.llvm_shlib_dir))
        self.config.substitutions.append(
            ('%pluginext', self.config.llvm_plugin_ext))

        builtin_include_dir = self.get_clang_builtin_include_dir(
            self.config.clang)
        clang_cc1_args = [
            '-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc'
        ]
        cheri128_cc1_args = clang_cc1_args + [
            '-triple', 'cheri-unknown-freebsd', '-target-cpu', 'cheri128',
            '-cheri-size', '128', '-mllvm', '-verify-machineinstrs'
        ]
        cheri256_cc1_args = clang_cc1_args + [
            '-triple', 'cheri-unknown-freebsd', '-target-cpu', 'cheri256',
            '-cheri-size', '256', '-mllvm', '-verify-machineinstrs'
        ]

        default_cheri_size = self.lit_config.params['CHERI_CAP_SIZE']
        if default_cheri_size == '16':
            self.config.available_features.add("cheri_is_128")
            cheri_cc1_args = cheri128_cc1_args
            default_cheri_cpu = 'cheri128'

        else:
            assert default_cheri_size == '32', "Invalid -DCHERI_CAP_SIZE=" + default_cheri_size
            self.config.available_features.add("cheri_is_256")
            default_cheri_cpu = 'cheri256'
            cheri_cc1_args = cheri256_cc1_args

        cheri_clang_args = [
            '-target', 'cheri-unknown-freebsd', '-nostdinc',
            '-mcpu=' + default_cheri_cpu, '-msoft-float'
        ]

        tool_substitutions = [
            # CHERI substitutions (order is important due to repeated substitutions!)
            ToolSubst('%cheri_purecap_cc1',
                      command='%cheri_cc1',
                      extra_args=['-target-abi', 'purecap']),
            ToolSubst('%cheri128_purecap_cc1',
                      command='%cheri128_cc1',
                      extra_args=['-target-abi', 'purecap']),
            ToolSubst('%cheri256_purecap_cc1',
                      command='%cheri256_cc1',
                      extra_args=['-target-abi', 'purecap']),
            ToolSubst('%cheri_cc1',
                      command=self.config.clang,
                      extra_args=cheri_cc1_args),
            ToolSubst('%cheri128_cc1',
                      command=self.config.clang,
                      extra_args=cheri128_cc1_args),
            ToolSubst('%cheri256_cc1',
                      command=self.config.clang,
                      extra_args=cheri256_cc1_args),
            ToolSubst('%cheri_clang',
                      command=self.config.clang,
                      extra_args=cheri_clang_args),
            ToolSubst('%cheri_purecap_clang',
                      command=self.config.clang,
                      extra_args=cheri_clang_args + ['-mabi=purecap']),
            # For the tests in Driver that don't depend on the capability size
            ToolSubst('%plain_clang_cheri_triple_allowed',
                      command=self.config.clang),
            ToolSubst('%clang', command=self.config.clang),
            ToolSubst('%clang_analyze_cc1',
                      command='%clang_cc1',
                      extra_args=['-analyze', '%analyze']),
            ToolSubst('%clang_cc1',
                      command=self.config.clang,
                      extra_args=clang_cc1_args),
            ToolSubst('%clang_cpp',
                      command=self.config.clang,
                      extra_args=['--driver-mode=cpp']),
            ToolSubst('%clang_cl',
                      command=self.config.clang,
                      extra_args=['--driver-mode=cl']),
            ToolSubst('%clangxx',
                      command=self.config.clang,
                      extra_args=['--driver-mode=g++']),
        ]
        self.add_tool_substitutions(tool_substitutions)

        self.config.substitutions.append(
            ('%itanium_abi_triple',
             self.make_itanium_abi_triple(self.config.target_triple)))
        self.config.substitutions.append(
            ('%ms_abi_triple',
             self.make_msabi_triple(self.config.target_triple)))
        self.config.substitutions.append(
            ('%resource_dir', builtin_include_dir))

        # The host triple might not be set, at least if we're compiling clang from
        # an already installed llvm.
        if self.config.host_triple and self.config.host_triple != '@LLVM_HOST_TRIPLE@':
            self.config.substitutions.append(
                ('%target_itanium_abi_host_triple', '--target=%s' %
                 self.make_itanium_abi_triple(self.config.host_triple)))
        else:
            self.config.substitutions.append(
                ('%target_itanium_abi_host_triple', ''))
        if hasattr(self.config, "clang_src_dir"):
            self.config.substitutions.append(
                ('%src_include_dir', self.config.clang_src_dir + '/include'))

        # FIXME: Find nicer way to prohibit this.
        self.config.substitutions.append(
            (' clang ',
             """*** Do not use 'clang' in tests, use '%clang'. ***"""))
        self.config.substitutions.append(
            (' clang\+\+ ',
             """*** Do not use 'clang++' in tests, use '%clangxx'. ***"""))
        self.config.substitutions.append(
            (' clang-cc ',
             """*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***"""))
        self.config.substitutions.append((
            ' clang -cc1 -analyze ',
            """*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***"""
        ))
        self.config.substitutions.append((
            ' clang -cc1 ',
            """*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***"""))
        self.config.substitutions.append(
            (' %clang-cc1 ',
             """*** invalid substitution, use '%clang_cc1'. ***"""))
        self.config.substitutions.append(
            (' %clang-cpp ',
             """*** invalid substitution, use '%clang_cpp'. ***"""))
        self.config.substitutions.append(
            (' %clang-cl ',
             """*** invalid substitution, use '%clang_cl'. ***"""))

        # Only tests inside Driver/ should be using the %clang substitution with a cheri triple
        self.config.substitutions.append((
            '%clang_cc1.+cheri-unknown-freebsd.+',
            """false "*** Do not use 'clang_cc1' with cheri triple in tests, use 'cheri_cc1'. ***" """
        ))
        self.config.substitutions.append((
            '%clang.+cheri-unknown-freebsd.+',
            """false "*** Do not use 'clang' with cheri triple in tests, use 'cheri_clang'. ***" """
        ))