Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update building plugin guide #1515

Open
erick-xanadu opened this issue Feb 12, 2025 · 0 comments
Open

Update building plugin guide #1515

erick-xanadu opened this issue Feb 12, 2025 · 0 comments
Assignees
Labels
chore documentation Improvements or additions to documentation

Comments

@erick-xanadu
Copy link
Contributor

erick-xanadu commented Feb 12, 2025

Users reported the following:

With these changes, you should now be able to use make all and build the standalone plugin.

I find that all of the above changes get overwritten with the initial state. Is there some configuration that might cause a reset of the standalone implementation?

Additionally, the build process can be somewhat simplified. I originally had issues building the standalone plugin and including Catalyst's sources without making it part of the Catalyst build system. I asked a question on discord:

Hello,

I have a MLIR based project. I am trying to make the experience of writing a standalone-plugin for my project fairly easy. I have not modified the standalone-plugin build system in any major way yet. (I would say I haven't modified the build system besides patching the CMake to have a path to my mlir-opt-like tool and patching the lit tests so that my mlir-opt-like tool is used instead of mlir-opt). This works well so far.

However, I am trying now to modify the Standalone Pass available upstream to be able to correctly have the INCLUDE_DIRS for my project. I was able to do that myself, but I am having troubles after adding this line:

let dependentDialects = [
"foo::MyDialect"
];

When I build the standalone-plugin everything appears to work until the linking phase. I then get the following message:

/usr/bin/ld: lib/libMLIRStandalone.a(StandalonePasses.cpp.o): in function `mlir::detail::TypeIDResolver<foo::MyDialect, void>::resolveTypeID()':
StandalonePasses.cpp:

// ... snip ...

undefined reference to `foo::MyDialect::MyDialect(mlir::MLIRContext*)'
collect2: error: ld returned 1 exit status

I understand that this is missing in the linking stage. I believe what I need to do is to have the StandalonePlugin cmake file modified to add my library, something like

add_llvm_library(StandalonePlugin

   DEPENDS
   MLIRMyDialect
   MLIRStandalone
   PLUGIN_TOOL
   mlir-opt

   LINK_LIBS
   MLIRMyDialect
   MLIRStandalone
   )

But I am having some troubles getting this to work. I have the following questions:

Does anyone know of a project that has already implemented this type of support? I would like to see how they set up their build system to make it easy for MLIR plugin developers to reuse their dialects.
Does anyone have an idea on where to get started? Should I use FetchContent or AddExternalDependency? Maybe a link to read some documentation.

Thanks in advance!

Finally got a reply (thanks Maks!)

this means you're missing an include MyDialect.cpp.inc somewhere
that's where those TypeIDResolver resolvers live

which could simplify the build process

@erick-xanadu erick-xanadu added chore documentation Improvements or additions to documentation labels Feb 12, 2025
@erick-xanadu erick-xanadu self-assigned this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant