[llvm] 20e1577 - [lld] Add a feature for each lld variant when use_lld is called
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue May 18 02:52:16 PDT 2021
Author: James Henderson
Date: 2021-05-18T10:51:27+01:00
New Revision: 20e1577d13ce8622b1ef709f7bc1c397df98e7e2
URL: https://github.com/llvm/llvm-project/commit/20e1577d13ce8622b1ef709f7bc1c397df98e7e2
DIFF: https://github.com/llvm/llvm-project/commit/20e1577d13ce8622b1ef709f7bc1c397df98e7e2.diff
LOG: [lld] Add a feature for each lld variant when use_lld is called
This allows tests to detect whether to run or not, dependent on which
LLD version is required for the test.
Reviewed by: thopre
Differential Revision: https://reviews.llvm.org/D101997
Added:
llvm/utils/lit/tests/Inputs/lld-features/ld.lld
llvm/utils/lit/tests/Inputs/lld-features/ld.lld.exe
llvm/utils/lit/tests/Inputs/lld-features/ld.lld.txt
llvm/utils/lit/tests/Inputs/lld-features/ld64.lld
llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.exe
llvm/utils/lit/tests/Inputs/lld-features/ld64.lld.txt
llvm/utils/lit/tests/Inputs/lld-features/lit.cfg
llvm/utils/lit/tests/Inputs/lld-features/lld-link
llvm/utils/lit/tests/Inputs/lld-features/lld-link.exe
llvm/utils/lit/tests/Inputs/lld-features/lld-link.txt
llvm/utils/lit/tests/Inputs/lld-features/wasm-ld
llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.exe
llvm/utils/lit/tests/Inputs/lld-features/wasm-ld.txt
llvm/utils/lit/tests/lld-features.py
Modified:
llvm/utils/lit/lit/llvm/config.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 94824cd34773a..bb4d57c75aaac 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -615,11 +615,16 @@ def use_lld(self, additional_tool_dirs=[], required=True,
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..2afd069a47988
--- /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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..656c0bac18594
--- /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
index 0000000000000..f9249baa1ced0
--- /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(use_installed=True)
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..9553d05660f8e
--- /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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..e69de29bb2d1d
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
index 0000000000000..e3487b42c7543
--- /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
index 0000000000000..d1c360eaef1c3
--- /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
More information about the llvm-commits
mailing list