Is there a way to share common dependencies between plugin files?

I have a project that's based around plugins loaded at runtime. Common dependencies between them are the serenity and futures crates, and a piece of code describing the structs passed to the plugin. I compile the plugins as cdylib. It all works fine, but some of the files are over 70MB, which is quite a lot. Would it be possible to not include the dependencies in the compiled file?

Not really.

In theory you can factor out common dependencies as dynamic libraries (so you have libraries loading libraries), but:

  • Rust doesn't guarantee a stable ABI
  • Generics-heavy libraries like futures will have very little code that can be moved to a library anyway

You could try extending your host plug-in API to offer functionality of serenity via a C API, so that plugins won't need to bundle their own.

There's also Maybe you could use it to wrap serenity in a more rusty API and make it a cdylib.

Hm. So I'm stuck with massive files?

Perhaps the files can be trimmed using typical methods, like lto and strip.

That looks promising, thanks

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.