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')
def use_default_substitutions(self): tool_patterns = [ ToolSubst('FileCheck', unresolved='fatal'), # Handle these specially as they are strings searched for during testing. ToolSubst(r'\| \bcount\b', command=FindTool('count'), verbatim=True, unresolved='fatal'), ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal') ] default_cheri_size = self.lit_config.params['CHERI_CAP_SIZE'] tool_patterns.append( ToolSubst('%cheri_FileCheck', FindTool('FileCheck'), extra_args=['-D\\$CAP_SIZE=' + default_cheri_size])) if not self.lit_config.quiet: self.lit_config.note('Running tests for CHERI_CAP_SIZE=' + default_cheri_size) self.config.substitutions.append( ('%python', '"%s"' % (sys.executable))) self.add_tool_substitutions(tool_patterns, [self.config.llvm_tools_dir])
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')
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]), ToolSubst('%lldb-init', command=FindTool('lldb'), extra_args=['-S', lldb_init]), ToolSubst('%lldb-noinit', command=FindTool('lldb'), extra_args=['--no-lldbinit']), 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', 'lldb-vscode', ToolSubst('%build', command="'" + sys.executable + "'", extra_args=build_script_args) ] _disallow(config, 'lldb') _disallow(config, 'debugserver') _disallow(config, 'platformserver') llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir])
def use_default_substitutions(self): tool_patterns = [ ToolSubst('FileCheck', unresolved='fatal'), # Handle these specially as they are strings searched for during testing. ToolSubst(r'\| \bcount\b', command=FindTool( 'count'), verbatim=True, unresolved='fatal'), ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal')] self.config.substitutions.append(('%python', sys.executable)) self.add_tool_substitutions( tool_patterns, [self.config.llvm_tools_dir])
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 _add_cheri_tool_substitution(self, tool): assert tool in ('llc', 'opt', 'llvm-mc'), 'Invalid tool: ' + tool default_cheri_size = self.lit_config.params['CHERI_CAP_SIZE'] self.config.substitutions.append((r"\b{tool}\b.+\-target-abi\s+purecap\b", "\"---Don't use {tool} -target-abi purecap, " "use %cheri[128/256]_purecap_{tool} instead ---\"".format(tool=tool))) self.config.substitutions.append((r"\b{tool}\b.+\-mcpu=cheri.+", "\"---Don't use {tool} -mcpu=cheri, " "use %cheri[128/256]_{tool} instead ---\"".format(tool=tool))) if tool == 'llvm-mc': triple_opt = '-triple' purecap_args = ['-target-abi', 'purecap', '-position-independent'] else: triple_opt = '-mtriple' purecap_args = ['-target-abi', 'purecap', '-relocation-model', 'pic'] extra_args = [] if tool == "llc": # TODO: add this to clang as well? extra_args = ["-verify-machineinstrs"] cheri128_args = [triple_opt + '=cheri-unknown-freebsd', '-mcpu=cheri128', '-mattr=+cheri128'] + extra_args cheri256_args = [triple_opt + '=cheri-unknown-freebsd', '-mcpu=cheri256', '-mattr=+cheri256'] + extra_args riscv32_cheri_args = [triple_opt + '=riscv32-unknown-freebsd', '-mattr=+xcheri'] + extra_args riscv64_cheri_args = [triple_opt + '=riscv64-unknown-freebsd', '-mattr=+xcheri'] + extra_args riscv32_cheri_purecap_args = ['-target-abi', 'il32pc64', '-mattr=+cap-mode'] + riscv32_cheri_args riscv64_cheri_purecap_args = ['-target-abi', 'l64pc128', '-mattr=+cap-mode'] + riscv64_cheri_args if default_cheri_size == '16': self.config.available_features.add("cheri_is_128") self.config.substitutions.append(('%cheri_type', 'CHERI128')) default_args = cheri128_args else: assert default_cheri_size == '32', "Invalid -DCHERI_CAP_SIZE=" + default_cheri_size self.config.substitutions.append(('%cheri_type', 'CHERI256')) self.config.available_features.add("cheri_is_256") default_args = cheri256_args self.config.substitutions.append(('%cheri_cap_bytes', default_cheri_size)) tool_patterns = [ ToolSubst('%cheri_' + tool, FindTool(tool), extra_args=default_args), ToolSubst('%cheri128_' + tool, FindTool(tool), extra_args=cheri128_args), ToolSubst('%cheri256_' + tool, FindTool(tool), extra_args=cheri256_args), ToolSubst('%cheri_purecap_' + tool, FindTool(tool), extra_args=default_args + purecap_args), ToolSubst('%cheri128_purecap_' + tool, FindTool(tool), extra_args=cheri128_args + purecap_args), ToolSubst('%cheri256_purecap_' + tool, FindTool(tool), extra_args=cheri256_args + purecap_args), ToolSubst('%riscv32_cheri_' + tool, FindTool(tool), extra_args=riscv32_cheri_args), ToolSubst('%riscv64_cheri_' + tool, FindTool(tool), extra_args=riscv64_cheri_args), ToolSubst('%riscv32_cheri_purecap_' + tool, FindTool(tool), extra_args=riscv32_cheri_purecap_args), ToolSubst('%riscv64_cheri_purecap_' + tool, FindTool(tool), extra_args=riscv64_cheri_purecap_args), ] self.add_tool_substitutions(tool_patterns, [self.config.llvm_tools_dir])
def _add_cheri_tool_substitution(self, tool): assert tool in ('llc', 'opt', 'llvm-mc'), 'Invalid tool: ' + tool default_cheri_size = self.lit_config.params['CHERI_CAP_SIZE'] self.config.substitutions.append( (r"\b{tool}\b.+\-target-abi\s+purecap\b", "\"---Don't use {tool} -target-abi purecap, " "use %cheri[128/256]_purecap_{tool} instead ---\"".format( tool=tool))) self.config.substitutions.append( (r"\b{tool}\b.+\-mcpu=cheri.+", "\"---Don't use {tool} -mcpu=cheri, " "use %cheri[128/256]_{tool} instead ---\"".format(tool=tool))) if tool == 'llvm-mc': triple_arg = '-triple=cheri-unknown-freebsd' purecap_args = ['-target-abi', 'purecap', '-position-independent'] else: triple_arg = '-mtriple=cheri-unknown-freebsd' purecap_args = [ '-target-abi', 'purecap', '-relocation-model', 'pic' ] cheri128_args = [triple_arg, '-mcpu=cheri128', '-mattr=+cheri128'] cheri256_args = [triple_arg, '-mcpu=cheri256', '-mattr=+cheri256'] if default_cheri_size == '16': self.config.available_features.add("cheri_is_128") self.config.substitutions.append(('%cheri_type', 'CHERI128')) default_args = cheri128_args else: assert default_cheri_size == '32', "Invalid -DCHERI_CAP_SIZE=" + default_cheri_size self.config.substitutions.append(('%cheri_type', 'CHERI256')) self.config.available_features.add("cheri_is_256") default_args = cheri256_args tool_patterns = [ ToolSubst('%cheri_' + tool, FindTool(tool), extra_args=default_args), ToolSubst('%cheri128_' + tool, FindTool(tool), extra_args=cheri128_args), ToolSubst('%cheri256_' + tool, FindTool(tool), extra_args=cheri256_args), ToolSubst('%cheri_purecap_' + tool, FindTool(tool), extra_args=default_args + purecap_args), ToolSubst('%cheri128_purecap_' + tool, FindTool(tool), extra_args=cheri128_args + purecap_args), ToolSubst('%cheri256_purecap_' + tool, FindTool(tool), extra_args=cheri256_args + purecap_args), ] self.add_tool_substitutions(tool_patterns, [self.config.llvm_tools_dir])
llvm_config.use_default_substitutions() config.substitutions.append(('%host_cc', config.host_cc)) tool_dirs = [config.llvm_tools_dir, config.test_source_root] linker_tool = llvm_config.use_llvm_tool('ld', required=True) tools = [ ToolSubst('llvm-bolt', unresolved='fatal'), ToolSubst('perf2bolt', unresolved='fatal'), ToolSubst('yaml2obj', unresolved='fatal'), ToolSubst('llvm-mc', unresolved='fatal'), ToolSubst('linker', command=linker_tool, unresolved='fatal'), ToolSubst('link_fdata', command=FindTool('link_fdata.sh'), unresolved='fatal'), ] llvm_config.add_tool_substitutions(tools, tool_dirs) # Propagate path to symbolizer for ASan/MSan. llvm_config.with_system_environment( ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) config.substitutions.append(('%PATH%', config.environment['PATH'])) # 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
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'), 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:
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'), 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])
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) config.substitutions.append(('%B', config.flang_obj_root)) # For each occurrence of a flang 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.llvm_tools_dir, config.flang_tools_dir] flang_includes = "-I" + config.flang_intrinsic_modules_dir tools = [ ToolSubst('%flang', command=FindTool('flang'), unresolved='fatal'), ToolSubst('%f18', command=FindTool('f18'), unresolved='fatal'), ToolSubst('%f18_with_includes', command=FindTool('f18'), extra_args=[flang_includes], unresolved='fatal') ] llvm_config.add_tool_substitutions(tools, tool_dirs) # Enable libpgmath testing result = lit_config.params.get("LIBPGMATH") if result: config.environment["LIBPGMATH"] = True
# to be linked contain instrumented sanitizer code. ld64_cmd = config.ld64_executable asan_rtlib = get_asan_rtlib() 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) 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'), ] # FIXME: Why do we have both `lli` and `%lli` that do slightly different things? tools.extend([ 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dsymutil', 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-opt-fuzzer', 'llvm-lib', 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mcmarkup', 'llvm-modextract', 'llvm-nm',
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') ] # 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. if config.cc: libruntime = os.path.join(config.flang_lib_dir, 'libFortranRuntime.a') includes = os.path.join(config.flang_src_dir, 'runtime') if os.path.isfile(libruntime) and os.path.isdir(includes): config.available_features.add('c-compiler')
llvm_config.use_default_substitutions() config.substitutions.append(('%host_cc', config.host_cc)) config.substitutions.append(('%host_cxx', config.host_cxx)) tool_dirs = [config.llvm_tools_dir, config.test_source_root] linker_tool = llvm_config.use_llvm_tool('ld', required=True) tools = [ ToolSubst('llvm-bolt', unresolved='fatal'), ToolSubst('perf2bolt', unresolved='fatal'), ToolSubst('yaml2obj', unresolved='fatal'), ToolSubst('llvm-mc', unresolved='fatal'), ToolSubst('linker', command=linker_tool, unresolved='fatal'), ToolSubst('link_fdata', command=FindTool('link_fdata.sh'), unresolved='fatal'), ] llvm_config.add_tool_substitutions(tools, tool_dirs) # Propagate path to symbolizer for ASan/MSan. llvm_config.with_system_environment( ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) config.substitutions.append(('%PATH%', config.environment['PATH'])) # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']: has_plugins = config.enable_shared else:
# 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')] # 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. if config.cc: libruntime = os.path.join(config.flang_lib_dir, 'libFortranRuntime.a') includes = os.path.join(config.flang_src_dir, 'runtime') if os.path.isfile(libruntime) and os.path.isdir(includes): config.available_features.add('c-compiler') tools.append(ToolSubst('%cc', command=config.cc, unresolved='fatal')) tools.append(ToolSubst('%libruntime', command=libruntime, unresolved='fatal'))
# Propagate path to symbolizer for ASan/MSan. llvm_config.with_system_environment( ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) config.substitutions.append(('%PATH%', config.environment['PATH'])) # For each occurrence of a clang tool name, replace it with the full path to # the build directory holding that tool. We explicitly specify the directories # to search to ensure that we get the tools just built and not some random # tools that might happen to be in the user's PATH. tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir] tools = [ 'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'opt', 'llvm-ifs', 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') llvm_config.add_tool_substitutions(tools, tool_dirs)
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 = [ '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) config.substitutions.append( ('%hmaptool', "'%s' %s" % (config.python_executable, os.path.join(config.clang_tools_dir, 'hmaptool')))) # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']:
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-diff', 'clang-format', 'clang-tblgen', 'opt', 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') llvm_config.add_tool_substitutions(tools, tool_dirs)
# excludes: A list of directories 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.soll_obj_root, 'test') llvm_config.use_default_substitutions() tool_substitutions = [ ToolSubst('%soll', command=config.soll, extra_args=[]), ] llvm_config.add_tool_substitutions(tool_substitutions) # For each occurrence of a soll 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.soll_tools_dir, config.llvm_tools_dir] tools = [ 'opt', ToolSubst('%soll_extdef_map', command=FindTool('soll-extdef-mapping'), unresolved='ignore'), ] llvm_config.add_tool_substitutions(tools, tool_dirs)
# 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.
# 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'))
# 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', 'llvm-dwarfdump', # XXXAR: needed by some CHERI tests '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) config.substitutions.append( ('%hmaptool', "'%s' %s" % (config.python_executable, os.path.join(config.clang_tools_dir, 'hmaptool')))) # Plugins (loadable modules)
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) 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('%extract', FindTool('extract')), 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')), ] # FIXME: Why do we have both `lli` and `%lli` that do slightly different things? tools.extend([
# 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'), 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],
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'))
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)
'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')
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) 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?
config.environment['CLANG_BINARY'] = os.getenv('CLANG_BINARY') llvm_config.use_default_substitutions() # 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 = ['input', '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.fc_obj_root, 'test') # Tweak the PATH to include the tools dir. llvm_config.with_environment('PATH', config.fc_tools_dir, append_path=True) llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) # For each occurrence of a fc 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.llvm_tools_dir, config.fc_tools_dir] tools = [ToolSubst('%fc', command=FindTool('fc'), unresolved='fatal')] llvm_config.add_tool_substitutions(tools, tool_dirs)