Skip to content

fix: break circular dependency to enable 'BUILD_SHARED_LIBS'#4620

Open
jackfiled wants to merge 1 commit into
llvm:mainfrom
jackfiled:fix/shared-build
Open

fix: break circular dependency to enable 'BUILD_SHARED_LIBS'#4620
jackfiled wants to merge 1 commit into
llvm:mainfrom
jackfiled:fix/shared-build

Conversation

@jackfiled

Copy link
Copy Markdown

This PR tries to close #3961.

Torch-MLIR fails to build when using -DBUILD_SHARED_LIBS=ON. The root cause is a circular dependency between TorchMLIRTorchUtils and TorchMLIRTorchDialect, between TorchMLIRConversionPasses and TorchMLIRTorchConversionPasses, combined with many missing explicit link dependencies across conversion libraries.

This commit does the following works:

  • Inline small utility functions used by TorchMLIRTorchDialect and move squeezeTensor/unsqueezeTensor/sparsity functions to TorchOps.cpp to make TorchMLIRTorchDialect not depend on TorchMLIRTorchUtils.
  • Relocate backend pipeline registration to conversion lib to break the circular dependency between TorchMLIRConversionPasses and TorchMLIRTorchConversionPasses.
  • Add many missing CMake LINK_LIBS.

It's my first time to contribute to LLVM community and this project, any feedback is appreciated!

Break the circular dependcy in TorchMLIRTorchDialect and TorchMLIRTorchUtils, TorchMLIRConversionPasses and TorchMLIRTorchConversionPasses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cmake] Torch-MLIR doesn't build with CMake setting 'BUILD_SHARED_LIBS=ON'

1 participant