[llvm] [mlir] [MLIR][Standalone] test Standalone against install distributions (PR #157944)

Maksim Levental via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 10 22:46:31 PDT 2025


https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/157944

>From 25967cd4ab08ace37fbd9ada80e72105601e27a1 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Wed, 10 Sep 2025 12:57:54 -0700
Subject: [PATCH 1/5] [MLIR][Standalone] test Standalone against install
 distributions

---
 mlir/test/Examples/standalone/lit.local.cfg      |  2 ++
 .../Examples/standalone/test.toy.install-dir     | 16 ++++++++++++++++
 mlir/test/lit.cfg.py                             |  3 +++
 mlir/test/lit.site.cfg.py.in                     |  1 +
 4 files changed, 22 insertions(+)
 create mode 100644 mlir/test/Examples/standalone/test.toy.install-dir

diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg
index fe8397c6b9a10..bc9928decf527 100644
--- a/mlir/test/Examples/standalone/lit.local.cfg
+++ b/mlir/test/Examples/standalone/lit.local.cfg
@@ -10,3 +10,5 @@ config.substitutions.append(("%host_cc", config.host_cc))
 config.substitutions.append(("%enable_libcxx", config.enable_libcxx))
 config.substitutions.append(("%mlir_cmake_dir", config.mlir_cmake_dir))
 config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
+config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
+config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
diff --git a/mlir/test/Examples/standalone/test.toy.install-dir b/mlir/test/Examples/standalone/test.toy.install-dir
new file mode 100644
index 0000000000000..5c33a70491ae1
--- /dev/null
+++ b/mlir/test/Examples/standalone/test.toy.install-dir
@@ -0,0 +1,16 @@
+# REQUIRES: github-actions
+# RUN: "%cmake_exe" --build %llvm_obj_root --target install
+# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
+# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
+# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%host_cmake_install_prefix \
+# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
+# RUN: -DPython3_EXECUTABLE=%python \
+# RUN: -DPython_EXECUTABLE=%python
+# RUN: "%cmake_exe" --build . --target check-standalone | tee %t
+# RUN: FileCheck --input-file=%t %s
+
+# Note: The number of checked tests is not important. The command will fail
+# if any fail.
+# CHECK: Passed
+# CHECK-NOT: Failed
+# UNSUPPORTED: target={{.*(windows|android).*}}
diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
index f99c24d6e299a..08c7947c1e9a6 100644
--- a/mlir/test/lit.cfg.py
+++ b/mlir/test/lit.cfg.py
@@ -383,3 +383,6 @@ def have_host_jit_feature_support(feature_name):
 
 if sys.version_info >= (3, 11):
     config.available_features.add("python-ge-311")
+
+if "GITHUB_ACTIONS" in os.environ:
+    config.available_features.add("github-actions")
diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in
index 8a742a227847b..7e22ebf23c773 100644
--- a/mlir/test/lit.site.cfg.py.in
+++ b/mlir/test/lit.site.cfg.py.in
@@ -18,6 +18,7 @@ config.host_cxx = "@HOST_CXX@"
 config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
 config.host_cmake = "@CMAKE_COMMAND@"
 config.host_cmake_generator = "@CMAKE_GENERATOR@"
+config.host_cmake_install_prefix = "@CMAKE_INSTALL_PREFIX@"
 config.llvm_use_linker = "@LLVM_USE_LINKER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.host_arch = "@HOST_ARCH@"

>From d1c0e0de28156092c459e74b95ffc2350e9e6086 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Wed, 10 Sep 2025 13:23:07 -0700
Subject: [PATCH 2/5] Update lit.site.cfg.py.in

---
 .../standalone/{test.toy.install-dir => test.install-dir.toy}    | 0
 mlir/test/lit.site.cfg.py.in                                     | 1 +
 2 files changed, 1 insertion(+)
 rename mlir/test/Examples/standalone/{test.toy.install-dir => test.install-dir.toy} (100%)

diff --git a/mlir/test/Examples/standalone/test.toy.install-dir b/mlir/test/Examples/standalone/test.install-dir.toy
similarity index 100%
rename from mlir/test/Examples/standalone/test.toy.install-dir
rename to mlir/test/Examples/standalone/test.install-dir.toy
diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in
index 7e22ebf23c773..eadfd047d15f7 100644
--- a/mlir/test/lit.site.cfg.py.in
+++ b/mlir/test/lit.site.cfg.py.in
@@ -3,6 +3,7 @@
 import sys
 
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"

>From 589e6dc18e85e4ffdcff6394a2cec0667b52c5df Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Wed, 10 Sep 2025 15:54:54 -0700
Subject: [PATCH 3/5] add test.install-distribution-dir.toy

---
 mlir/test/Examples/standalone/lit.local.cfg     |  1 +
 .../Examples/standalone/test.install-dir.toy    |  4 ++--
 .../test.install-distribution-dir.toy           | 17 +++++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 mlir/test/Examples/standalone/test.install-distribution-dir.toy

diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg
index bc9928decf527..76b46a458ce98 100644
--- a/mlir/test/Examples/standalone/lit.local.cfg
+++ b/mlir/test/Examples/standalone/lit.local.cfg
@@ -11,4 +11,5 @@ config.substitutions.append(("%enable_libcxx", config.enable_libcxx))
 config.substitutions.append(("%mlir_cmake_dir", config.mlir_cmake_dir))
 config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
 config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
+config.substitutions.append(("%llvm_src_root", config.llvm_src_root))
 config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
diff --git a/mlir/test/Examples/standalone/test.install-dir.toy b/mlir/test/Examples/standalone/test.install-dir.toy
index 5c33a70491ae1..b2bf8726ba17f 100644
--- a/mlir/test/Examples/standalone/test.install-dir.toy
+++ b/mlir/test/Examples/standalone/test.install-dir.toy
@@ -1,8 +1,8 @@
 # REQUIRES: github-actions
-# RUN: "%cmake_exe" --build %llvm_obj_root --target install
+# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install
 # RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
 # RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
-# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%host_cmake_install_prefix \
+# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR="%host_cmake_install_prefix" \
 # RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
 # RUN: -DPython3_EXECUTABLE=%python \
 # RUN: -DPython_EXECUTABLE=%python
diff --git a/mlir/test/Examples/standalone/test.install-distribution-dir.toy b/mlir/test/Examples/standalone/test.install-distribution-dir.toy
new file mode 100644
index 0000000000000..f50f1c1ebf989
--- /dev/null
+++ b/mlir/test/Examples/standalone/test.install-distribution-dir.toy
@@ -0,0 +1,17 @@
+# REQUIRES: github-actions
+# RUN: "%cmake_exe" "%llvm_src_root" -DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-python-sources"
+# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install-distribution
+# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
+# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
+# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%host_cmake_install_prefix \
+# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
+# RUN: -DPython3_EXECUTABLE=%python \
+# RUN: -DPython_EXECUTABLE=%python
+# RUN: "%cmake_exe" --build . --target check-standalone | tee %t
+# RUN: FileCheck --input-file=%t %s
+
+# Note: The number of checked tests is not important. The command will fail
+# if any fail.
+# CHECK: Passed
+# CHECK-NOT: Failed
+# UNSUPPORTED: target={{.*(windows|android).*}}

>From 0b66b50e87dc7b0ad7aa693b6bbab87f634f79fe Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Wed, 10 Sep 2025 18:34:14 -0700
Subject: [PATCH 4/5] Update lit.local.cfg

---
 mlir/test/Examples/standalone/lit.local.cfg | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg
index 76b46a458ce98..1449638d25ef5 100644
--- a/mlir/test/Examples/standalone/lit.local.cfg
+++ b/mlir/test/Examples/standalone/lit.local.cfg
@@ -13,3 +13,4 @@ config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
 config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
 config.substitutions.append(("%llvm_src_root", config.llvm_src_root))
 config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
+config.substitutions.append(("%host_cmake_cmd", config.host_cmake))

>From 58c7f149b88bc073ba8150d95d81aebf7fe561f3 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Wed, 10 Sep 2025 18:34:35 -0700
Subject: [PATCH 5/5] Update test.install-distribution-dir.toy

---
 llvm/utils/lit/lit/llvm/config.py                            | 2 +-
 mlir/examples/standalone/CMakeLists.txt                      | 1 -
 mlir/test/Examples/standalone/lit.local.cfg                  | 4 +++-
 mlir/test/Examples/standalone/test.install-dir.toy           | 1 +
 .../Examples/standalone/test.install-distribution-dir.toy    | 5 +++--
 mlir/test/lit.cfg.py                                         | 2 +-
 mlir/test/lit.site.cfg.py.in                                 | 3 +++
 7 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 56aa5eb64fa36..c532cb7b4b238 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -461,7 +461,7 @@ def add_err_msg_substitutions(self):
 
     def use_default_substitutions(self):
         tool_patterns = [
-            ToolSubst("FileCheck", unresolved="fatal"),
+            ToolSubst("FileCheck", pre=";", post=";", unresolved="fatal"),
             # Handle these specially as they are strings searched for during
             # testing.
             ToolSubst(
diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt
index 88dfa3e5d57a3..f94405f92c1e9 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -8,7 +8,6 @@ set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   find_package(MLIR REQUIRED CONFIG)
 
-
   # Define the default argument to use by `lit` when testing.
   set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
 
diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg
index 1449638d25ef5..2c335c2f0ba7f 100644
--- a/mlir/test/Examples/standalone/lit.local.cfg
+++ b/mlir/test/Examples/standalone/lit.local.cfg
@@ -13,4 +13,6 @@ config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
 config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
 config.substitutions.append(("%llvm_src_root", config.llvm_src_root))
 config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
-config.substitutions.append(("%host_cmake_cmd", config.host_cmake))
+config.substitutions.append(("%cmake_build_type", config.cmake_build_type))
+config.substitutions.append(("%cmake_c_compiler_launcher", config.cmake_c_compiler_launcher))
+config.substitutions.append(("%cmake_cxx_compiler_launcher", config.cmake_cxx_compiler_launcher))
diff --git a/mlir/test/Examples/standalone/test.install-dir.toy b/mlir/test/Examples/standalone/test.install-dir.toy
index b2bf8726ba17f..725f63133c933 100644
--- a/mlir/test/Examples/standalone/test.install-dir.toy
+++ b/mlir/test/Examples/standalone/test.install-dir.toy
@@ -1,4 +1,5 @@
 # REQUIRES: github-actions
+# RUN: rm -rf %host_cmake_install_prefix
 # RUN: "%cmake_exe" --build "%llvm_obj_root" --target install
 # RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
 # RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
diff --git a/mlir/test/Examples/standalone/test.install-distribution-dir.toy b/mlir/test/Examples/standalone/test.install-distribution-dir.toy
index f50f1c1ebf989..b10e6eb6a66a5 100644
--- a/mlir/test/Examples/standalone/test.install-distribution-dir.toy
+++ b/mlir/test/Examples/standalone/test.install-distribution-dir.toy
@@ -1,5 +1,6 @@
-# REQUIRES: github-actions
-# RUN: "%cmake_exe" "%llvm_src_root" -DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-python-sources"
+# RUN: rm -rf %host_cmake_install_prefix
+# RUN: "%cmake_exe" "%llvm_src_root" -DCMAKE_BUILD_TYPE=%cmake_build_type -B "%llvm_obj_root" \
+# RUN: -DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-python-sources"
 # RUN: "%cmake_exe" --build "%llvm_obj_root" --target install-distribution
 # RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
 # RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
index 08c7947c1e9a6..a404aac2ef2f7 100644
--- a/mlir/test/lit.cfg.py
+++ b/mlir/test/lit.cfg.py
@@ -187,7 +187,7 @@ def find_real_python_interpreter():
     llvm_config.with_environment("PATH", dirs, append_path=True)
 
 tools = [
-    "mlir-tblgen",
+    ToolSubst("mlir-tblgen", pre=";", post=";", unresolved="fatal"),
     "mlir-translate",
     "mlir-lsp-server",
     "mlir-capi-execution-engine-test",
diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in
index eadfd047d15f7..ebac12ca42da7 100644
--- a/mlir/test/lit.site.cfg.py.in
+++ b/mlir/test/lit.site.cfg.py.in
@@ -18,6 +18,9 @@ config.host_cc = "@HOST_CC@"
 config.host_cxx = "@HOST_CXX@"
 config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
 config.host_cmake = "@CMAKE_COMMAND@"
+config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
+config.cmake_c_compiler_launcher = "@CMAKE_C_COMPILER_LAUNCHER@"
+config.cmake_cxx_compiler_launcher= "@CMAKE_CXX_COMPILER_LAUNCHER@"
 config.host_cmake_generator = "@CMAKE_GENERATOR@"
 config.host_cmake_install_prefix = "@CMAKE_INSTALL_PREFIX@"
 config.llvm_use_linker = "@LLVM_USE_LINKER@"



More information about the llvm-commits mailing list