diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh index 5abb8d72df028..dde5125b456ba 100755 --- a/.ci/monolithic-linux.sh +++ b/.ci/monolithic-linux.sh @@ -58,11 +58,13 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ -D LIBCXX_CXX_ABI=libcxxabi \ -D MLIR_ENABLE_BINDINGS_PYTHON=ON \ + -D MLIR_RUN_STANDALONE_INSTALL_TESTS=ON \ -D LLDB_ENABLE_PYTHON=ON \ -D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \ -D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -D CMAKE_EXE_LINKER_FLAGS="-no-pie" \ - -D LLVM_ENABLE_WERROR=ON + -D LLVM_ENABLE_WERROR=ON \ + -D LLVM_INSTALL_UTILS=ON start-group "ninja" diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh index f85d6e3d51b57..f1f5010425f2e 100755 --- a/.ci/monolithic-windows.sh +++ b/.ci/monolithic-windows.sh @@ -46,10 +46,12 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ -D CMAKE_C_COMPILER_LAUNCHER=sccache \ -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ -D MLIR_ENABLE_BINDINGS_PYTHON=ON \ + -D MLIR_RUN_STANDALONE_INSTALL_TESTS=ON \ -D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \ -D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \ -D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \ - -D LLVM_ENABLE_RUNTIMES="${runtimes}" + -D LLVM_ENABLE_RUNTIMES="${runtimes}" \ + -D LLVM_INSTALL_UTILS=ON start-group "ninja" diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt index 88dfa3e5d57a3..887eba036e99c 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") @@ -60,5 +59,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/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/lit.cfg.py b/mlir/examples/standalone/test/lit.cfg.py index e27dddd7fb0b9..d4c1918fc5b3e 100644 --- a/mlir/examples/standalone/test/lit.cfg.py +++ b/mlir/examples/standalone/test/lit.cfg.py @@ -53,7 +53,7 @@ tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir] tools = [ - "mlir-opt", + ToolSubst("mlir-opt", pre=";", post=";", unresolved="fatal"), "standalone-capi-test", "standalone-opt", "standalone-translate", diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt index 628adcfb6e285..41f787fbfdced 100644 --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -65,6 +65,12 @@ if (MLIR_INCLUDE_INTEGRATION_TESTS) endif() +option(MLIR_RUN_STANDALONE_INSTALL_TESTS "Run Standalone example install tests." OFF) +if(MLIR_RUN_STANDALONE_INSTALL_TESTS AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "") + message(WARNING "Standalone example install tests will install into root!\ + If you want to disable this behavior pass -DMLIR_RUN_STANDALONE_INSTALL_TESTS=OFF") +endif() + llvm_canonicalize_cmake_booleans( LLVM_BUILD_EXAMPLES LLVM_HAS_NVPTX_TARGET @@ -76,6 +82,7 @@ llvm_canonicalize_cmake_booleans( MLIR_ENABLE_SPIRV_CPU_RUNNER MLIR_ENABLE_VULKAN_RUNNER MLIR_INCLUDE_INTEGRATION_TESTS + MLIR_RUN_STANDALONE_INSTALL_TESTS MLIR_RUN_AMX_TESTS MLIR_RUN_CUDA_TENSOR_CORE_TESTS MLIR_RUN_X86VECTOR_TESTS diff --git a/mlir/test/Examples/standalone/lit.local.cfg b/mlir/test/Examples/standalone/lit.local.cfg index fe8397c6b9a10..cd2df2dd8f3a8 100644 --- a/mlir/test/Examples/standalone/lit.local.cfg +++ b/mlir/test/Examples/standalone/lit.local.cfg @@ -10,3 +10,19 @@ 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(("%llvm_src_root", config.llvm_src_root)) +config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix)) +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)) + +if config.run_standalone_install_tests: + config.available_features.add("run-standalone-install-tests") + # see https://github.com/llvm/llvm-project/blob/57782eff31e9d454b54a201c7ac43dc1b93dbb3f/llvm/utils/lit/lit/TestRunner.py#L1858 + config.substitutions.insert(0, ("FileCheck", "FileChuck")) + config.substitutions.insert(0, ("count", "kount")) + config.substitutions.insert(0, ("not", "mot")) + config.substitutions.append(("kount", "count")) + config.substitutions.append(("mot", "not")) + config.substitutions.append(("FileChuck", "FileCheck")) diff --git a/mlir/test/Examples/standalone/test.install-dir.toy b/mlir/test/Examples/standalone/test.install-dir.toy new file mode 100644 index 0000000000000..6531bf8098aec --- /dev/null +++ b/mlir/test/Examples/standalone/test.install-dir.toy @@ -0,0 +1,50 @@ +# REQUIRES: run-standalone-install-tests + +# RUN: echo "test full install" | tee %t +# CHECK: test full install + +# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install -j | tee -a %t + +# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \ +# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \ +# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \ +# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx \ +# RUN: -DLLVM_EXTERNAL_LIT="%llvm_obj_root/bin/llvm-lit" \ +# RUN: -DMLIR_DIR="%host_cmake_install_prefix/lib/cmake/mlir" \ +# RUN: -DLLVM_DIR="%host_cmake_install_prefix/lib/cmake/llvm" \ +# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \ +# RUN: -DPython3_EXECUTABLE=%python \ +# RUN: -DPython_EXECUTABLE=%python | tee -a %t + +# RUN: "%cmake_exe" --build . --target check-standalone -j | tee -a %t + +# CHECK: Passed +# CHECK-NOT: Failed +# UNSUPPORTED: target={{.*(windows|android).*}} + +# RUN: echo "test install distribution" | tee -a %t +# CHECK: test install distribution + +# 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;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-opt;mlir-python-sources" | tee -a %t + +# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install-distribution -j | tee -a %t + +# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \ +# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \ +# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \ +# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx \ +# RUN: -DLLVM_EXTERNAL_LIT="%llvm_obj_root/bin/llvm-lit" \ +# RUN: -DMLIR_DIR="%host_cmake_install_prefix/lib/cmake/mlir" \ +# RUN: -DLLVM_DIR="%host_cmake_install_prefix/lib/cmake/llvm" \ +# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \ +# RUN: -DPython3_EXECUTABLE=%python \ +# RUN: -DPython_EXECUTABLE=%python | tee -a %t + +# RUN: "%cmake_exe" --build . --target check-standalone -j | tee -a %t + +# RUN: FileCheck --input-file=%t %s + +# CHECK: Passed +# CHECK-NOT: Failed +# UNSUPPORTED: target={{.*(windows|android).*}} diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy index e99bab5f0affc..c3e855b5d202d 100644 --- a/mlir/test/Examples/standalone/test.toy +++ b/mlir/test/Examples/standalone/test.toy @@ -1,5 +1,6 @@ # RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \ # RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \ +# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \ # RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir \ # RUN: -DLLVM_USE_LINKER=%llvm_use_linker \ # RUN: -DPython3_EXECUTABLE=%python \ @@ -11,4 +12,4 @@ # if any fail. # CHECK: Passed # CHECK-NOT: Failed -# UNSUPPORTED: target={{.*(windows|android).*}} +# UNSUPPORTED: target={{.*(android).*}} diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py index f99c24d6e299a..c1cd371a466b7 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", @@ -318,7 +318,7 @@ def find_real_python_interpreter(): ] ) else: - tools.extend(["mlir-opt"]) + tools.extend([ToolSubst("mlir-opt", pre=";", post=";", unresolved="fatal")]) llvm_config.add_tool_substitutions(tools, tool_dirs) diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in index 8a742a227847b..b1044f5f86563 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@" @@ -17,7 +18,11 @@ 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@" config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.host_arch = "@HOST_ARCH@" @@ -31,6 +36,7 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@ config.run_nvptx_tests = @LLVM_HAS_NVPTX_TARGET@ config.enable_cuda_runner = @MLIR_ENABLE_CUDA_RUNNER@ config.run_rocm_tests = @MLIR_ENABLE_ROCM_CONVERSIONS@ +config.run_standalone_install_tests = @MLIR_RUN_STANDALONE_INSTALL_TESTS@ config.enable_rocm_runner = @MLIR_ENABLE_ROCM_RUNNER@ config.gpu_compilation_format = "@MLIR_GPU_COMPILATION_TEST_FORMAT@" config.rocm_test_chipset = "@ROCM_TEST_CHIPSET@"