diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -15,6 +15,10 @@ cmake_policy(SET CMP0077 NEW) endif() +if(POLICY CMP0023) + cmake_policy(SET CMP0023 OLD) +endif() + if(NOT DEFINED LLVM_VERSION_MAJOR) set(LLVM_VERSION_MAJOR 11) endif() diff --git a/mlir/tools/CMakeLists.txt b/mlir/tools/CMakeLists.txt --- a/mlir/tools/CMakeLists.txt +++ b/mlir/tools/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory(mlir-opt) add_subdirectory(mlir-tblgen) add_subdirectory(mlir-translate) +add_subdirectory(mlir-shlib) diff --git a/mlir/tools/mlir-shlib/CMakeLists.txt b/mlir/tools/mlir-shlib/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/tools/mlir-shlib/CMakeLists.txt @@ -0,0 +1,63 @@ +# This tool creates a shared library from the MLIR libraries. Generating this +# library is enabled by setting MLIR_BUILD_MLIR_DYLIB=yes on the CMake +# commandline. + +set(SOURCES + libmlir.cpp + ) + +#if(MLIR_BUILD_MLIR_DYLIB) + +set(LIBS + MLIRAnalysis + MLIRAffineOps + MLIRAffineToStandard + MLIRLoopsToGPU + MLIRLinalgToLLVM + + MLIRLoopToStandard + MLIREDSC + MLIRFxpMathOps + MLIRGPU + MLIRGPUtoNVVMTransforms + MLIRGPUtoROCDLTransforms + MLIRGPUtoSPIRVTransforms + MLIRLinalgOps + MLIRLLVMIR + MLIRLoopOps + MLIRNVVMIR + MLIROptMain + MLIRParser + MLIRPass + MLIRQuantizerTransforms + MLIRQuantOps + MLIRROCDLIR + MLIRSPIRV + MLIRStandardToSPIRVTransforms + MLIRSPIRVTestPasses + MLIRSPIRVTransforms + MLIRStandardOps + MLIRStandardToLLVM + MLIRTransforms + MLIRTestDialect + MLIRTestIR + MLIRTestPass + MLIRTestTransforms + MLIRSupport + MLIRVectorOps + MLIRVectorToLLVM + MLIRVectorToLoops +) +if(MLIR_CUDA_CONVERSIONS_ENABLED) + list(APPEND LIBS + MLIRGPUtoCUDATransforms + ) +endif() + +add_llvm_library(MLIR SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES}) + +llvm_update_compile_flags(MLIR) +whole_archive_link(MLIR ${LIBS}) +target_link_libraries(MLIR PRIVATE ${LIBS}) +#endif() + diff --git a/mlir/tools/mlir-shlib/libmlir.cpp b/mlir/tools/mlir-shlib/libmlir.cpp new file mode 100644 --- /dev/null +++ b/mlir/tools/mlir-shlib/libmlir.cpp @@ -0,0 +1,12 @@ +//===-libllvm.cpp - LLVM Shared Library -----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is empty and serves only the purpose of making CMake happy because +// you can't define a target with no sources. +// +//===----------------------------------------------------------------------===//