diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -604,11 +604,16 @@ tool_substitutions = [] if ld_lld: tool_substitutions.append(ToolSubst(r'ld\.lld', command=ld_lld)) + self.config.available_features.add('ld.lld') if lld_link: tool_substitutions.append(ToolSubst('lld-link', command=lld_link)) + self.config.available_features.add('lld-link') if ld64_lld: tool_substitutions.append(ToolSubst(r'ld64\.lld', command=ld64_lld)) + self.config.available_features.add('ld64.lld') if wasm_ld: tool_substitutions.append(ToolSubst('wasm-ld', command=wasm_ld)) + self.config.available_features.add('wasm-ld') self.add_tool_substitutions(tool_substitutions) + return was_found diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld.lld b/llvm/utils/lit/tests/Inputs/lld-features/ld.lld new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld.lld.exe b/llvm/utils/lit/tests/Inputs/lld-features/ld.lld.exe new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld.lld.txt b/llvm/utils/lit/tests/Inputs/lld-features/ld.lld.txt new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/lld-features/ld.lld.txt @@ -0,0 +1,2 @@ +# REQUIRES: ld.lld +# RUN: true diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld b/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.exe b/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.exe new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.txt b/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.txt new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.txt @@ -0,0 +1,2 @@ +# REQUIRES: ld64.lld +# RUN: true diff --git a/llvm/utils/lit/tests/Inputs/lld-features/lit.cfg b/llvm/utils/lit/tests/Inputs/lld-features/lit.cfg new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/lld-features/lit.cfg @@ -0,0 +1,17 @@ +import lit.formats +config.name = 'search-env' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None +config.llvm_tools_dir = '' +import lit.llvm +lit.llvm.initialize(lit_config, config) +import os.path +curdir = os.path.dirname(__file__) +# The current directory contains files for each version of LLD, both with and +# without a .exe extension. The .exe versions will be found on Windows and the +# ones without will be found on Linux. Note that all files are just empty files, +# since the test doesn't actually use them. +lit.llvm.llvm_config.with_environment('PATH', curdir, append_path=True) +lit.llvm.llvm_config.use_lld() diff --git a/llvm/utils/lit/tests/Inputs/lld-features/lld-link b/llvm/utils/lit/tests/Inputs/lld-features/lld-link new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/lld-link.exe b/llvm/utils/lit/tests/Inputs/lld-features/lld-link.exe new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/lld-link.txt b/llvm/utils/lit/tests/Inputs/lld-features/lld-link.txt new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/lld-features/lld-link.txt @@ -0,0 +1,2 @@ +# REQUIRES: lld-link +# RUN: true diff --git a/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld b/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.exe b/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.exe new file mode 100644 diff --git a/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.txt b/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.txt new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.txt @@ -0,0 +1,2 @@ +# REQUIRES: wasm-ld +# RUN: true diff --git a/llvm/utils/lit/tests/lld-features.py b/llvm/utils/lit/tests/lld-features.py new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/lld-features.py @@ -0,0 +1,6 @@ +## Show that each of the LLD variants detected by use_lld comes with its own +## feature. + +# RUN: %{lit} %{inputs}/lld-features 2>&1 | FileCheck %s -DDIR=%p + +# CHECK: Passed: 4