Skip to content

Conversation

makslevental
Copy link
Contributor

@makslevental makslevental commented Sep 12, 2025

This PR turns on all Standalone tests for Windows except for the plugins (which aren't supported on Windows I believe).

@makslevental makslevental force-pushed the users/makslevental/enable-win branch from e392222 to 79234f9 Compare September 12, 2025 04:13
@makslevental makslevental changed the title [MLIR] enable Standalone for Windows [MLIR] enable Standalone example test for Windows Sep 12, 2025
@makslevental makslevental force-pushed the users/makslevental/enable-win branch 10 times, most recently from 1f989d0 to 500f0fe Compare September 12, 2025 05:40
@makslevental makslevental force-pushed the users/makslevental/enable-win branch from 500f0fe to 45308cb Compare September 12, 2025 05:41
@makslevental makslevental marked this pull request as ready for review September 12, 2025 05:51
@llvmbot llvmbot added the mlir label Sep 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2025

@llvm/pr-subscribers-mlir

Author: Maksim Levental (makslevental)

Changes

This PR turns on all Standalone tests for Windows except for the plugins (which aren't supported on Windows I believe).


Full diff: https://github.com/llvm/llvm-project/pull/158183.diff

8 Files Affected:

  • (modified) mlir/examples/standalone/CMakeLists.txt (+3-1)
  • (modified) mlir/examples/standalone/python/CMakeLists.txt (+4)
  • (modified) mlir/examples/standalone/test/CMakeLists.txt (+3-1)
  • (modified) mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir (+1)
  • (modified) mlir/examples/standalone/test/Standalone/standalone-plugin.mlir (+1)
  • (modified) mlir/test/Examples/standalone/lit.local.cfg (+4)
  • (modified) mlir/test/Examples/standalone/test.toy (+5-1)
  • (modified) mlir/test/lit.site.cfg.py.in (+4)
diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt
index 88dfa3e5d57a3..03627c0c10496 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -60,5 +60,7 @@ if(MLIR_ENABLE_BINDINGS_PYTHON)
 endif()
 add_subdirectory(test)
 add_subdirectory(standalone-opt)
-add_subdirectory(standalone-plugin)
+if(NOT WIN32)
+  add_subdirectory(standalone-plugin)
+endif()
 add_subdirectory(standalone-translate)
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index a0eca9c095775..1ab27ce3b533a 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -26,6 +26,8 @@ declare_mlir_python_extension(StandalonePythonSources.Pybind11Extension
   ADD_TO_PARENT StandalonePythonSources
   SOURCES
     StandaloneExtensionPybind11.cpp
+  PRIVATE_LINK_LIBS
+    LLVMSupport
   EMBED_CAPI_LINK_LIBS
     StandaloneCAPI
   PYTHON_BINDINGS_LIBRARY pybind11
@@ -36,6 +38,8 @@ declare_mlir_python_extension(StandalonePythonSources.NanobindExtension
   ADD_TO_PARENT StandalonePythonSources
   SOURCES
     StandaloneExtensionNanobind.cpp
+  PRIVATE_LINK_LIBS
+    LLVMSupport
   EMBED_CAPI_LINK_LIBS
     StandaloneCAPI
   PYTHON_BINDINGS_LIBRARY nanobind
diff --git a/mlir/examples/standalone/test/CMakeLists.txt b/mlir/examples/standalone/test/CMakeLists.txt
index fdde159064287..8864563df8a33 100644
--- a/mlir/examples/standalone/test/CMakeLists.txt
+++ b/mlir/examples/standalone/test/CMakeLists.txt
@@ -14,8 +14,10 @@ set(STANDALONE_TEST_DEPENDS
         standalone-capi-test
         standalone-opt
         standalone-translate
-        StandalonePlugin
         )
+if(NOT WIN32)
+  list(APPEND STANDALONE_TEST_DEPENDS StandalonePlugin)
+endif()
 if(MLIR_ENABLE_BINDINGS_PYTHON)
   list(APPEND STANDALONE_TEST_DEPENDS StandalonePythonModules)
 endif()
diff --git a/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir b/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir
index 1d652dc45830c..3020097dc1640 100644
--- a/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir
+++ b/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: mlir-opt %s --load-pass-plugin=%standalone_libs/StandalonePlugin%shlibext --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s
 
 module {
diff --git a/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir b/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir
index 468932b81a529..900b524c1feb7 100644
--- a/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir
+++ b/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: mlir-opt %s --load-dialect-plugin=%standalone_libs/StandalonePlugin%shlibext --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s
 
 module {
diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg
index fe8397c6b9a10..ef4e743a3add8 100644
--- a/mlir/test/Examples/standalone/lit.local.cfg
+++ b/mlir/test/Examples/standalone/lit.local.cfg
@@ -10,3 +10,7 @@ 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(("%cmke_exe_linker_flags", config.cmake_exe_linker_flags))
+config.substitutions.append(("%cmake_module_linker_flags", config.cmake_module_linker_flags))
+config.substitutions.append(("%cmake_shared_linker_flags", config.cmake_shared_linker_flags))
+config.substitutions.append(("%cmake_build_type", config.cmake_build_type))
diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy
index e99bab5f0affc..527c82fa85350 100644
--- a/mlir/test/Examples/standalone/test.toy
+++ b/mlir/test/Examples/standalone/test.toy
@@ -1,7 +1,11 @@
 # RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
+# RUN: -DCMAKE_BUILD_TYPE=%cmake_build_type \
 # RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
 # RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir \
 # RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
+# RUN: -DCMAKE_EXE_LINKER_FLAGS="%cmke_exe_linker_flags" \
+# RUN: -DCMAKE_MODULE_LINKER_FLAGS="%cmake_module_linker_flags" \
+# RUN: -DCMAKE_SHARED_LINKER_FLAGS="%cmake_shared_linker_flags" \
 # RUN: -DPython3_EXECUTABLE=%python \
 # RUN: -DPython_EXECUTABLE=%python
 # RUN: "%cmake_exe" --build . --target check-standalone | tee %t
@@ -11,4 +15,4 @@
 # if any fail.
 # CHECK: Passed
 # CHECK-NOT: Failed
-# UNSUPPORTED: target={{.*(windows|android).*}}
+# UNSUPPORTED: target={{.*(android).*}}
diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in
index 8a742a227847b..c564a51128739 100644
--- a/mlir/test/lit.site.cfg.py.in
+++ b/mlir/test/lit.site.cfg.py.in
@@ -18,6 +18,10 @@ config.host_cxx = "@HOST_CXX@"
 config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
 config.host_cmake = "@CMAKE_COMMAND@"
 config.host_cmake_generator = "@CMAKE_GENERATOR@"
+config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
+config.cmake_exe_linker_flags = "@CMAKE_EXE_LINKER_FLAGS@"
+config.cmake_module_linker_flags = "@CMAKE_MODULE_LINKER_FLAGS@"
+config.cmake_shared_linker_flags = "@CMAKE_SHARED_LINKER_FLAGS@"
 config.llvm_use_linker = "@LLVM_USE_LINKER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.host_arch = "@HOST_ARCH@"

Copy link
Contributor

@christopherbate christopherbate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM although I don't have an easy way to test the changes locally.

BTW what is the plugin limitation on windows? I couldn't find any mention of this in the codebase.

@makslevental
Copy link
Contributor Author

BTW what is the plugin limitation on windows? I couldn't find any mention of this in the codebase.

I'm struggling to remember but I went back to one of the original PRs and found this link that suggest it should work. The thing is I did have it on in the first push and there was a fail that I can't find in the CI (here) now. Let me switch it back on and see what happens.

@makslevental
Copy link
Contributor Author

2025-09-12T17:47:03.2044126Z # | -- StandalonePlugin ignored -- Loadable modules not supported on this platform.

You can trace it back to

if(WIN32 OR CYGWIN)
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
set(LLVM_ENABLE_PLUGINS_default ON)
else()
set(LLVM_ENABLE_PLUGINS_default OFF)
endif()
else()
set(LLVM_ENABLE_PLUGINS_default ${LLVM_ENABLE_PIC})
endif()
option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default})

So maybe it can be made to work by adding one of those prereqs but I'd rather not mess with it here.

@makslevental makslevental force-pushed the users/makslevental/enable-win branch from 6c48b53 to a18bf40 Compare September 12, 2025 18:12
@makslevental makslevental merged commit 1a6b2b6 into llvm:main Sep 12, 2025
15 checks passed
@makslevental makslevental deleted the users/makslevental/enable-win branch September 12, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants