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

Create single module for shared functionality #1896

Open
bendk opened this issue Dec 12, 2023 · 1 comment
Open

Create single module for shared functionality #1896

bendk opened this issue Dec 12, 2023 · 1 comment

Comments

@bendk
Copy link
Contributor

bendk commented Dec 12, 2023

We should look into creating a single module on the foreign side that holds all shared functionality: RustBuffer, Future handling code, etc. There would be a couple advantages to this:

  • Smaller bindings
  • Simplifies compatibility issues with external types. With our current system, we create a separate RustBuffer class for each module, which makes using an external type weird since it each module uses a different RustBuffer.
  • Simplifies global callback registration, for example the foreign executor callback that we used to have.
@alexkirsz
Copy link
Contributor

We would love to have that as well!

In our setup, instead of running uniffi in a single step at the very end of the compilation process, we run it directly on the intermediate rlibs of each uniffi library. The current issues we've seen with this approach are:

  1. uniffi will always re-generate bindings for all upstream uniffi libraries at every step; and
  2. each module has its own RustBuffer/Primitive/Future handling code.

For 1., we only extract the generated module of the current uniffi library and ignore the rest.

For 2., it's unclear to us at this point if these duplicate implementations increase the final binary size, or if the foreign language's compiler and/or linker allow for deduplication. We will eventually need to investigate this, as we've found that splitting a single uniffi library into two different libraries with the same surface API increased our binary size significantly.

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

No branches or pull requests

2 participants