diff --git a/mlir/examples/standalone/lib/Standalone/CMakeLists.txt b/mlir/examples/standalone/lib/Standalone/CMakeLists.txt --- a/mlir/examples/standalone/lib/Standalone/CMakeLists.txt +++ b/mlir/examples/standalone/lib/Standalone/CMakeLists.txt @@ -1,18 +1,34 @@ +if (APPLE) + add_mlir_dialect_library(MLIRStandalone + StandaloneTypes.cpp + StandaloneDialect.cpp + StandaloneOps.cpp + StandalonePasses.cpp + + ADDITIONAL_HEADER_DIRS + ${PROJECT_SOURCE_DIR}/include/Standalone + + DEPENDS + MLIRStandaloneOpsIncGen + MLIRStandalonePassesIncGen + ) +else() add_mlir_dialect_library(MLIRStandalone - StandaloneTypes.cpp - StandaloneDialect.cpp - StandaloneOps.cpp - StandalonePasses.cpp + StandaloneTypes.cpp + StandaloneDialect.cpp + StandaloneOps.cpp + StandalonePasses.cpp - ADDITIONAL_HEADER_DIRS - ${PROJECT_SOURCE_DIR}/include/Standalone + ADDITIONAL_HEADER_DIRS + ${PROJECT_SOURCE_DIR}/include/Standalone - DEPENDS - MLIRStandaloneOpsIncGen - MLIRStandalonePassesIncGen + DEPENDS + MLIRStandaloneOpsIncGen + MLIRStandalonePassesIncGen LINK_LIBS PUBLIC MLIRIR - MLIRInferTypeOpInterface - MLIRFuncDialect + MLIRInferTypeOpInterface + MLIRFuncDialect ) +endif() diff --git a/mlir/examples/standalone/standalone-plugin/CMakeLists.txt b/mlir/examples/standalone/standalone-plugin/CMakeLists.txt --- a/mlir/examples/standalone/standalone-plugin/CMakeLists.txt +++ b/mlir/examples/standalone/standalone-plugin/CMakeLists.txt @@ -1,22 +1,30 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) -set(LIBS +if (APPLE) + set(LIBS MLIRStandalone) +else() + set(LIBS MLIRIR MLIRPass MLIRPluginsLib MLIRStandalone MLIRTransformUtils - ) + ) +endif() add_mlir_dialect_library(StandalonePlugin - SHARED - standalone-plugin.cpp + SHARED + standalone-plugin.cpp - DEPENDS - MLIRStandalone - ) + DEPENDS + MLIRStandalone +) llvm_update_compile_flags(StandalonePlugin) -target_link_libraries(StandalonePlugin PRIVATE ${LIBS}) +target_link_libraries(StandalonePlugin + PRIVATE + ${LIBS} + "$<$:-undefined dynamic_lookup>" +) mlir_check_all_link_libraries(StandalonePlugin) diff --git a/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir b/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir --- a/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir +++ b/mlir/examples/standalone/test/Standalone/standalone-pass-plugin.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s --load-pass-plugin=%standalone_libs/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s +// RUN: mlir-opt %s --load-pass-plugin=%standalone_libs/libStandalonePlugin%shlibext --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s module { // CHECK-LABEL: func @foo() diff --git a/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir b/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir --- a/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir +++ b/mlir/examples/standalone/test/Standalone/standalone-plugin.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s --load-dialect-plugin=%standalone_libs/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s +// RUN: mlir-opt %s --load-dialect-plugin=%standalone_libs/libStandalonePlugin%shlibext --pass-pipeline="builtin.module(standalone-switch-bar-foo)" | FileCheck %s module { // CHECK-LABEL: func @foo() diff --git a/mlir/examples/standalone/test/lit.cfg.py b/mlir/examples/standalone/test/lit.cfg.py --- a/mlir/examples/standalone/test/lit.cfg.py +++ b/mlir/examples/standalone/test/lit.cfg.py @@ -30,6 +30,7 @@ config.test_exec_root = os.path.join(config.standalone_obj_root, 'test') config.substitutions.append(('%PATH%', config.environment['PATH'])) +config.substitutions.append(('%shlibext', config.llvm_shlib_ext)) llvm_config.with_system_environment( ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) diff --git a/mlir/examples/standalone/test/lit.site.cfg.py.in b/mlir/examples/standalone/test/lit.site.cfg.py.in --- a/mlir/examples/standalone/test/lit.site.cfg.py.in +++ b/mlir/examples/standalone/test/lit.site.cfg.py.in @@ -4,6 +4,7 @@ config.mlir_obj_dir = "@MLIR_BINARY_DIR@" config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@ config.standalone_obj_root = "@STANDALONE_BINARY_DIR@" +config.llvm_shlib_ext = "@SHLIBEXT@" import lit.llvm lit.llvm.initialize(lit_config, config)